Changeset: 23904801fe79 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/23904801fe79 Modified Files: sql/backends/monet5/sql.h sql/backends/monet5/sql_upgrades.c sql/test/emptydb-previous-upgrade-chain-hge/Tests/upgrade.stable.out.int128 sql/test/emptydb-previous-upgrade-chain/Tests/upgrade.stable.out sql/test/emptydb-previous-upgrade-chain/Tests/upgrade.stable.out.int128 sql/test/emptydb-previous-upgrade-hge/Tests/upgrade.stable.out.int128 sql/test/emptydb-previous-upgrade/Tests/upgrade.stable.out sql/test/emptydb-previous-upgrade/Tests/upgrade.stable.out.int128 sql/test/emptydb-upgrade-chain-hge/Tests/upgrade.stable.out.int128 sql/test/emptydb-upgrade-chain/Tests/upgrade.stable.out sql/test/emptydb-upgrade-chain/Tests/upgrade.stable.out.int128 sql/test/emptydb-upgrade-chain/Tests/upgrade.stable.out.ppc64.int128 sql/test/emptydb-upgrade-hge/Tests/upgrade.stable.out.int128 sql/test/emptydb-upgrade/Tests/upgrade.stable.out sql/test/emptydb-upgrade/Tests/upgrade.stable.out.int128 sql/test/emptydb/Tests/check.stable.out sql/test/emptydb/Tests/check.stable.out.32bit sql/test/emptydb/Tests/check.stable.out.int128 sql/test/testdb-previous-upgrade-chain-hge/Tests/upgrade.stable.out.int128 sql/test/testdb-previous-upgrade-chain/Tests/upgrade.stable.out sql/test/testdb-previous-upgrade-chain/Tests/upgrade.stable.out.int128 sql/test/testdb-previous-upgrade-hge/Tests/upgrade.stable.out.int128 sql/test/testdb-previous-upgrade/Tests/upgrade.stable.out sql/test/testdb-previous-upgrade/Tests/upgrade.stable.out.int128 sql/test/testdb-upgrade-chain-hge/Tests/upgrade.stable.out.int128 sql/test/testdb-upgrade-chain/Tests/upgrade.stable.out sql/test/testdb-upgrade-chain/Tests/upgrade.stable.out.int128 sql/test/testdb-upgrade-hge/Tests/upgrade.stable.out.int128 sql/test/testdb-upgrade/Tests/upgrade.stable.out sql/test/testdb-upgrade/Tests/upgrade.stable.out.int128 Branch: default Log Message:
Merge with Jun2023 branch. diffs (truncated from 764 to 300 lines): diff --git a/monetdb5/modules/atoms/Tests/All b/monetdb5/modules/atoms/Tests/All --- a/monetdb5/modules/atoms/Tests/All +++ b/monetdb5/modules/atoms/Tests/All @@ -38,3 +38,5 @@ startswith endswith contains HAVE_ICONV?asciify + +ts_and_tstz_to_str_bug diff --git a/monetdb5/modules/atoms/Tests/ts_and_tstz_to_str_bug.test b/monetdb5/modules/atoms/Tests/ts_and_tstz_to_str_bug.test new file mode 100644 --- /dev/null +++ b/monetdb5/modules/atoms/Tests/ts_and_tstz_to_str_bug.test @@ -0,0 +1,16 @@ +statement ok +CREATE TABLE t2 (dt TIMESTAMP) + +statement ok +INSERT INTO t2 (dt) VALUES('2023-10-11 11:36') + +query I +SELECT + levenshtein(sys.timestamp_to_str(cast(dt as timestamp with time zone), '%Y-%d-%d %H:%M:%S'), + sys.timestamp_to_str(dt, '%Y-%d-%d %H:%M:%S')) +FROM t2 +---- +0 + +statement ok +DROP TABLE t2 diff --git a/sql/backends/monet5/sql.h b/sql/backends/monet5/sql.h --- a/sql/backends/monet5/sql.h +++ b/sql/backends/monet5/sql.h @@ -282,7 +282,6 @@ extern str SQLflush_log(Client cntxt, Ma extern str SQLsuspend_log_flushing(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci); extern str SQLresume_log_flushing(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci); extern str SQLhot_snapshot(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci); -extern str SQLhot_snapshot_wrap(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci); extern str SQLpersist_unlogged(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci); extern str SQLsession_prepared_statements(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci); diff --git a/sql/backends/monet5/sql_upgrades.c b/sql/backends/monet5/sql_upgrades.c --- a/sql/backends/monet5/sql_upgrades.c +++ b/sql/backends/monet5/sql_upgrades.c @@ -5179,6 +5179,7 @@ sql_update_jun2023(Client c, mvc *sql, s char *err = NULL, *buf = GDKmalloc(bufsize); res_table *output; BAT *b; + sql_subtype t1, t2; (void) sql; if (buf == NULL) @@ -5546,7 +5547,6 @@ sql_update_jun2023(Client c, mvc *sql, s /* Add new sysadmin procedure calls: stop, pause and resume with two arguments, first arg is query OID and second the user username that the query in bound to. */ - sql_subtype t1, t2; sql_find_subtype(&t1, "bigint", 64, 0); sql_find_subtype(&t2, "varchar", 0, 0); if (!sql_bind_func(sql, "sys", "pause", &t1, &t2, F_PROC, true)) { @@ -5781,6 +5781,38 @@ sql_update_jun2023(Client c, mvc *sql, s } static str +sql_update_jun2023_sp3(Client c, mvc *sql, sql_schema *s) +{ + (void)s; + char *err = NULL; + sql_subtype t1, t2; + + sql_find_subtype(&t1, "timestamp", 0, 0); + sql_find_subtype(&t2, "varchar", 0, 0); + + if (!sql_bind_func(sql, "sys", "timestamp_to_str", &t1, &t2, F_FUNC, true)) { + sql->session->status = 0; + sql->errstr[0] = '\0'; + + char *query = GDKmalloc(512); + if (query == NULL) + throw(SQL, __func__, SQLSTATE(HY013) MAL_MALLOC_FAIL); + + snprintf(query, 512, "CREATE FUNCTION timestamp_to_str(d TIMESTAMP, format STRING) RETURNS STRING " + "EXTERNAL NAME mtime.\"timestamp_to_str\";\n" + "GRANT EXECUTE ON FUNCTION timestamp_to_str(TIMESTAMP, STRING) TO PUBLIC;\n" + "UPDATE sys.functions SET system = true WHERE system <> true AND name = 'timestamp_to_str' " + "AND schema_id = 2000 and type = %d;\n", F_FUNC); + + printf("Running database upgrade commands:\n%s\n", query); + err = SQLstatementIntern(c, query, "update", true, false, NULL); + GDKfree(query); + } + + return err; /* usually MAL_SUCCEED */ +} + +static str sql_update_default_geom(Client c, mvc *sql, sql_schema *s) { sql_subtype tp; @@ -6278,10 +6310,10 @@ sql_update_default(Client c, mvc *sql, s "EXTERNAL NAME sql.persist_unlogged;\n" "CREATE FUNCTION sys.persist_unlogged(sname STRING)\n" "RETURNS TABLE(\"table\" STRING, \"table_id\" INT, \"rowcount\" BIGINT)\n" - "EXTERNAL NAME sql.persist_unlogged(string);\n" + "EXTERNAL NAME sql.persist_unlogged;\n" "CREATE FUNCTION sys.persist_unlogged(sname STRING, tname STRING)\n" "RETURNS TABLE(\"table\" STRING, \"table_id\" INT, \"rowcount\" BIGINT)\n" - "EXTERNAL NAME sql.persist_unlogged(string, string);\n" + "EXTERNAL NAME sql.persist_unlogged;\n" "GRANT EXECUTE ON FUNCTION sys.persist_unlogged() TO PUBLIC;\n" "UPDATE sys.functions SET system = true WHERE system <> true AND\n" "name = 'persist_unlogged' AND schema_id = 2000;\n"; @@ -6476,6 +6508,12 @@ SQLupgrades(Client c, mvc *m) goto handle_error; } + if ((err = sql_update_jun2023_sp3(c, m, s)) != NULL) { + TRC_CRITICAL(SQL_PARSER, "%s\n", err); + freeException(err); + return -1; + } + return 0; handle_error: diff --git a/sql/scripts/13_date.sql b/sql/scripts/13_date.sql --- a/sql/scripts/13_date.sql +++ b/sql/scripts/13_date.sql @@ -21,6 +21,9 @@ create function time_to_str(d time with create function str_to_timestamp(s string, format string) returns timestamp with time zone external name mtime."str_to_timestamp"; +create function timestamp_to_str(d timestamp, format string) returns string + external name mtime."timestamp_to_str"; + create function timestamp_to_str(d timestamp with time zone, format string) returns string external name mtime."timestamp_to_str"; @@ -29,4 +32,5 @@ grant execute on function date_to_str to grant execute on function str_to_time to public; grant execute on function time_to_str to public; grant execute on function str_to_timestamp to public; -grant execute on function timestamp_to_str to public; +grant execute on function timestamp_to_str(timestamp, string) to public; +grant execute on function timestamp_to_str(timestamp with time zone, string) to public; diff --git a/sql/test/BugTracker-2019/Tests/duplicates-not-eliminated-long-CASE-stmt.Bug-6697.test b/sql/test/BugTracker-2019/Tests/duplicates-not-eliminated-long-CASE-stmt.Bug-6697.test --- a/sql/test/BugTracker-2019/Tests/duplicates-not-eliminated-long-CASE-stmt.Bug-6697.test +++ b/sql/test/BugTracker-2019/Tests/duplicates-not-eliminated-long-CASE-stmt.Bug-6697.test @@ -105,7 +105,7 @@ 1 query I rowsort select count(*) from sys.tracelog() where stmt like '%batcalc.timestamp%' ---- -1 +0 query T rowsort SELECT sys.timestamp_to_str(case when task0."sys_created_on" >= '1999-10-31 09:00:00' and task0."sys_created_on" < '2000-04-02 10:00:00' diff --git a/sql/test/emptydb-previous-upgrade-chain-hge/Tests/upgrade.stable.out.int128 b/sql/test/emptydb-previous-upgrade-chain-hge/Tests/upgrade.stable.out.int128 --- a/sql/test/emptydb-previous-upgrade-chain-hge/Tests/upgrade.stable.out.int128 +++ b/sql/test/emptydb-previous-upgrade-chain-hge/Tests/upgrade.stable.out.int128 @@ -748,11 +748,16 @@ RETURNS TABLE("table" STRING, "table_id" EXTERNAL NAME sql.persist_unlogged; CREATE FUNCTION sys.persist_unlogged(sname STRING) RETURNS TABLE("table" STRING, "table_id" INT, "rowcount" BIGINT) -EXTERNAL NAME sql.persist_unlogged(string); +EXTERNAL NAME sql.persist_unlogged; CREATE FUNCTION sys.persist_unlogged(sname STRING, tname STRING) RETURNS TABLE("table" STRING, "table_id" INT, "rowcount" BIGINT) -EXTERNAL NAME sql.persist_unlogged(string, string); +EXTERNAL NAME sql.persist_unlogged; GRANT EXECUTE ON FUNCTION sys.persist_unlogged() TO PUBLIC; UPDATE sys.functions SET system = true WHERE system <> true AND name = 'persist_unlogged' AND schema_id = 2000; +Running database upgrade commands: +CREATE FUNCTION timestamp_to_str(d TIMESTAMP, format STRING) RETURNS STRING EXTERNAL NAME mtime."timestamp_to_str"; +GRANT EXECUTE ON FUNCTION timestamp_to_str(TIMESTAMP, STRING) TO PUBLIC; +UPDATE sys.functions SET system = true WHERE system <> true AND name = 'timestamp_to_str' AND schema_id = 2000 and type = 1; + diff --git a/sql/test/emptydb-previous-upgrade-chain/Tests/upgrade.stable.out b/sql/test/emptydb-previous-upgrade-chain/Tests/upgrade.stable.out --- a/sql/test/emptydb-previous-upgrade-chain/Tests/upgrade.stable.out +++ b/sql/test/emptydb-previous-upgrade-chain/Tests/upgrade.stable.out @@ -748,11 +748,16 @@ RETURNS TABLE("table" STRING, "table_id" EXTERNAL NAME sql.persist_unlogged; CREATE FUNCTION sys.persist_unlogged(sname STRING) RETURNS TABLE("table" STRING, "table_id" INT, "rowcount" BIGINT) -EXTERNAL NAME sql.persist_unlogged(string); +EXTERNAL NAME sql.persist_unlogged; CREATE FUNCTION sys.persist_unlogged(sname STRING, tname STRING) RETURNS TABLE("table" STRING, "table_id" INT, "rowcount" BIGINT) -EXTERNAL NAME sql.persist_unlogged(string, string); +EXTERNAL NAME sql.persist_unlogged; GRANT EXECUTE ON FUNCTION sys.persist_unlogged() TO PUBLIC; UPDATE sys.functions SET system = true WHERE system <> true AND name = 'persist_unlogged' AND schema_id = 2000; +Running database upgrade commands: +CREATE FUNCTION timestamp_to_str(d TIMESTAMP, format STRING) RETURNS STRING EXTERNAL NAME mtime."timestamp_to_str"; +GRANT EXECUTE ON FUNCTION timestamp_to_str(TIMESTAMP, STRING) TO PUBLIC; +UPDATE sys.functions SET system = true WHERE system <> true AND name = 'timestamp_to_str' AND schema_id = 2000 and type = 1; + diff --git a/sql/test/emptydb-previous-upgrade-chain/Tests/upgrade.stable.out.int128 b/sql/test/emptydb-previous-upgrade-chain/Tests/upgrade.stable.out.int128 --- a/sql/test/emptydb-previous-upgrade-chain/Tests/upgrade.stable.out.int128 +++ b/sql/test/emptydb-previous-upgrade-chain/Tests/upgrade.stable.out.int128 @@ -817,11 +817,16 @@ RETURNS TABLE("table" STRING, "table_id" EXTERNAL NAME sql.persist_unlogged; CREATE FUNCTION sys.persist_unlogged(sname STRING) RETURNS TABLE("table" STRING, "table_id" INT, "rowcount" BIGINT) -EXTERNAL NAME sql.persist_unlogged(string); +EXTERNAL NAME sql.persist_unlogged; CREATE FUNCTION sys.persist_unlogged(sname STRING, tname STRING) RETURNS TABLE("table" STRING, "table_id" INT, "rowcount" BIGINT) -EXTERNAL NAME sql.persist_unlogged(string, string); +EXTERNAL NAME sql.persist_unlogged; GRANT EXECUTE ON FUNCTION sys.persist_unlogged() TO PUBLIC; UPDATE sys.functions SET system = true WHERE system <> true AND name = 'persist_unlogged' AND schema_id = 2000; +Running database upgrade commands: +CREATE FUNCTION timestamp_to_str(d TIMESTAMP, format STRING) RETURNS STRING EXTERNAL NAME mtime."timestamp_to_str"; +GRANT EXECUTE ON FUNCTION timestamp_to_str(TIMESTAMP, STRING) TO PUBLIC; +UPDATE sys.functions SET system = true WHERE system <> true AND name = 'timestamp_to_str' AND schema_id = 2000 and type = 1; + diff --git a/sql/test/emptydb-previous-upgrade-hge/Tests/upgrade.stable.out.int128 b/sql/test/emptydb-previous-upgrade-hge/Tests/upgrade.stable.out.int128 --- a/sql/test/emptydb-previous-upgrade-hge/Tests/upgrade.stable.out.int128 +++ b/sql/test/emptydb-previous-upgrade-hge/Tests/upgrade.stable.out.int128 @@ -748,11 +748,16 @@ RETURNS TABLE("table" STRING, "table_id" EXTERNAL NAME sql.persist_unlogged; CREATE FUNCTION sys.persist_unlogged(sname STRING) RETURNS TABLE("table" STRING, "table_id" INT, "rowcount" BIGINT) -EXTERNAL NAME sql.persist_unlogged(string); +EXTERNAL NAME sql.persist_unlogged; CREATE FUNCTION sys.persist_unlogged(sname STRING, tname STRING) RETURNS TABLE("table" STRING, "table_id" INT, "rowcount" BIGINT) -EXTERNAL NAME sql.persist_unlogged(string, string); +EXTERNAL NAME sql.persist_unlogged; GRANT EXECUTE ON FUNCTION sys.persist_unlogged() TO PUBLIC; UPDATE sys.functions SET system = true WHERE system <> true AND name = 'persist_unlogged' AND schema_id = 2000; +Running database upgrade commands: +CREATE FUNCTION timestamp_to_str(d TIMESTAMP, format STRING) RETURNS STRING EXTERNAL NAME mtime."timestamp_to_str"; +GRANT EXECUTE ON FUNCTION timestamp_to_str(TIMESTAMP, STRING) TO PUBLIC; +UPDATE sys.functions SET system = true WHERE system <> true AND name = 'timestamp_to_str' AND schema_id = 2000 and type = 1; + diff --git a/sql/test/emptydb-previous-upgrade/Tests/upgrade.stable.out b/sql/test/emptydb-previous-upgrade/Tests/upgrade.stable.out --- a/sql/test/emptydb-previous-upgrade/Tests/upgrade.stable.out +++ b/sql/test/emptydb-previous-upgrade/Tests/upgrade.stable.out @@ -748,11 +748,16 @@ RETURNS TABLE("table" STRING, "table_id" EXTERNAL NAME sql.persist_unlogged; CREATE FUNCTION sys.persist_unlogged(sname STRING) RETURNS TABLE("table" STRING, "table_id" INT, "rowcount" BIGINT) -EXTERNAL NAME sql.persist_unlogged(string); +EXTERNAL NAME sql.persist_unlogged; CREATE FUNCTION sys.persist_unlogged(sname STRING, tname STRING) RETURNS TABLE("table" STRING, "table_id" INT, "rowcount" BIGINT) -EXTERNAL NAME sql.persist_unlogged(string, string); +EXTERNAL NAME sql.persist_unlogged; GRANT EXECUTE ON FUNCTION sys.persist_unlogged() TO PUBLIC; UPDATE sys.functions SET system = true WHERE system <> true AND name = 'persist_unlogged' AND schema_id = 2000; +Running database upgrade commands: +CREATE FUNCTION timestamp_to_str(d TIMESTAMP, format STRING) RETURNS STRING EXTERNAL NAME mtime."timestamp_to_str"; +GRANT EXECUTE ON FUNCTION timestamp_to_str(TIMESTAMP, STRING) TO PUBLIC; +UPDATE sys.functions SET system = true WHERE system <> true AND name = 'timestamp_to_str' AND schema_id = 2000 and type = 1; + diff --git a/sql/test/emptydb-previous-upgrade/Tests/upgrade.stable.out.int128 b/sql/test/emptydb-previous-upgrade/Tests/upgrade.stable.out.int128 --- a/sql/test/emptydb-previous-upgrade/Tests/upgrade.stable.out.int128 +++ b/sql/test/emptydb-previous-upgrade/Tests/upgrade.stable.out.int128 @@ -817,11 +817,16 @@ RETURNS TABLE("table" STRING, "table_id" EXTERNAL NAME sql.persist_unlogged; CREATE FUNCTION sys.persist_unlogged(sname STRING) RETURNS TABLE("table" STRING, "table_id" INT, "rowcount" BIGINT) -EXTERNAL NAME sql.persist_unlogged(string); +EXTERNAL NAME sql.persist_unlogged; CREATE FUNCTION sys.persist_unlogged(sname STRING, tname STRING) RETURNS TABLE("table" STRING, "table_id" INT, "rowcount" BIGINT) -EXTERNAL NAME sql.persist_unlogged(string, string); +EXTERNAL NAME sql.persist_unlogged; GRANT EXECUTE ON FUNCTION sys.persist_unlogged() TO PUBLIC; UPDATE sys.functions SET system = true WHERE system <> true AND name = 'persist_unlogged' AND schema_id = 2000; +Running database upgrade commands: +CREATE FUNCTION timestamp_to_str(d TIMESTAMP, format STRING) RETURNS STRING EXTERNAL NAME mtime."timestamp_to_str"; +GRANT EXECUTE ON FUNCTION timestamp_to_str(TIMESTAMP, STRING) TO PUBLIC; +UPDATE sys.functions SET system = true WHERE system <> true AND name = 'timestamp_to_str' AND schema_id = 2000 and type = 1; + diff --git a/sql/test/emptydb-upgrade-chain-hge/Tests/upgrade.stable.out.int128 b/sql/test/emptydb-upgrade-chain-hge/Tests/upgrade.stable.out.int128 --- a/sql/test/emptydb-upgrade-chain-hge/Tests/upgrade.stable.out.int128 +++ b/sql/test/emptydb-upgrade-chain-hge/Tests/upgrade.stable.out.int128 @@ -388,11 +388,16 @@ RETURNS TABLE("table" STRING, "table_id" EXTERNAL NAME sql.persist_unlogged; CREATE FUNCTION sys.persist_unlogged(sname STRING) RETURNS TABLE("table" STRING, "table_id" INT, "rowcount" BIGINT) -EXTERNAL NAME sql.persist_unlogged(string); +EXTERNAL NAME sql.persist_unlogged; CREATE FUNCTION sys.persist_unlogged(sname STRING, tname STRING) RETURNS TABLE("table" STRING, "table_id" INT, "rowcount" BIGINT) _______________________________________________ checkin-list mailing list -- checkin-list@monetdb.org To unsubscribe send an email to checkin-list-le...@monetdb.org