Changeset: a7e989341828 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/a7e989341828 Modified Files: clients/mapiclient/dump.c Branch: default Log Message:
Merge with Mar2025 branch. diffs (273 lines): diff --git a/clients/ChangeLog.Mar2025 b/clients/ChangeLog.Mar2025 --- a/clients/ChangeLog.Mar2025 +++ b/clients/ChangeLog.Mar2025 @@ -1,3 +1,9 @@ # ChangeLog file for clients # This file is updated with Maddlog +* Thu Sep 11 2025 Sjoerd Mullender <[email protected]> +- Changed the --describe (-D) option of msqldump to really mean (as it + says in the manual) do a dump without the data. Before, the output + looked like a dump, but could not necessarily be fed back into an + mserver5, i.e. it wasn't really a dump without data. + diff --git a/clients/mapiclient/dump.c b/clients/mapiclient/dump.c --- a/clients/mapiclient/dump.c +++ b/clients/mapiclient/dump.c @@ -2928,7 +2928,6 @@ dump_database(Mapi mid, stream *sqlf, co const char *uname = mapi_fetch_field(hdl, 0); const char *fullname = mapi_fetch_field(hdl, 1); const char *pwhash = mapi_fetch_field(hdl, 2); - const char *sname = mapi_fetch_field(hdl, 3); const char *spath = mapi_fetch_field(hdl, 4); const char *mmemory = mapi_fetch_field(hdl, 5); const char *mworkers = mapi_fetch_field(hdl, 6); @@ -2942,7 +2941,7 @@ dump_database(Mapi mid, stream *sqlf, co mnstr_printf(sqlf, " NAME "); squoted_print(sqlf, fullname, '\'', false); mnstr_printf(sqlf, " SCHEMA "); - dquoted_print(sqlf, describe ? sname : "sys", NULL); + dquoted_print(sqlf, "sys", NULL); if (spath && strcmp(spath, "\"sys\"") != 0) { mnstr_printf(sqlf, " SCHEMA PATH "); squoted_print(sqlf, spath, '\'', false); @@ -2991,26 +2990,24 @@ dump_database(Mapi mid, stream *sqlf, co goto bailout; mapi_close_handle(hdl); - if (!describe) { - /* dump users, part 2 */ - if ((hdl = mapi_query(mid, users)) == NULL || - mapi_error(mid)) - goto bailout; + /* dump users, part 2 */ + if ((hdl = mapi_query(mid, users)) == NULL || + mapi_error(mid)) + goto bailout; - while (mapi_fetch_row(hdl) != 0) { - char *uname = mapi_fetch_field(hdl, 0); - char *sname = mapi_fetch_field(hdl, 3); + while (mapi_fetch_row(hdl) != 0) { + char *uname = mapi_fetch_field(hdl, 0); + char *sname = mapi_fetch_field(hdl, 3); - if (strcmp(sname, "sys") == 0) - continue; - mnstr_printf(sqlf, "ALTER USER "); - dquoted_print(sqlf, uname, " SET SCHEMA "); - dquoted_print(sqlf, sname, ";\n"); - } - if (mapi_error(mid)) - goto bailout; - mapi_close_handle(hdl); + if (strcmp(sname, "sys") == 0) + continue; + mnstr_printf(sqlf, "ALTER USER "); + dquoted_print(sqlf, uname, " SET SCHEMA "); + dquoted_print(sqlf, sname, ";\n"); } + if (mapi_error(mid)) + goto bailout; + mapi_close_handle(hdl); /* grant user privileges */ if ((hdl = mapi_query(mid, grants)) == NULL || mapi_error(mid)) @@ -3141,8 +3138,9 @@ dump_database(Mapi mid, stream *sqlf, co dquoted_print(sqlf, curschema, ";\n"); } } - int ptype = atoi(type), dont_describe = (ptype == 3 || ptype == 5); - rc = dump_table(mid, schema, name, sqlf, ddir, ext, dont_describe || describe, describe, useInserts, true, noescape, false); + int ptype = atoi(type); + bool dont_describe = (ptype == 3 || ptype == 5); + rc = dump_table(mid, schema, name, sqlf, ddir, ext, dont_describe || describe, false, useInserts, true, noescape, false); free(id); free(schema); free(name); @@ -3209,62 +3207,60 @@ dump_database(Mapi mid, stream *sqlf, co if (dump_table_defaults(mid, NULL, NULL, sqlf)) goto bailout2; - if (!describe) { - if (dump_foreign_keys(mid, NULL, NULL, NULL, sqlf)) - goto bailout2; + if (dump_foreign_keys(mid, NULL, NULL, NULL, sqlf)) + goto bailout2; - /* dump sequences, part 2 */ - if ((hdl = mapi_query(mid, sequences2)) == NULL || - mapi_error(mid)) - goto bailout; + /* dump sequences, part 2 */ + if ((hdl = mapi_query(mid, sequences2)) == NULL || + mapi_error(mid)) + goto bailout; - while (mapi_fetch_row(hdl) != 0) { - const char *schema = mapi_fetch_field(hdl, 0); /* sch */ - const char *name = mapi_fetch_field(hdl, 1); /* seq */ - const char *restart = mapi_fetch_field(hdl, 3); /* rs */ - const char *minvalue; - const char *maxvalue; - const char *increment = mapi_fetch_field(hdl, 6); /* inc */ - const char *cycle = mapi_fetch_field(hdl, 8); /* cycle */ + while (mapi_fetch_row(hdl) != 0) { + const char *schema = mapi_fetch_field(hdl, 0); /* sch */ + const char *name = mapi_fetch_field(hdl, 1); /* seq */ + const char *restart = mapi_fetch_field(hdl, 3); /* rs */ + const char *minvalue; + const char *maxvalue; + const char *increment = mapi_fetch_field(hdl, 6); /* inc */ + const char *cycle = mapi_fetch_field(hdl, 8); /* cycle */ - if (mapi_get_field_count(hdl) > 9) { - /* new version (Jan2022) of sys.describe_sequences */ - minvalue = mapi_fetch_field(hdl, 11); /* rmi */ - maxvalue = mapi_fetch_field(hdl, 12); /* rma */ - } else { - /* old version (pre Jan2022) of sys.describe_sequences */ - minvalue = mapi_fetch_field(hdl, 4); /* minvalue */ - maxvalue = mapi_fetch_field(hdl, 5); /* maxvalue */ - if (strcmp(minvalue, "0") == 0) - minvalue = NULL; - if (strcmp(maxvalue, "0") == 0) - maxvalue = NULL; - } + if (mapi_get_field_count(hdl) > 9) { + /* new version (Jan2022) of sys.describe_sequences */ + minvalue = mapi_fetch_field(hdl, 11); /* rmi */ + maxvalue = mapi_fetch_field(hdl, 12); /* rma */ + } else { + /* old version (pre Jan2022) of sys.describe_sequences */ + minvalue = mapi_fetch_field(hdl, 4); /* minvalue */ + maxvalue = mapi_fetch_field(hdl, 5); /* maxvalue */ + if (strcmp(minvalue, "0") == 0) + minvalue = NULL; + if (strcmp(maxvalue, "0") == 0) + maxvalue = NULL; + } - if (sname != NULL && strcmp(schema, sname) != 0) - continue; + if (sname != NULL && strcmp(schema, sname) != 0) + continue; - mnstr_printf(sqlf, + mnstr_printf(sqlf, "ALTER SEQUENCE "); - dquoted_print(sqlf, schema, "."); - dquoted_print(sqlf, name, NULL); - mnstr_printf(sqlf, " RESTART WITH %s", restart); - if (strcmp(increment, "1") != 0) - mnstr_printf(sqlf, " INCREMENT BY %s", increment); - if (minvalue) - mnstr_printf(sqlf, " MINVALUE %s", minvalue); - if (maxvalue) - mnstr_printf(sqlf, " MAXVALUE %s", maxvalue); - mnstr_printf(sqlf, " %sCYCLE;\n", strcmp(cycle, "true") == 0 ? "" : "NO "); - if (mnstr_errnr(sqlf) != MNSTR_NO__ERROR) { - mapi_close_handle(hdl); - goto bailout2; - } + dquoted_print(sqlf, schema, "."); + dquoted_print(sqlf, name, NULL); + mnstr_printf(sqlf, " RESTART WITH %s", restart); + if (strcmp(increment, "1") != 0) + mnstr_printf(sqlf, " INCREMENT BY %s", increment); + if (minvalue) + mnstr_printf(sqlf, " MINVALUE %s", minvalue); + if (maxvalue) + mnstr_printf(sqlf, " MAXVALUE %s", maxvalue); + mnstr_printf(sqlf, " %sCYCLE;\n", strcmp(cycle, "true") == 0 ? "" : "NO "); + if (mnstr_errnr(sqlf) != MNSTR_NO__ERROR) { + mapi_close_handle(hdl); + goto bailout2; } - if (mapi_error(mid)) - goto bailout; - mapi_close_handle(hdl); } + if (mapi_error(mid)) + goto bailout; + mapi_close_handle(hdl); /* add tables to MERGE tables */ if ((hdl = mapi_query(mid, mergetables)) == NULL || mapi_error(mid)) diff --git a/clients/mapiclient/msqldump.c b/clients/mapiclient/msqldump.c --- a/clients/mapiclient/msqldump.c +++ b/clients/mapiclient/msqldump.c @@ -81,7 +81,7 @@ main(int argc, char **argv) bool quiet = false; stream *out; bool user_set_as_flag = false; - char *table = NULL; + const char *table = NULL; static struct option long_options[] = { {"host", 1, 0, 'h'}, {"port", 1, 0, 'p'}, diff --git a/sql/jdbc/tests/Tests/Test_JdbcClient.SQL.py b/sql/jdbc/tests/Tests/Test_JdbcClient.SQL.py --- a/sql/jdbc/tests/Tests/Test_JdbcClient.SQL.py +++ b/sql/jdbc/tests/Tests/Test_JdbcClient.SQL.py @@ -88,7 +88,7 @@ if __name__ == '__main__': p = run(cmd, stdout=PIPE, stderr=PIPE, check=True, encoding='utf-8') pout = str(p.stdout) perr = str(p.stderr) - if perr != "Error on line 12: [22000] Missing file name\nError on line 30: [22000] Requested file compression format .bz2 is not supported. Use .gz instead.\nError on line 32: [22000] Requested file compression format .lz4 is not supported. Use .gz instead.\nError on line 34: [22000] Requested file compression format .xz is not supported. Use .gz instead.\nError on line 36: [22000] Requested file compression format .zip is not supported. Use .gz instead.\n": + if perr != "Error on line 12: [22000] Missing file name\nError on line 30: [22000] Specified file compression format .bz2 is not supported. Only .gz is supported.\nError on line 32: [22000] Specified file compression format .lz4 is not supported. Only .gz is supported.\nError on line 34: [22000] Specified file compression format .xz is not supported. Only .gz is supported.\nError on line 36: [22000] Specified file compression format .zip is not supported. Only .gz is supported.\n": print(perr) print("OnClientDownloadData err difference detected") if pout != "121 affected rows\n122 affected rows\n123 affected rows\n124 affected rows\n120 affected rows\n": diff --git a/sql/server/sql_scan.c b/sql/server/sql_scan.c --- a/sql/server/sql_scan.c +++ b/sql/server/sql_scan.c @@ -1218,7 +1218,7 @@ int scanner_symbol(mvc * c, int cur) cur = skip_c_comment(c); if (cur < 0) return EOF; - return tokenize(c, cur); + return ' '; } else { utf8_putchar(lc, next); return scanner_token(lc, cur); @@ -1237,7 +1237,7 @@ int scanner_symbol(mvc * c, int cur) case '#': if ((cur = skip_sql_comment(c)) == EOF) return cur; - return tokenize(c, cur); + return ' '; case '\'': if (lc->raw_string_mode || lc->next_string_is_raw) return scanner_string(c, cur, false); @@ -1263,7 +1263,7 @@ int scanner_symbol(mvc * c, int cur) lc->started = started; if ((cur = skip_sql_comment(c)) == EOF) return cur; - return tokenize(c, cur); + return ' '; } lc->started = 1; utf8_putchar(lc, next); @@ -1493,7 +1493,10 @@ tokenize(mvc * c, int cur) } return keyword_or_ident(c, cur); } else if (iswpunct(cur)) { - return scanner_symbol(c, cur); + cur = scanner_symbol(c, cur); + if (iswspace(cur)) + continue; + return cur; } if (cur == EOF) { if (lc->mode == LINE_1 || !lc->started ) diff --git a/sql/test/Tests/selective_snapshot.py b/sql/test/Tests/selective_snapshot.py --- a/sql/test/Tests/selective_snapshot.py +++ b/sql/test/Tests/selective_snapshot.py @@ -117,6 +117,7 @@ def unpack_snapshot(filename): tar.extractall(dbfarm, filter='data') +shutil.rmtree(os.path.join(dbfarm, mydb), ignore_errors=True) # Create the database and set up some test data. # Instantly create a full snapshot. # Verify that foreign key constraints are checked. _______________________________________________ checkin-list mailing list -- [email protected] To unsubscribe send an email to [email protected]
