Changeset: 0ca206e627af for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/0ca206e627af
Branch: default
Log Message:

merged


diffs (truncated from 205072 to 300 lines):

diff --git a/clients/Tests/MAL-signatures-hge.test 
b/clients/Tests/MAL-signatures-hge.test
--- a/clients/Tests/MAL-signatures-hge.test
+++ b/clients/Tests/MAL-signatures-hge.test
@@ -1,4 +1,5 @@
 hash-threshold 100000
+
 query TTTTT nosort
 select * from sys.malfunctions() order by module, "function", address, 
signature, comment
 ----
diff --git a/clients/mapiclient/dump.c b/clients/mapiclient/dump.c
--- a/clients/mapiclient/dump.c
+++ b/clients/mapiclient/dump.c
@@ -2517,6 +2517,16 @@ dump_database(Mapi mid, stream *toConsol
 {
        const char *start_trx = "START TRANSACTION";
        const char *end = "ROLLBACK";
+       const char *types =
+               "SELECT s.name, "
+                      "t.systemname, "
+                      "t.sqlname "
+               "FROM sys.types t LEFT JOIN sys.schemas s ON s.id = t.schema_id 
"
+               "WHERE t.eclass = 18 "
+                 "AND (t.schema_id <> 2000 "
+                       "OR (t.schema_id = 2000 "
+                            "AND t.sqlname NOT IN 
('geometrya','mbr','url','inet','json','uuid')))"
+               "ORDER BY s.name, t.sqlname";
        const char *users =
                has_schema_path(mid) ?
                "SELECT ui.name, "
@@ -2736,6 +2746,11 @@ dump_database(Mapi mid, stream *toConsol
        sname = get_schema(mid);
        if (sname == NULL)
                goto bailout2;
+       mnstr_printf(toConsole, "SET SCHEMA ");
+       dquoted_print(toConsole, sname, ";\n");
+       curschema = strdup(sname);
+       if (curschema == NULL)
+               goto bailout;
        if (strcmp(sname, "sys") == 0 || strcmp(sname, "tmp") == 0) {
                free(sname);
                sname = NULL;
@@ -2850,14 +2865,26 @@ dump_database(Mapi mid, stream *toConsol
                if (mapi_error(mid))
                        goto bailout;
                mapi_close_handle(hdl);
-       } else {
-               mnstr_printf(toConsole, "SET SCHEMA ");
-               dquoted_print(toConsole, sname, ";\n");
-               curschema = strdup(sname);
-               if (curschema == NULL)
-                       goto bailout;
        }
 
+       /* dump types */
+       if ((hdl = mapi_query(mid, types)) == NULL || mapi_error(mid))
+               goto bailout;
+
+       while (mapi_fetch_row(hdl) != 0) {
+               const char *sname = mapi_fetch_field(hdl, 0);
+               const char *sysname = mapi_fetch_field(hdl, 1);
+               const char *sqlname = mapi_fetch_field(hdl, 2);
+               mnstr_printf(toConsole, "CREATE TYPE ");
+               dquoted_print(toConsole, sname, ".");
+               dquoted_print(toConsole, sqlname, " EXTERNAL NAME ");
+               dquoted_print(toConsole, sysname, ";\n");
+       }
+       if (mapi_error(mid))
+               goto bailout;
+       mapi_close_handle(hdl);
+       hdl = NULL;
+
        /* dump sequences, part 1 */
        if ((hdl = mapi_query(mid, sequences1)) == NULL || mapi_error(mid))
                goto bailout;
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
@@ -4599,7 +4599,9 @@ sql_update_default(Client c, mvc *sql)
        if (buf == NULL)
                throw(SQL, __func__, SQLSTATE(HY013) MAL_MALLOC_FAIL);
 
-       /* if 'describe_partition_tables' system view doesn't use 'vals' CTE, 
re-create it */
+       /* if 'describe_partition_tables' system view doesn't use 'vals'
+        * CTE, re-create it; while we're at it, also update the sequence
+        * dumping code */
        pos += snprintf(buf + pos, bufsize - pos,
                        "select 1 from tables where schema_id = (select \"id\" 
from sys.schemas where \"name\" = 'sys') and \"name\" = 
'describe_partition_tables' and \"query\" not like '%%vals%%';\n");
        if ((err = SQLstatementIntern(c, buf, "update", true, false, &output))) 
{
@@ -4614,13 +4616,19 @@ sql_update_default(Client c, mvc *sql)
                t->system = 0;
                t = mvc_bind_table(sql, s, "dump_partition_tables");
                t->system = 0;
+               t = mvc_bind_table(sql, s, "dump_sequences");
+               t->system = 0;
+               t = mvc_bind_table(sql, s, "dump_start_sequences");
+               t->system = 0;
 
                pos = 0;
                pos += snprintf(buf + pos, bufsize - pos,
                        /* drop dependent stuff from 76_dump.sql */
                        "drop function sys.dump_database(boolean);\n"
                        "drop view sys.dump_partition_tables;\n"
-                       "drop view sys.describe_partition_tables;\n");
+                       "drop view sys.describe_partition_tables;\n"
+                       "drop view sys.dump_sequences;\n"
+                       "drop view sys.dump_start_sequences;\n");
 
                pos += snprintf(buf + pos, bufsize - pos,
                        "CREATE VIEW sys.describe_partition_tables AS\n"
@@ -4697,6 +4705,23 @@ sql_update_default(Client c, mvc *sql)
                        "       p_sch partition_schema_name,\n"
                        "       p_tbl partition_table_name\n"
                        "       FROM sys.describe_partition_tables;\n"
+                       "CREATE VIEW sys.dump_sequences AS\n"
+                       "  SELECT\n"
+                       "    'CREATE SEQUENCE ' || sys.FQN(sch, seq) || ' AS 
BIGINT;' stmt,\n"
+                       "    sch schema_name,\n"
+                       "    seq seqname\n"
+                       "    FROM sys.describe_sequences;\n"
+                       "CREATE VIEW sys.dump_start_sequences AS\n"
+                       "  SELECT 'ALTER SEQUENCE ' || sys.FQN(sch, seq) ||\n"
+                       "          CASE WHEN s = 0 THEN '' ELSE ' RESTART WITH 
' || rs END ||\n"
+                       "          CASE WHEN inc = 1 THEN '' ELSE ' INCREMENT 
BY ' || inc END ||\n"
+                       "          CASE WHEN nomin THEN ' NO MINVALUE' WHEN rmi 
IS NULL THEN '' ELSE ' MINVALUE ' || rmi END ||\n"
+                       "          CASE WHEN nomax THEN ' NO MAXVALUE' WHEN rma 
IS NULL THEN '' ELSE ' MAXVALUE ' || rma END ||\n"
+                       "          CASE WHEN \"cache\" = 1 THEN '' ELSE ' CACHE 
' || \"cache\" END ||\n"
+                       "          CASE WHEN \"cycle\" THEN '' ELSE ' NO' END 
|| ' CYCLE;' stmt,\n"
+                       "    sch schema_name,\n"
+                       "    seq sequence_name\n"
+                       "    FROM sys.describe_sequences;\n"
                        "CREATE FUNCTION sys.dump_database(describe BOOLEAN) 
RETURNS TABLE(o int, stmt STRING)\n"
                        "BEGIN\n"
                        "\n"
@@ -4748,7 +4773,7 @@ sql_update_default(Client c, mvc *sql)
                        "END;\n");
 
                pos += snprintf(buf + pos, bufsize - pos,
-                       "update sys._tables set system = true where name in 
('describe_partition_tables', 'dump_partition_tables') AND schema_id = 
2000;\n");
+                       "update sys._tables set system = true where name in 
('describe_partition_tables', 'dump_partition_tables', 'dump_sequences', 
'dump_start_sequences') AND schema_id = 2000;\n");
                pos += snprintf(buf + pos, bufsize - pos,
                        "update sys.functions set system = true where system <> 
true and name in ('dump_database') and schema_id = 2000 and type = %d;\n", 
F_UNION);
 
diff --git a/sql/scripts/76_dump.sql b/sql/scripts/76_dump.sql
--- a/sql/scripts/76_dump.sql
+++ b/sql/scripts/76_dump.sql
@@ -181,31 +181,19 @@ CREATE VIEW sys.dump_partition_tables AS
 
 CREATE VIEW sys.dump_sequences AS
   SELECT
-    'CREATE SEQUENCE ' || sys.FQN(sch, seq) || ' AS BIGINT ' ||
-    CASE WHEN "s" <> 0 THEN 'START WITH ' || "rs" ELSE '' END ||
-    CASE WHEN "inc" <> 1 THEN ' INCREMENT BY ' || "inc" ELSE '' END ||
-    CASE
-      WHEN nomin THEN ' NO MINVALUE'
-      WHEN rmi IS NOT NULL THEN ' MINVALUE ' || rmi
-      ELSE ''
-    END ||
-    CASE
-      WHEN nomax THEN ' NO MAXVALUE'
-      WHEN rma IS NOT NULL THEN ' MAXVALUE ' || rma
-      ELSE ''
-    END ||
-    CASE WHEN "cache" <> 1 THEN ' CACHE ' || "cache" ELSE '' END ||
-    CASE WHEN "cycle" THEN ' CYCLE' ELSE '' END ||
-    ';' stmt,
+    'CREATE SEQUENCE ' || sys.FQN(sch, seq) || ' AS BIGINT;' stmt,
     sch schema_name,
     seq seqname
     FROM sys.describe_sequences;
 
 CREATE VIEW sys.dump_start_sequences AS
-  SELECT
-    'UPDATE sys.sequences seq SET start = ' || s ||
-      ' WHERE name = ' || sys.SQ(seq) ||
-      ' AND schema_id = (SELECT s.id FROM sys.schemas s WHERE s.name = ' || 
sys.SQ(sch) || ');' stmt,
+  SELECT 'ALTER SEQUENCE ' || sys.FQN(sch, seq) ||
+          CASE WHEN s = 0 THEN '' ELSE ' RESTART WITH ' || rs END ||
+          CASE WHEN inc = 1 THEN '' ELSE ' INCREMENT BY ' || inc END ||
+          CASE WHEN nomin THEN ' NO MINVALUE' WHEN rmi IS NULL THEN '' ELSE ' 
MINVALUE ' || rmi END ||
+          CASE WHEN nomax THEN ' NO MAXVALUE' WHEN rma IS NULL THEN '' ELSE ' 
MAXVALUE ' || rma END ||
+          CASE WHEN "cache" = 1 THEN '' ELSE ' CACHE ' || "cache" END ||
+          CASE WHEN "cycle" THEN '' ELSE ' NO' END || ' CYCLE;' stmt,
     sch schema_name,
     seq sequence_name
     FROM sys.describe_sequences;
diff --git a/sql/test/Dependencies/Tests/dependency_owner_schema_3.test 
b/sql/test/Dependencies/Tests/dependency_owner_schema_3.test
--- a/sql/test/Dependencies/Tests/dependency_owner_schema_3.test
+++ b/sql/test/Dependencies/Tests/dependency_owner_schema_3.test
@@ -126,7 +126,7 @@ DEP_FUNC
 query TTT rowsort
 SELECT c.name, v.name, 'DEP_VIEW' from sys.columns as c, sys.tables as v, 
sys.dependencies as dep where c.id = dep.id AND v.id = dep.depend_id AND 
dep.depend_type = 5 AND v.type in (1, 11, 21, 31) order by c.name, v.name
 ----
-2277 values hashing to be0394cfd4bbe2f3fb9af9fb43087e76
+2274 values hashing to f4b96600fba0faf630ad83449eaa46b0
 
 query TTT rowsort
 SELECT c.name, k.name, 'DEP_KEY' from sys.columns as c,  sys.objects as kc, 
sys.keys as k where kc."name" = c.name AND kc.id = k.id AND k.table_id = 
c.table_id AND k.rkey = -1 order by c.name, k.name
diff --git a/sql/test/Dump/Tests/dump-again.stable.out 
b/sql/test/Dump/Tests/dump-again.stable.out
--- a/sql/test/Dump/Tests/dump-again.stable.out
+++ b/sql/test/Dump/Tests/dump-again.stable.out
@@ -1,6 +1,6 @@
 START TRANSACTION;
+SET SCHEMA "sys";
 CREATE SEQUENCE "sys"."test_seq" AS INTEGER;
-SET SCHEMA "sys";
 CREATE TABLE "sys"."test" (
        "id" INTEGER,
        "i"  SMALLINT
diff --git a/sql/test/Dump/Tests/dump.stable.out 
b/sql/test/Dump/Tests/dump.stable.out
--- a/sql/test/Dump/Tests/dump.stable.out
+++ b/sql/test/Dump/Tests/dump.stable.out
@@ -1,6 +1,6 @@
 START TRANSACTION;
+SET SCHEMA "sys";
 CREATE SEQUENCE "sys"."test_seq" AS INTEGER;
-SET SCHEMA "sys";
 CREATE TABLE "sys"."test" (
        "id" INTEGER,
        "i"  SMALLINT
diff --git a/sql/test/Tests/comment-dump.test b/sql/test/Tests/comment-dump.test
--- a/sql/test/Tests/comment-dump.test
+++ b/sql/test/Tests/comment-dump.test
@@ -73,7 +73,7 @@ select stmt from sys.dump_database(false
 START TRANSACTION;
 SET SCHEMA "sys";
 CREATE SCHEMA "foo" AUTHORIZATION "monetdb";
-CREATE SEQUENCE "foo"."counter" AS BIGINT START WITH 1;
+CREATE SEQUENCE "foo"."counter" AS BIGINT;
 CREATE TABLE "foo"."tab" ("i" INTEGER, "j" DECIMAL(4,2));
 create view "foo"."vivi" as select * from tab@;
 create "foo"."f" unction "foo"."f" () returns int begin return 42; end@;
@@ -82,7 +82,7 @@ create "foo"."f" unction "foo"."f" (i in
 create "foo"."f" unction "foo"."f" (i int, j int, k int) returns int begin 
return 45; end@;
 create "foo"."f" unction "foo"."f" (i int, j int, k int, l int) returns int 
begin return 45; end@;
 create procedure "foo"."g" () be "foo"."g" in delete from tab where false; 
end@;
-UPDATE sys.sequences seq SET start = 1 WHERE name = 'counter' AND schema_id = 
(SELECT s.id FROM sys.schemas s WHERE s.name = 'foo');
+ALTER SEQUENCE "foo"."counter" RESTART WITH 1 NO CYCLE;
 CREATE INDEX "idx" ON "foo"."tab"(j,i);
 COMMENT ON COLUMN "foo"."tab"."i" IS 'ii';
 COMMENT ON COLUMN "foo"."tab"."j" IS 'jj';
diff --git a/sql/test/UserDump/Tests/dump.stable.out 
b/sql/test/UserDump/Tests/dump.stable.out
--- a/sql/test/UserDump/Tests/dump.stable.out
+++ b/sql/test/UserDump/Tests/dump.stable.out
@@ -1,4 +1,5 @@
 START TRANSACTION;
+SET SCHEMA "sys";
 CREATE USER "test" WITH ENCRYPTED PASSWORD 
'ee26b0dd4af7e749aa1a8ee3c10ae9923f618980772e473f8819a5d4940e0db27ac185f8a0e1d5f84f88bc887fd67b143732c304cc5fa9ad8e6f57f50028a8ff'
 NAME 'Test User' SCHEMA "sys";
 CREATE USER "voc" WITH ENCRYPTED PASSWORD 
'ea45cf4e124b215a28631ec7ff0bf06e82fc26b2be7a066c9594855690fb5d42438be58d6523132384a1738cb4e5139caa1f970ebdfb422d65834d9a4ef61c0e'
 NAME 'VOC Explorer' SCHEMA "sys";
 CREATE SCHEMA "test" AUTHORIZATION "test";
diff --git a/sql/test/emptydb-previous-upgrade-chain-hge/Tests/upgrade.py 
b/sql/test/emptydb-previous-upgrade-chain-hge/Tests/upgrade.py
--- a/sql/test/emptydb-previous-upgrade-chain-hge/Tests/upgrade.py
+++ b/sql/test/emptydb-previous-upgrade-chain-hge/Tests/upgrade.py
@@ -72,7 +72,7 @@ if len(sys.argv) == 2 and sys.argv[1] ==
     for line in difflib.unified_diff(stable, srvout, fromfile='test', 
tofile=f):
         sys.stderr.write(line)
         xit = 1
-    if len(cltout) != 2 or cltout[0] != 'START TRANSACTION;' or cltout[1] != 
'COMMIT;':
+    if len(cltout) != 3 or cltout[0] != 'START TRANSACTION;' or cltout[1] != 
'SET SCHEMA "sys";' or cltout[2] != 'COMMIT;':
         sys.stderr.write('\n'.join(cltout))
         xit = 1
 else:
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
@@ -249,3735 +249,3747 @@ insert into sys.args values (44964, 86, 
 insert into sys.functions values (87, 'anyequal', 'anyequal', 'aggr', 0, 3, 
false, false, false, 2000, true, true);
 insert into sys.args values (44965, 87, 'res_0', 'boolean', 1, 0, 0, 0);
 insert into sys.args values (44966, 87, 'arg_1', 'any', 0, 0, 1, 1);
-insert into sys.functions values (88, 'allnotequal', 'allnotequal', 'aggr', 0, 
3, false, false, false, 2000, true, true);
-insert into sys.args values (44967, 88, 'res_0', 'boolean', 1, 0, 0, 0);
-insert into sys.args values (44968, 88, 'arg_1', 'any', 0, 0, 1, 1);
-insert into sys.functions values (89, 'sql_anyequal', 'anyequal', 'aggr', 0, 
1, false, false, false, 2000, true, true);
-insert into sys.args values (44969, 89, 'res_0', 'boolean', 1, 0, 0, 0);
-insert into sys.args values (44970, 89, 'arg_1', 'any', 0, 0, 1, 1);
-insert into sys.args values (44971, 89, 'arg_2', 'any', 0, 0, 1, 2);
-insert into sys.functions values (90, 'sql_not_anyequal', 'not_anyequal', 
'aggr', 0, 1, false, false, false, 2000, true, true);
-insert into sys.args values (44972, 90, 'res_0', 'boolean', 1, 0, 0, 0);
-insert into sys.args values (44973, 90, 'arg_1', 'any', 0, 0, 1, 1);
-insert into sys.args values (44974, 90, 'arg_2', 'any', 0, 0, 1, 2);
-insert into sys.functions values (91, 'exist', 'exist', 'aggr', 0, 3, false, 
false, false, 2000, true, true);
-insert into sys.args values (44975, 91, 'res_0', 'boolean', 1, 0, 0, 0);
-insert into sys.args values (44976, 91, 'arg_1', 'any', 0, 0, 1, 1);
-insert into sys.functions values (92, 'not_exist', 'not_exist', 'aggr', 0, 3, 
false, false, false, 2000, true, true);
-insert into sys.args values (44977, 92, 'res_0', 'boolean', 1, 0, 0, 0);
-insert into sys.args values (44978, 92, 'arg_1', 'any', 0, 0, 1, 1);
-insert into sys.functions values (93, 'sql_exists', 'exist', 'aggr', 0, 1, 
false, false, false, 2000, true, true);
-insert into sys.args values (44979, 93, 'res_0', 'boolean', 1, 0, 0, 0);
-insert into sys.args values (44980, 93, 'arg_1', 'any', 0, 0, 1, 1);
-insert into sys.functions values (94, 'sql_not_exists', 'not_exist', 'aggr', 
0, 1, false, false, false, 2000, true, true);
-insert into sys.args values (44981, 94, 'res_0', 'boolean', 1, 0, 0, 0);
-insert into sys.args values (44982, 94, 'arg_1', 'any', 0, 0, 1, 1);
-insert into sys.functions values (95, 'identity', 'identity', 'calc', 0, 1, 
false, false, false, 2000, true, true);
-insert into sys.args values (44983, 95, 'res_0', 'oid', 63, 0, 0, 0);
-insert into sys.args values (44984, 95, 'arg_1', 'any', 0, 0, 1, 1);
-insert into sys.functions values (96, 'rowid', 'identity', 'calc', 0, 1, 
false, false, false, 2000, true, true);
-insert into sys.args values (44985, 96, 'res_0', 'int', 32, 0, 0, 0);
-insert into sys.args values (44986, 96, 'arg_1', 'any', 0, 0, 1, 1);
-insert into sys.functions values (97, 'rowid', 'rowid', 'calc', 0, 1, false, 
false, false, 2000, true, true);
-insert into sys.args values (44987, 97, 'res_0', 'oid', 63, 0, 0, 0);
-insert into sys.args values (44988, 97, 'arg_1', 'any', 0, 0, 1, 1);
_______________________________________________
checkin-list mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to