Changeset: 84987918aa9b for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/84987918aa9b Branch: balanced_union Log Message:
Merge with default branch. diffs (truncated from 714 to 300 lines): 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 @@ -6657,7 +6657,7 @@ sql_update_default(Client c, mvc *sql, s if (BATcount(b) == 0) { /* do update */ sql_table *t; - const char query[] = + const char query1[] = "update sys._columns set type_digits = 7 where type = 'tinyint' and type_digits <> 7;\n" "update sys._columns set type_digits = 15 where type = 'smallint' and type_digits <> 15;\n" "update sys._columns set type_digits = 31 where type = 'int' and type_digits <> 31;\n" @@ -7061,37 +7061,102 @@ sql_update_default(Client c, mvc *sql, s t->system = 0; if ((t = mvc_bind_table(sql, s, "describe_tables")) != NULL) t->system = 0; - printf("Running database upgrade commands:\n%s\n", query); + printf("Running database upgrade commands:\n%s\n", query1); fflush(stdout); - err = SQLstatementIntern(c, query, "update", true, false, NULL); - - list *l; - if ((l = sa_list(sql->sa)) != NULL) { - sql_subtype tp1, tp2; - sql_find_subtype(&tp1, "date", 0, 0); - list_append(l, &tp1); - list_append(l, &tp1); - sql_find_subtype(&tp2, "day_interval", 0, 0); - list_append(l, &tp2); - if (!sql_bind_func_(sql, s->base.name, "generate_series", l, F_UNION, true, true)) { - const char query[] = "create function sys.generate_series(first date, \"limit\" date, stepsize interval month)\n" - "returns table (value date)\n" - "external name generator.series;\n" - "create function sys.generate_series(first date, \"limit\" date, stepsize interval day)\n" - "returns table (value date)\n" - "external name generator.series;\n" - "update sys.functions set system = true where system <> true and name = 'generate_series' and schema_id = 2000;\n"; - sql->session->status = 0; - sql->errstr[0] = '\0'; - printf("Running database upgrade commands:\n%s\n", query); + err = SQLstatementIntern(c, query1, "update", true, false, NULL); + if (err == MAL_SUCCEED) { + const char query2[] = "create function sys.generate_series(first date, \"limit\" date, stepsize interval month)\n" + "returns table (value date)\n" + "external name generator.series;\n" + "create function sys.generate_series(first date, \"limit\" date, stepsize interval day)\n" + "returns table (value date)\n" + "external name generator.series;\n" + "update sys.functions set system = true where system <> true and name = 'generate_series' and schema_id = 2000;\n"; + sql->session->status = 0; + sql->errstr[0] = '\0'; + printf("Running database upgrade commands:\n%s\n", query2); + fflush(stdout); + err = SQLstatementIntern(c, query2, "update", true, false, NULL); + if (err == MAL_SUCCEED) { + const char query3[] = + "drop view sys.sessions;\n" + "drop function sys.sessions();\n" + "create function sys.sessions()\n" + " returns table(\n" + " \"sessionid\" int,\n" + " \"username\" string,\n" + " \"login\" timestamp,\n" + " \"idle\" timestamp,\n" + " \"optimizer\" string,\n" + " \"sessiontimeout\" int,\n" + " \"querytimeout\" int,\n" + " \"workerlimit\" int,\n" + " \"memorylimit\" int,\n" + " \"language\" string,\n" + " \"peer\" string,\n" + " \"hostname\" string,\n" + " \"application\" string,\n" + " \"client\" string,\n" + " \"clientpid\" bigint,\n" + " \"remark\" string\n" + " )\n" + " external name sql.sessions;\n" + "create view sys.sessions as select * from sys.sessions();\n" + "create procedure sys.setclientinfo(property string, value string)\n" + " external name clients.setinfo;\n" + "grant execute on procedure sys.setclientinfo(string, string) to public;\n" + "create table sys.clientinfo_properties(prop string);\n" + "insert into sys.clientinfo_properties values\n" + " ('ClientHostname'),\n" + " ('ApplicationName'),\n" + " ('ClientLibrary'),\n" + " ('ClientRemark'),\n" + " ('ClientPid');\n" + "update sys.functions set system = true where schema_id = 2000 and name in ('setclientinfo', 'sessions');\n" + "update sys._tables set system = true where schema_id = 2000 and name in ('clientinfo_properties', 'sessions');\n"; + ; + sql_schema *sys = mvc_bind_schema(sql, "sys"); + sql_table *t = mvc_bind_table(sql, sys, "sessions"); + t->system = 0; /* make it non-system else the drop view will fail */ + printf("Running database upgrade commands:\n%s\n", query3); fflush(stdout); - err = SQLstatementIntern(c, query, "update", true, false, NULL); + err = SQLstatementIntern(c, query3, "update", true, false, NULL); + + if (err == MAL_SUCCEED) { + const char query4[] = + "DROP TABLE sys.key_types;\n" + "CREATE TABLE sys.key_types (\n" + " key_type_id SMALLINT NOT NULL PRIMARY KEY,\n" + " key_type_name VARCHAR(35) NOT NULL UNIQUE);\n" + "INSERT INTO sys.key_types VALUES\n" + "(0, 'Primary Key'),\n" + "(1, 'Unique Key'),\n" + "(2, 'Foreign Key'),\n" + "(3, 'Unique Key With Nulls Not Distinct'),\n" + "(4, 'Check Constraint');\n" + + "GRANT SELECT ON sys.key_types TO PUBLIC;\n" + "UPDATE sys._tables SET system = true WHERE schema_id = 2000 AND name = 'key_types';\n"; + sql_table *t; + if ((t = mvc_bind_table(sql, s, "key_types")) != NULL) + t->system = 0; + printf("Running database upgrade commands:\n%s\n", query4); + fflush(stdout); + err = SQLstatementIntern(c, query4, "update", true, false, NULL); + if (err == MAL_SUCCEED) { + const char query5[] = "ALTER TABLE sys.key_types SET READ ONLY;\n"; + printf("Running database upgrade commands:\n%s\n", query5); + fflush(stdout); + err = SQLstatementIntern(c, query5, "update", true, false, NULL); + } + } } } } BBPunfix(b->batCacheid); } res_table_destroy(output); + return err; } 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 @@ -1046,3 +1046,20 @@ insert into sys.clientinfo_properties va update sys.functions set system = true where schema_id = 2000 and name in ('setclientinfo', 'sessions'); update sys._tables set system = true where schema_id = 2000 and name in ('clientinfo_properties', 'sessions'); +Running database upgrade commands: +DROP TABLE sys.key_types; +CREATE TABLE sys.key_types ( + key_type_id SMALLINT NOT NULL PRIMARY KEY, + key_type_name VARCHAR(35) NOT NULL UNIQUE); +INSERT INTO sys.key_types VALUES +(0, 'Primary Key'), +(1, 'Unique Key'), +(2, 'Foreign Key'), +(3, 'Unique Key With Nulls Not Distinct'), +(4, 'Check Constraint'); +GRANT SELECT ON sys.key_types TO PUBLIC; +UPDATE sys._tables SET system = true WHERE schema_id = 2000 AND name = 'key_types'; + +Running database upgrade commands: +ALTER TABLE sys.key_types SET READ ONLY; + 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 @@ -1034,3 +1034,20 @@ insert into sys.clientinfo_properties va update sys.functions set system = true where schema_id = 2000 and name in ('setclientinfo', 'sessions'); update sys._tables set system = true where schema_id = 2000 and name in ('clientinfo_properties', 'sessions'); +Running database upgrade commands: +DROP TABLE sys.key_types; +CREATE TABLE sys.key_types ( + key_type_id SMALLINT NOT NULL PRIMARY KEY, + key_type_name VARCHAR(35) NOT NULL UNIQUE); +INSERT INTO sys.key_types VALUES +(0, 'Primary Key'), +(1, 'Unique Key'), +(2, 'Foreign Key'), +(3, 'Unique Key With Nulls Not Distinct'), +(4, 'Check Constraint'); +GRANT SELECT ON sys.key_types TO PUBLIC; +UPDATE sys._tables SET system = true WHERE schema_id = 2000 AND name = 'key_types'; + +Running database upgrade commands: +ALTER TABLE sys.key_types SET READ ONLY; + 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 @@ -1115,3 +1115,20 @@ insert into sys.clientinfo_properties va update sys.functions set system = true where schema_id = 2000 and name in ('setclientinfo', 'sessions'); update sys._tables set system = true where schema_id = 2000 and name in ('clientinfo_properties', 'sessions'); +Running database upgrade commands: +DROP TABLE sys.key_types; +CREATE TABLE sys.key_types ( + key_type_id SMALLINT NOT NULL PRIMARY KEY, + key_type_name VARCHAR(35) NOT NULL UNIQUE); +INSERT INTO sys.key_types VALUES +(0, 'Primary Key'), +(1, 'Unique Key'), +(2, 'Foreign Key'), +(3, 'Unique Key With Nulls Not Distinct'), +(4, 'Check Constraint'); +GRANT SELECT ON sys.key_types TO PUBLIC; +UPDATE sys._tables SET system = true WHERE schema_id = 2000 AND name = 'key_types'; + +Running database upgrade commands: +ALTER TABLE sys.key_types SET READ ONLY; + 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 @@ -1046,3 +1046,20 @@ insert into sys.clientinfo_properties va update sys.functions set system = true where schema_id = 2000 and name in ('setclientinfo', 'sessions'); update sys._tables set system = true where schema_id = 2000 and name in ('clientinfo_properties', 'sessions'); +Running database upgrade commands: +DROP TABLE sys.key_types; +CREATE TABLE sys.key_types ( + key_type_id SMALLINT NOT NULL PRIMARY KEY, + key_type_name VARCHAR(35) NOT NULL UNIQUE); +INSERT INTO sys.key_types VALUES +(0, 'Primary Key'), +(1, 'Unique Key'), +(2, 'Foreign Key'), +(3, 'Unique Key With Nulls Not Distinct'), +(4, 'Check Constraint'); +GRANT SELECT ON sys.key_types TO PUBLIC; +UPDATE sys._tables SET system = true WHERE schema_id = 2000 AND name = 'key_types'; + +Running database upgrade commands: +ALTER TABLE sys.key_types SET READ ONLY; + 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 @@ -1034,3 +1034,20 @@ insert into sys.clientinfo_properties va update sys.functions set system = true where schema_id = 2000 and name in ('setclientinfo', 'sessions'); update sys._tables set system = true where schema_id = 2000 and name in ('clientinfo_properties', 'sessions'); +Running database upgrade commands: +DROP TABLE sys.key_types; +CREATE TABLE sys.key_types ( + key_type_id SMALLINT NOT NULL PRIMARY KEY, + key_type_name VARCHAR(35) NOT NULL UNIQUE); +INSERT INTO sys.key_types VALUES +(0, 'Primary Key'), +(1, 'Unique Key'), +(2, 'Foreign Key'), +(3, 'Unique Key With Nulls Not Distinct'), +(4, 'Check Constraint'); +GRANT SELECT ON sys.key_types TO PUBLIC; +UPDATE sys._tables SET system = true WHERE schema_id = 2000 AND name = 'key_types'; + +Running database upgrade commands: +ALTER TABLE sys.key_types SET READ ONLY; + 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 @@ -1115,3 +1115,20 @@ insert into sys.clientinfo_properties va update sys.functions set system = true where schema_id = 2000 and name in ('setclientinfo', 'sessions'); update sys._tables set system = true where schema_id = 2000 and name in ('clientinfo_properties', 'sessions'); +Running database upgrade commands: +DROP TABLE sys.key_types; +CREATE TABLE sys.key_types ( + key_type_id SMALLINT NOT NULL PRIMARY KEY, + key_type_name VARCHAR(35) NOT NULL UNIQUE); +INSERT INTO sys.key_types VALUES +(0, 'Primary Key'), +(1, 'Unique Key'), +(2, 'Foreign Key'), +(3, 'Unique Key With Nulls Not Distinct'), +(4, 'Check Constraint'); +GRANT SELECT ON sys.key_types TO PUBLIC; +UPDATE sys._tables SET system = true WHERE schema_id = 2000 AND name = 'key_types'; + +Running database upgrade commands: +ALTER TABLE sys.key_types SET READ ONLY; + 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 @@ -436,3 +436,20 @@ insert into sys.clientinfo_properties va update sys.functions set system = true where schema_id = 2000 and name in ('setclientinfo', 'sessions'); update sys._tables set system = true where schema_id = 2000 and name in ('clientinfo_properties', 'sessions'); +Running database upgrade commands: +DROP TABLE sys.key_types; +CREATE TABLE sys.key_types ( + key_type_id SMALLINT NOT NULL PRIMARY KEY, + key_type_name VARCHAR(35) NOT NULL UNIQUE); +INSERT INTO sys.key_types VALUES +(0, 'Primary Key'), +(1, 'Unique Key'), +(2, 'Foreign Key'), +(3, 'Unique Key With Nulls Not Distinct'), +(4, 'Check Constraint'); _______________________________________________ checkin-list mailing list -- checkin-list@monetdb.org To unsubscribe send an email to checkin-list-le...@monetdb.org