Changeset: c87f16b6e584 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=c87f16b6e584
Modified Files:
clients/mapiclient/dump.c
clients/mapiclient/mclient.c
clients/mapiclient/msqldump.c
clients/mapiclient/msqldump.h
Branch: comment-on
Log Message:
Emit SET SCHEMA in msqldump -f
diffs (94 lines):
diff --git a/clients/mapiclient/dump.c b/clients/mapiclient/dump.c
--- a/clients/mapiclient/dump.c
+++ b/clients/mapiclient/dump.c
@@ -1589,7 +1589,7 @@ dump_function(Mapi mid, stream *toConsol
}
int
-dump_functions(Mapi mid, stream *toConsole, const char *sname, const char
*fname, const char *id)
+dump_functions(Mapi mid, stream *toConsole, char set_schema, const char
*sname, const char *fname, const char *id)
{
MapiHdl hdl;
char *query, *q, *end_q;
@@ -1597,6 +1597,7 @@ dump_functions(Mapi mid, stream *toConso
int hashge = has_hugeint(mid);
char *to_free = NULL;
char wantSystem;
+ long prev_sid;
if (fname != NULL) {
/* dump a single function */
@@ -1629,7 +1630,7 @@ dump_functions(Mapi mid, stream *toConso
end_q = q + len;
q += snprintf(q, end_q - q,
- "SELECT f.id, LENGTH(rem.remark) "
+ "SELECT s.id, s.name, f.id, LENGTH(rem.remark) AS remark_len "
"FROM sys.schemas s "
"JOIN sys.functions f ON s.id = f.schema_id "
"LEFT OUTER JOIN sys.comments rem ON f.id = rem.id "
@@ -1648,9 +1649,18 @@ dump_functions(Mapi mid, stream *toConso
free(query);
if (hdl == NULL || mapi_error(mid))
goto bailout;
+ prev_sid = 0;
while (!mnstr_errnr(toConsole) && mapi_fetch_row(hdl) != 0) {
- const char *fid = mapi_fetch_field(hdl, 0);
- const char *remark_len = mapi_fetch_field(hdl, 1);
+ long sid = strtol(mapi_fetch_field(hdl, 0), NULL, 10);
+ const char *schema = mapi_fetch_field(hdl, 1);
+ const char *fid = mapi_fetch_field(hdl, 2);
+ const char *remark_len = mapi_fetch_field(hdl, 3);
+ if (set_schema && sid != prev_sid) {
+ mnstr_printf(toConsole, "SET SCHEMA ");
+ quoted_print(toConsole, schema, 0);
+ mnstr_printf(toConsole, ";\n");
+ prev_sid = sid;
+ }
dump_function(mid, toConsole, fid, hashge);
if (remark_len)
dump_function_comment(mid, toConsole, fid);
@@ -2150,7 +2160,7 @@ dump_database(Mapi mid, stream *toConsol
curschema);
}
if (routine)
- dump_functions(mid, toConsole, schema, name, id);
+ dump_functions(mid, toConsole, 0, schema, name, id);
else
mnstr_printf(toConsole, "%s\n", query);
append_comment(comments, type, sname, name, NULL, NULL, remark);
diff --git a/clients/mapiclient/mclient.c b/clients/mapiclient/mclient.c
--- a/clients/mapiclient/mclient.c
+++ b/clients/mapiclient/mclient.c
@@ -2496,7 +2496,7 @@ doFile(Mapi mid, stream *fp, int useinse
if (x & MD_SEQ)
describe_sequence(mid,
NULL, line, toConsole);
if (x & MD_FUNC)
- dump_functions(mid,
toConsole, NULL, line, NULL);
+ dump_functions(mid,
toConsole, 0, NULL, line, NULL);
if (x & MD_SCHEMA)
describe_schema(mid,
line, toConsole);
#ifdef HAVE_POPEN
diff --git a/clients/mapiclient/msqldump.c b/clients/mapiclient/msqldump.c
--- a/clients/mapiclient/msqldump.c
+++ b/clients/mapiclient/msqldump.c
@@ -219,7 +219,7 @@ main(int argc, char **argv)
dump_version(mid, out, "--");
}
if (functions)
- c = dump_functions(mid, out, NULL, NULL, NULL);
+ c = dump_functions(mid, out, 1, NULL, NULL, NULL);
else if (table)
c = dump_table(mid, NULL, table, out, describe, 1, useinserts);
else
diff --git a/clients/mapiclient/msqldump.h b/clients/mapiclient/msqldump.h
--- a/clients/mapiclient/msqldump.h
+++ b/clients/mapiclient/msqldump.h
@@ -10,6 +10,6 @@ extern int describe_table(Mapi mid, cons
extern int describe_sequence(Mapi mid, const char *schema, const char *sname,
stream *toConsole);
extern int describe_schema(Mapi mid, const char *sname, stream *toConsole);
extern int dump_table(Mapi mid, const char *schema, const char *tname, stream
*toConsole, int describe, int foreign, char useInserts);
-extern int dump_functions(Mapi mid, stream *toConsole, const char *sname,
const char *fname, const char *id);
+extern int dump_functions(Mapi mid, stream *toConsole, char set_schema, const
char *sname, const char *fname, const char *id);
extern int dump_database(Mapi mid, stream *toConsole, int describe, char
useInserts);
extern void dump_version(Mapi mid, stream *toConsole, const char *prefix);
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list