Changeset: 8750c9c9f6e5 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=8750c9c9f6e5
Modified Files:
sql/backends/monet5/sql_scenario.c
sql/test/testdb-upgrade-chain/Tests/upgrade.stable.out
sql/test/testdb-upgrade/Tests/upgrade.stable.out
Branch: default
Log Message:
Fix up upgrade path to default branch after changeset 704c67d263e7.
diffs (162 lines):
diff --git a/sql/backends/monet5/sql_scenario.c
b/sql/backends/monet5/sql_scenario.c
--- a/sql/backends/monet5/sql_scenario.c
+++ b/sql/backends/monet5/sql_scenario.c
@@ -759,14 +759,6 @@ sql_update_jan2014(Client c)
fclose(fp);
}
- /* new file 41_jsonstore.sql */
- pos += snprintf(buf + pos, bufsize - pos, "create function sys.md5(v
string) returns string external name clients.md5sum;\n");
-
- /* new file 45_uuid.sql */
- pos += snprintf(buf + pos, bufsize - pos, "create type uuid external
name uuid;\n");
- pos += snprintf(buf + pos, bufsize - pos, "create function sys.uuid()
returns uuid external name uuid.\"new\";\n");
- pos += snprintf(buf + pos, bufsize - pos, "create function
sys.isaUUID(u uuid) returns uuid external name uuid.\"isaUUID\";\n");
-
/* added entry in 75_storagemodel.sql */
pos += snprintf(buf + pos, bufsize - pos, "create view sys.storage as
select * from sys.storage();\n");
pos += snprintf(buf + pos, bufsize - pos, "create view sys.storagemodel
as select * from sys.storagemodel();\n");
@@ -783,7 +775,7 @@ sql_update_jan2014(Client c)
}
pos += snprintf(buf + pos, bufsize - pos,
- "insert into sys.systemfunctions (select f.id from
sys.functions f, sys.schemas s where f.name in ('isauuid', 'json_filter',
'json_filter_all', 'json_isvalid', 'json_isvalidarray', 'json_isvalidobject',
'json_length', 'json_path', 'json_text', 'md5', 'querylog_calls',
'querylog_catalog', 'queue', 'sessions', 'uuid') and f.type = %d and
f.schema_id = s.id and s.name = 'sys');\n",
+ "insert into sys.systemfunctions (select f.id from
sys.functions f, sys.schemas s where f.name in ('json_filter',
'json_filter_all', 'json_isvalid', 'json_isvalidarray', 'json_isvalidobject',
'json_length', 'json_path', 'json_text', 'querylog_calls', 'querylog_catalog',
'queue', 'sessions') and f.type = %d and f.schema_id = s.id and s.name =
'sys');\n",
F_FUNC);
pos += snprintf(buf + pos, bufsize - pos,
"insert into sys.systemfunctions (select f.id from
sys.functions f, sys.schemas s where f.name in ('analyze', 'pause',
'querylog_disable', 'querylog_empty', 'querylog_enable', 'resume',
'setsession', 'settimeout', 'shutdown', 'stop', 'sysmon_resume') and f.type =
%d and f.schema_id = s.id and s.name = 'sys');\n",
@@ -805,6 +797,44 @@ sql_update_jan2014(Client c)
return err; /* usually MAL_SUCCEED */
}
+static str
+sql_update_default(Client c)
+{
+ size_t bufsize = 2048, pos = 0;
+ char *buf = GDKmalloc(bufsize), *err = NULL;
+ ValRecord *schvar = stack_get_var(((backend *) c->sqlcontext)->mvc,
"current_schema");
+ char *schema = NULL;
+
+ if (schvar)
+ schema = strdup(schvar->val.sval);
+
+ pos += snprintf(buf + pos, bufsize - pos, "set schema \"sys\";\n");
+
+ /* new file 41_jsonstore.sql */
+ pos += snprintf(buf + pos, bufsize - pos, "create function sys.md5(v
string) returns string external name clients.md5sum;\n");
+
+ /* new file 45_uuid.sql */
+ pos += snprintf(buf + pos, bufsize - pos, "create type uuid external
name uuid;\n");
+ pos += snprintf(buf + pos, bufsize - pos, "create function sys.uuid()
returns uuid external name uuid.\"new\";\n");
+ pos += snprintf(buf + pos, bufsize - pos, "create function
sys.isaUUID(u uuid) returns uuid external name uuid.\"isaUUID\";\n");
+
+ pos += snprintf(buf + pos, bufsize - pos,
+ "insert into sys.systemfunctions (select f.id from
sys.functions f, sys.schemas s where f.name in ('isauuid', 'md5', 'uuid') and
f.type = %d and f.schema_id = s.id and s.name = 'sys');\n",
+ F_FUNC);
+
+ if (schema) {
+ pos += snprintf(buf + pos, bufsize - pos, "set schema
\"%s\";\n", schema);
+ free(schema);
+ }
+
+ assert(pos < bufsize);
+
+ printf("Running database upgrade commands:\n%s\n", buf);
+ err = SQLstatementIntern(c, &buf, "update", 1, 0);
+ GDKfree(buf);
+ return err; /* usually MAL_SUCCEED */
+}
+
str
SQLinitClient(Client c)
{
@@ -1017,6 +1047,15 @@ SQLinitClient(Client c)
GDKfree(err);
}
}
+ /* if function sys.md5(str) does not exist, we need to
+ * update */
+ sql_find_subtype(&tp, "clob", 0, 0);
+ if (!sql_bind_func(m->sa, mvc_bind_schema(m, "sys"), "md5",
&tp, NULL, F_FUNC)) {
+ if ((err = sql_update_default(c)) !=NULL) {
+ fprintf(stderr, "!%s\n", err);
+ GDKfree(err);
+ }
+ }
}
fflush(stdout);
fflush(stderr);
diff --git a/sql/test/testdb-upgrade-chain/Tests/upgrade.stable.out
b/sql/test/testdb-upgrade-chain/Tests/upgrade.stable.out
--- a/sql/test/testdb-upgrade-chain/Tests/upgrade.stable.out
+++ b/sql/test/testdb-upgrade-chain/Tests/upgrade.stable.out
@@ -274,10 +274,6 @@ returns integer external name json.lengt
-- returns json external name json.objectrender;
-- create function sys.json_array(*)
-- returns json external name json.arrayrender;
-create function sys.md5(v string) returns string external name clients.md5sum;
-create type uuid external name uuid;
-create function sys.uuid() returns uuid external name uuid."new";
-create function sys.isaUUID(u uuid) returns uuid external name uuid."isaUUID";
create view sys.storage as select * from sys.storage();
create view sys.storagemodel as select * from sys.storagemodel();
-- The contents of this file are subject to the MonetDB Public License
@@ -346,12 +342,21 @@ external name sql.analyze;
create procedure analyze(sch string, tbl string, col string, "sample" bigint)
external name sql.analyze;
-insert into sys.systemfunctions (select f.id from sys.functions f, sys.schemas
s where f.name in ('isauuid', 'json_filter', 'json_filter_all', 'json_isvalid',
'json_isvalidarray', 'json_isvalidobject', 'json_length', 'json_path',
'json_text', 'md5', 'querylog_calls', 'querylog_catalog', 'queue', 'sessions',
'uuid') and f.type = 1 and f.schema_id = s.id and s.name = 'sys');
+insert into sys.systemfunctions (select f.id from sys.functions f, sys.schemas
s where f.name in ('json_filter', 'json_filter_all', 'json_isvalid',
'json_isvalidarray', 'json_isvalidobject', 'json_length', 'json_path',
'json_text', 'querylog_calls', 'querylog_catalog', 'queue', 'sessions') and
f.type = 1 and f.schema_id = s.id and s.name = 'sys');
insert into sys.systemfunctions (select f.id from sys.functions f, sys.schemas
s where f.name in ('analyze', 'pause', 'querylog_disable', 'querylog_empty',
'querylog_enable', 'resume', 'setsession', 'settimeout', 'shutdown', 'stop',
'sysmon_resume') and f.type = 2 and f.schema_id = s.id and s.name = 'sys');
insert into sys.systemfunctions (select f.id from sys.functions f, sys.schemas
s where f.name in ('quantile', 'median') and f.type = 3 and f.schema_id = s.id
and s.name = 'sys');
update sys._tables set system = true where name in ('environment',
'optimizers', 'queue', 'sessions', 'statistics', 'storage', 'storagemodel',
'tracelog') and schema_id = (select id from sys.schemas where name = 'sys');
set schema "testschema";
+Running database upgrade commands:
+set schema "sys";
+create function sys.md5(v string) returns string external name clients.md5sum;
+create type uuid external name uuid;
+create function sys.uuid() returns uuid external name uuid."new";
+create function sys.isaUUID(u uuid) returns uuid external name uuid."isaUUID";
+insert into sys.systemfunctions (select f.id from sys.functions f, sys.schemas
s where f.name in ('isauuid', 'md5', 'uuid') and f.type = 1 and f.schema_id =
s.id and s.name = 'sys');
+set schema "testschema";
+
# 12:50:17 >
# 12:50:17 > "/usr/bin/python2" "upgrade.SQL.py" "upgrade"
diff --git a/sql/test/testdb-upgrade/Tests/upgrade.stable.out
b/sql/test/testdb-upgrade/Tests/upgrade.stable.out
--- a/sql/test/testdb-upgrade/Tests/upgrade.stable.out
+++ b/sql/test/testdb-upgrade/Tests/upgrade.stable.out
@@ -270,10 +270,6 @@ returns integer external name json.lengt
-- returns json external name json.objectrender;
-- create function sys.json_array(*)
-- returns json external name json.arrayrender;
-create function sys.md5(v string) returns string external name clients.md5sum;
-create type uuid external name uuid;
-create function sys.uuid() returns uuid external name uuid."new";
-create function sys.isaUUID(u uuid) returns uuid external name uuid."isaUUID";
create view sys.storage as select * from sys.storage();
create view sys.storagemodel as select * from sys.storagemodel();
-- The contents of this file are subject to the MonetDB Public License
@@ -342,12 +338,21 @@ external name sql.analyze;
create procedure analyze(sch string, tbl string, col string, "sample" bigint)
external name sql.analyze;
-insert into sys.systemfunctions (select f.id from sys.functions f, sys.schemas
s where f.name in ('isauuid', 'json_filter', 'json_filter_all', 'json_isvalid',
'json_isvalidarray', 'json_isvalidobject', 'json_length', 'json_path',
'json_text', 'md5', 'querylog_calls', 'querylog_catalog', 'queue', 'sessions',
'uuid') and f.type = 1 and f.schema_id = s.id and s.name = 'sys');
+insert into sys.systemfunctions (select f.id from sys.functions f, sys.schemas
s where f.name in ('json_filter', 'json_filter_all', 'json_isvalid',
'json_isvalidarray', 'json_isvalidobject', 'json_length', 'json_path',
'json_text', 'querylog_calls', 'querylog_catalog', 'queue', 'sessions') and
f.type = 1 and f.schema_id = s.id and s.name = 'sys');
insert into sys.systemfunctions (select f.id from sys.functions f, sys.schemas
s where f.name in ('analyze', 'pause', 'querylog_disable', 'querylog_empty',
'querylog_enable', 'resume', 'setsession', 'settimeout', 'shutdown', 'stop',
'sysmon_resume') and f.type = 2 and f.schema_id = s.id and s.name = 'sys');
insert into sys.systemfunctions (select f.id from sys.functions f, sys.schemas
s where f.name in ('quantile', 'median') and f.type = 3 and f.schema_id = s.id
and s.name = 'sys');
update sys._tables set system = true where name in ('environment',
'optimizers', 'queue', 'sessions', 'statistics', 'storage', 'storagemodel',
'tracelog') and schema_id = (select id from sys.schemas where name = 'sys');
set schema "testschema";
+Running database upgrade commands:
+set schema "sys";
+create function sys.md5(v string) returns string external name clients.md5sum;
+create type uuid external name uuid;
+create function sys.uuid() returns uuid external name uuid."new";
+create function sys.isaUUID(u uuid) returns uuid external name uuid."isaUUID";
+insert into sys.systemfunctions (select f.id from sys.functions f, sys.schemas
s where f.name in ('isauuid', 'md5', 'uuid') and f.type = 1 and f.schema_id =
s.id and s.name = 'sys');
+set schema "testschema";
+
# 21:49:41 >
# 21:49:41 > "/usr/bin/python2" "upgrade.SQL.py" "upgrade"
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list