Changeset: 32f5ae566d8a for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=32f5ae566d8a Added Files: sql/test/emptydb-upgrade-chain-hge/Tests/upgrade.reqtests sql/test/emptydb-upgrade-chain/Tests/upgrade.reqtests sql/test/emptydb-upgrade-hge/Tests/upgrade.reqtests sql/test/emptydb-upgrade/Tests/upgrade.reqtests Removed Files: sql/test/emptydb-upgrade-chain-hge/Tests/upgrade.stable.out.powerpc64 Modified Files: clients/mapiclient/dump.c sql/backends/monet5/sql_upgrades.c sql/scripts/21_dependency_functions.sql sql/server/sql_mvc.c 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.32bit sql/test/emptydb-upgrade-chain/Tests/upgrade.stable.out.int128 sql/test/emptydb-upgrade-chain/Tests/upgrade.stable.out.powerpc64.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.32bit 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-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.32bit 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.32bit sql/test/testdb-upgrade/Tests/upgrade.stable.out.int128 testing/Mtest.py.in Branch: default Log Message:
Merge with Mar2018 branch. diffs (truncated from 969 to 300 lines): diff --git a/clients/mapiclient/dump.c b/clients/mapiclient/dump.c --- a/clients/mapiclient/dump.c +++ b/clients/mapiclient/dump.c @@ -2416,13 +2416,13 @@ get_with_comments_as_clause(Mapi mid) ", function_types AS (\n" " SELECT function_type_id, function_type_name, function_type_keyword\n" " FROM sys.function_types, (VALUES\n" - " (1, \'FUNCTION\'), \n" - " (2, \'PROCEDURE\'),\n" - " (3, \'AGGREGATE\'),\n" - " (4, \'FILTER FUNCTION\'),\n" - " (5, \'FUNCTION\'), \n" - " (6, \'FUNCTION\'), \n" - " (7, \'LOADER\')) AS (id, function_type_keyword)\n" + " (1, 'FUNCTION'), \n" + " (2, 'PROCEDURE'),\n" + " (3, 'AGGREGATE'),\n" + " (4, 'FILTER FUNCTION'),\n" + " (5, 'FUNCTION'), \n" + " (6, 'FUNCTION'), \n" + " (7, 'LOADER')) AS (id, function_type_keyword)\n" " WHERE id = function_type_id\n" ")\n" ", function_languages AS (\n" 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 @@ -1502,6 +1502,34 @@ sql_update_mar2018_samtools(Client c, mv #endif /* HAVE_SAMTOOLS */ static str +sql_update_mar2018_sp1(Client c, mvc *sql) +{ + size_t bufsize = 2048, pos = 0; + char *buf = GDKmalloc(bufsize), *err = NULL; + char *schema = stack_get_string(sql, "current_schema"); + + if (buf == NULL) + throw(SQL, "sql_update_dec2016_sp3", SQLSTATE(HY001) MAL_MALLOC_FAIL); + pos += snprintf(buf + pos, bufsize - pos, + "set schema \"sys\";\n" + "drop function sys.dependencies_functions_os_triggers();\n" + "CREATE FUNCTION dependencies_functions_on_triggers()\n" + "RETURNS TABLE (sch varchar(100), usr varchar(100), dep_type varchar(32))\n" + "RETURN TABLE (SELECT f.name, tri.name, 'DEP_TRIGGER' from functions as f, triggers as tri, dependencies as dep where dep.id = f.id AND dep.depend_id =tri.id AND dep.depend_type = 8);\n" + "insert into sys.systemfunctions (select id from sys.functions where name in ('dependencies_functions_on_triggers') and schema_id = (select id from sys.schemas where name = 'sys') and id not in (select function_id from sys.systemfunctions));\n" + "delete from systemfunctions where function_id not in (select id from functions);\n"); + if (schema) + pos += snprintf(buf + pos, bufsize - pos, "set schema \"%s\";\n", schema); + pos += snprintf(buf + pos, bufsize - pos, "commit;\n"); + assert(pos < bufsize); + + printf("Running database upgrade commands:\n%s\n", buf); + err = SQLstatementIntern(c, &buf, "update", 1, 0, NULL); + GDKfree(buf); + return err; /* usually MAL_SUCCEED */ +} + +static str sql_update_default(Client c, mvc *sql) { size_t bufsize = 1000, pos = 0; @@ -1654,6 +1682,13 @@ SQLupgrades(Client c, mvc *m) #endif } + if (sql_bind_func(m->sa, s, "dependencies_functions_os_triggers", NULL, NULL, F_UNION)) { + if ((err = sql_update_mar2018_sp1(c, m)) != NULL) { + fprintf(stderr, "!%s\n", err); + freeException(err); + } + } + sql_find_subtype(&tp, "clob", 0, 0); if (sql_bind_aggr(m->sa, s, "group_concat", &tp) == NULL) { if ((err = sql_update_default(c, m)) != NULL) { diff --git a/sql/scripts/21_dependency_functions.sql b/sql/scripts/21_dependency_functions.sql --- a/sql/scripts/21_dependency_functions.sql +++ b/sql/scripts/21_dependency_functions.sql @@ -88,7 +88,7 @@ RETURNS TABLE (sch varchar(100), usr var RETURN TABLE (SELECT f1.name, f2.name, 'DEP_FUNC' from functions as f1, functions as f2, dependencies as dep where f1.id = dep.id AND f2.id = dep.depend_id AND dep.depend_type = 7); --Function f1 has a dependency on trigger tri -CREATE FUNCTION dependencies_functions_os_triggers() +CREATE FUNCTION dependencies_functions_on_triggers() RETURNS TABLE (sch varchar(100), usr varchar(100), dep_type varchar(32)) RETURN TABLE (SELECT f.name, tri.name, 'DEP_TRIGGER' from functions as f, triggers as tri, dependencies as dep where dep.id = f.id AND dep.depend_id =tri.id AND dep.depend_type = 8); diff --git a/sql/server/sql_mvc.c b/sql/server/sql_mvc.c --- a/sql/server/sql_mvc.c +++ b/sql/server/sql_mvc.c @@ -142,11 +142,14 @@ mvc_init(int debug, store_type store, in sql_table *deps = find_sql_table(s, "dependencies"); sql_column *depids = find_sql_column(deps, "id"); oid rid; + rids *rs; table_funcs.table_insert(m->session->tr, privs, &t->base.id, &pub, &p, &zero, &zero); - while ((rid = table_funcs.column_find_row(m->session->tr, depids, &tid, NULL)), !is_oid_nil(rid)) { + rs = table_funcs.rids_select(m->session->tr, depids, &tid, &tid, NULL); + while ((rid = table_funcs.rids_next(rs)), !is_oid_nil(rid)) { table_funcs.column_update_value(m->session->tr, depids, rid, &ntid); } + table_funcs.rids_destroy(rs); } t = mvc_create_view(m, s, "columns", SQL_PERSIST, "SELECT * FROM (SELECT p.* FROM \"sys\".\"_columns\" AS p UNION ALL SELECT t.* FROM \"tmp\".\"_columns\" AS t) AS columns;", 1); @@ -170,11 +173,14 @@ mvc_init(int debug, store_type store, in sql_table *deps = find_sql_table(s, "dependencies"); sql_column *depids = find_sql_column(deps, "id"); oid rid; + rids *rs; table_funcs.table_insert(m->session->tr, privs, &t->base.id, &pub, &p, &zero, &zero); - while ((rid = table_funcs.column_find_row(m->session->tr, depids, &cid, NULL)), !is_oid_nil(rid)) { + rs = table_funcs.rids_select(m->session->tr, depids, &cid, &cid, NULL); + while ((rid = table_funcs.rids_next(rs)), !is_oid_nil(rid)) { table_funcs.column_update_value(m->session->tr, depids, rid, &ncid); } + table_funcs.rids_destroy(rs); } else { sql_create_env(m, s); sql_create_comments(m, s); diff --git a/sql/test/emptydb-upgrade-chain-hge/Tests/upgrade.reqtests b/sql/test/emptydb-upgrade-chain-hge/Tests/upgrade.reqtests new file mode 100644 --- /dev/null +++ b/sql/test/emptydb-upgrade-chain-hge/Tests/upgrade.reqtests @@ -0,0 +1,1 @@ +unpackage 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 @@ -25,6 +25,17 @@ stdout of test 'upgrade` in directory 's Ready. Running database upgrade commands: +set schema "sys"; +drop function sys.dependencies_functions_os_triggers(); +CREATE FUNCTION dependencies_functions_on_triggers() +RETURNS TABLE (sch varchar(100), usr varchar(100), dep_type varchar(32)) +RETURN TABLE (SELECT f.name, tri.name, 'DEP_TRIGGER' from functions as f, triggers as tri, dependencies as dep where dep.id = f.id AND dep.depend_id =tri.id AND dep.depend_type = 8); +insert into sys.systemfunctions (select id from sys.functions where name in ('dependencies_functions_on_triggers') and schema_id = (select id from sys.schemas where name = 'sys') and id not in (select function_id from sys.systemfunctions)); +delete from systemfunctions where function_id not in (select id from functions); +set schema "sys"; +commit; + +Running database upgrade commands: set schema sys; create aggregate sys.group_concat(str string) returns string external name "aggr"."str_group_concat"; grant execute on aggregate sys.group_concat(string) to public; diff --git a/sql/test/emptydb-upgrade-chain-hge/Tests/upgrade.stable.out.powerpc64 b/sql/test/emptydb-upgrade-chain-hge/Tests/upgrade.stable.out.powerpc64 deleted file mode 100644 --- a/sql/test/emptydb-upgrade-chain-hge/Tests/upgrade.stable.out.powerpc64 +++ /dev/null @@ -1,46 +0,0 @@ -stdout of test 'upgrade` in directory 'sql/test/emptydb-upgrade-chain-hge` itself: - - -# 15:46:25 > -# 15:46:25 > "mserver5" "--debug=10" "--set" "gdk_nr_threads=8" "--set" "mapi_open=true" "--set" "mapi_port=36716" "--set" "mapi_usock=/var/tmp/mtest-7779/.s.monetdb.36716" "--set" "monet_prompt=" "--forcemito" "--dbpath=/home/sjoerd/@Monet-candidate/var/MonetDB/mTests_sql_test_emptydb-upgrade-chain-hge" -# 15:46:25 > - -# MonetDB 5 server v11.29.0 (hg id: 839372b4b4bb) -# This is an unreleased version -# Serving database 'mTests_sql_test_emptydb-upgrade-chain-hge', using 8 threads -# Compiled for powerpc64-unknown-linux-gnu/64bit with 128bit integers -# Found 255.360 GiB available main-memory. -# Copyright (c) 1993 - July 2008 CWI. -# Copyright (c) August 2008 - 2018 MonetDB B.V., all rights reserved -# Visit https://www.monetdb.org/ for further information -# Listening for connection requests on mapi:monetdb://power8:36716/ -# Listening for UNIX domain connection requests on mapi:monetdb:///var/tmp/mtest-7779/.s.monetdb.36716 -# MonetDB/GIS module loaded -# MonetDB/SQL module loaded - -Ready. -Running database upgrade commands: -set schema sys; -create aggregate sys.group_concat(str string) returns string external name "aggr"."str_group_concat"; -grant execute on aggregate sys.group_concat(string) to public; -create aggregate sys.group_concat(str string, sep string) returns string external name "aggr"."str_group_concat"; -grant execute on aggregate sys.group_concat(string, string) to public; -insert into sys.systemfunctions (select id from sys.functions where name in ('group_concat') and schema_id = (select id from sys.schemas where name = 'sys') and id not in (select function_id from sys.systemfunctions)); -set schema "sys"; -commit; - -# 16:05:46 > -# 16:05:46 > "mclient" "-lsql" "-ftest" "-tnone" "-Eutf-8" "-i" "-e" "--host=/var/tmp/mtest-68585" "--port=37702" -# 16:05:46 > - -#select 1; -% .L2 # table_name -% L2 # name -% tinyint # type -% 1 # length -[ 1 ] - -# 15:46:33 > -# 15:46:33 > "Done." -# 15:46:33 > - diff --git a/sql/test/emptydb-upgrade-chain/Tests/upgrade.reqtests b/sql/test/emptydb-upgrade-chain/Tests/upgrade.reqtests new file mode 100644 --- /dev/null +++ b/sql/test/emptydb-upgrade-chain/Tests/upgrade.reqtests @@ -0,0 +1,1 @@ +unpackage diff --git a/sql/test/emptydb-upgrade-chain/Tests/upgrade.stable.out b/sql/test/emptydb-upgrade-chain/Tests/upgrade.stable.out --- a/sql/test/emptydb-upgrade-chain/Tests/upgrade.stable.out +++ b/sql/test/emptydb-upgrade-chain/Tests/upgrade.stable.out @@ -25,6 +25,17 @@ stdout of test 'upgrade` in directory 's Ready. Running database upgrade commands: +set schema "sys"; +drop function sys.dependencies_functions_os_triggers(); +CREATE FUNCTION dependencies_functions_on_triggers() +RETURNS TABLE (sch varchar(100), usr varchar(100), dep_type varchar(32)) +RETURN TABLE (SELECT f.name, tri.name, 'DEP_TRIGGER' from functions as f, triggers as tri, dependencies as dep where dep.id = f.id AND dep.depend_id =tri.id AND dep.depend_type = 8); +insert into sys.systemfunctions (select id from sys.functions where name in ('dependencies_functions_on_triggers') and schema_id = (select id from sys.schemas where name = 'sys') and id not in (select function_id from sys.systemfunctions)); +delete from systemfunctions where function_id not in (select id from functions); +set schema "sys"; +commit; + +Running database upgrade commands: set schema sys; create aggregate sys.group_concat(str string) returns string external name "aggr"."str_group_concat"; grant execute on aggregate sys.group_concat(string) to public; diff --git a/sql/test/emptydb-upgrade-chain/Tests/upgrade.stable.out.32bit b/sql/test/emptydb-upgrade-chain/Tests/upgrade.stable.out.32bit --- a/sql/test/emptydb-upgrade-chain/Tests/upgrade.stable.out.32bit +++ b/sql/test/emptydb-upgrade-chain/Tests/upgrade.stable.out.32bit @@ -25,6 +25,17 @@ stdout of test 'upgrade` in directory 's Ready. Running database upgrade commands: +set schema "sys"; +drop function sys.dependencies_functions_os_triggers(); +CREATE FUNCTION dependencies_functions_on_triggers() +RETURNS TABLE (sch varchar(100), usr varchar(100), dep_type varchar(32)) +RETURN TABLE (SELECT f.name, tri.name, 'DEP_TRIGGER' from functions as f, triggers as tri, dependencies as dep where dep.id = f.id AND dep.depend_id =tri.id AND dep.depend_type = 8); +insert into sys.systemfunctions (select id from sys.functions where name in ('dependencies_functions_on_triggers') and schema_id = (select id from sys.schemas where name = 'sys') and id not in (select function_id from sys.systemfunctions)); +delete from systemfunctions where function_id not in (select id from functions); +set schema "sys"; +commit; + +Running database upgrade commands: set schema sys; create aggregate sys.group_concat(str string) returns string external name "aggr"."str_group_concat"; grant execute on aggregate sys.group_concat(string) to public; diff --git a/sql/test/emptydb-upgrade-chain/Tests/upgrade.stable.out.int128 b/sql/test/emptydb-upgrade-chain/Tests/upgrade.stable.out.int128 --- a/sql/test/emptydb-upgrade-chain/Tests/upgrade.stable.out.int128 +++ b/sql/test/emptydb-upgrade-chain/Tests/upgrade.stable.out.int128 @@ -5353,6 +5353,17 @@ set schema "sys"; commit; Running database upgrade commands: +set schema "sys"; +drop function sys.dependencies_functions_os_triggers(); +CREATE FUNCTION dependencies_functions_on_triggers() +RETURNS TABLE (sch varchar(100), usr varchar(100), dep_type varchar(32)) +RETURN TABLE (SELECT f.name, tri.name, 'DEP_TRIGGER' from functions as f, triggers as tri, dependencies as dep where dep.id = f.id AND dep.depend_id =tri.id AND dep.depend_type = 8); +insert into sys.systemfunctions (select id from sys.functions where name in ('dependencies_functions_on_triggers') and schema_id = (select id from sys.schemas where name = 'sys') and id not in (select function_id from sys.systemfunctions)); +delete from systemfunctions where function_id not in (select id from functions); +set schema "sys"; +commit; + +Running database upgrade commands: set schema sys; create aggregate sys.group_concat(str string) returns string external name "aggr"."str_group_concat"; grant execute on aggregate sys.group_concat(string) to public; diff --git a/sql/test/emptydb-upgrade-chain/Tests/upgrade.stable.out.powerpc64.int128 b/sql/test/emptydb-upgrade-chain/Tests/upgrade.stable.out.powerpc64.int128 --- a/sql/test/emptydb-upgrade-chain/Tests/upgrade.stable.out.powerpc64.int128 +++ b/sql/test/emptydb-upgrade-chain/Tests/upgrade.stable.out.powerpc64.int128 @@ -5353,6 +5353,17 @@ set schema "sys"; commit; Running database upgrade commands: +set schema "sys"; +drop function sys.dependencies_functions_os_triggers(); +CREATE FUNCTION dependencies_functions_on_triggers() +RETURNS TABLE (sch varchar(100), usr varchar(100), dep_type varchar(32)) +RETURN TABLE (SELECT f.name, tri.name, 'DEP_TRIGGER' from functions as f, triggers as tri, dependencies as dep where dep.id = f.id AND dep.depend_id =tri.id AND dep.depend_type = 8); +insert into sys.systemfunctions (select id from sys.functions where name in ('dependencies_functions_on_triggers') and schema_id = (select id from sys.schemas where name = 'sys') and id not in (select function_id from sys.systemfunctions)); +delete from systemfunctions where function_id not in (select id from functions); +set schema "sys"; +commit; + +Running database upgrade commands: set schema sys; create aggregate sys.group_concat(str string) returns string external name "aggr"."str_group_concat"; grant execute on aggregate sys.group_concat(string) to public; diff --git a/sql/test/emptydb-upgrade-hge/Tests/upgrade.reqtests b/sql/test/emptydb-upgrade-hge/Tests/upgrade.reqtests new file mode 100644 --- /dev/null +++ b/sql/test/emptydb-upgrade-hge/Tests/upgrade.reqtests @@ -0,0 +1,1 @@ +unpackage diff --git a/sql/test/emptydb-upgrade-hge/Tests/upgrade.stable.out.int128 b/sql/test/emptydb-upgrade-hge/Tests/upgrade.stable.out.int128 --- a/sql/test/emptydb-upgrade-hge/Tests/upgrade.stable.out.int128 +++ b/sql/test/emptydb-upgrade-hge/Tests/upgrade.stable.out.int128 _______________________________________________ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list