Changeset: 3f4c730fed75 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/3f4c730fed75 Modified Files: sql/backends/monet5/sql_upgrades.c Branch: default Log Message:
fix merge conflict in 0a8d1af0c436 diffs (135 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 @@ -7066,32 +7066,110 @@ sql_update_default(Client c, mvc *sql, s 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); - fflush(stdout); - err = SQLstatementIntern(c, query, "update", true, false, NULL); - } + if (!(l = sa_list(sql->sa))) + return "allocation failed"; + 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); + fflush(stdout); + err = SQLstatementIntern(c, query, "update", true, false, NULL); } } BBPunfix(b->batCacheid); } res_table_destroy(output); + + const char *query = "select id from args where func_id = (select id from functions where schema_id = 2000 and name = 'sessions');\n"; + err = SQLstatementIntern(c, query, "update", true, false, &output); + if (err) + goto end; + b = BATdescriptor(output->cols[0].b); + if (b && BATcount(b) < 15) { + query = + "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", query); + fflush(stdout); + err = SQLstatementIntern(c, query, "update", true, false, NULL); + } + if (b) + BBPunfix(b->batCacheid); + res_table_destroy(output); + +end: + sa_destroy(sql->sa); + + if (err) + return err; + sql_table *t; + if ((t = mvc_bind_table(sql, s, "key_types")) != NULL) + t->system = 0; + err = SQLstatementIntern(c, + "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" + "ALTER TABLE sys.key_types SET READ ONLY;\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" + , "update", true, false, NULL); return err; } _______________________________________________ checkin-list mailing list -- checkin-list@monetdb.org To unsubscribe send an email to checkin-list-le...@monetdb.org