Changeset: 0c356cb51b40 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=0c356cb51b40
Modified Files:
sql/backends/monet5/sql_upgrades.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
Branch: Mar2018
Log Message:
Drop the SQL function sys.chi2prob if the MAL implementation is missing.
diffs (139 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
@@ -1599,6 +1599,30 @@ sql_replace_Mar2018_ids_view(Client c, m
return err; /* usually MAL_SUCCEED */
}
+static str
+sql_update_gsl(Client c, mvc *sql)
+{
+ size_t bufsize = 1024, pos = 0;
+ char *buf = GDKmalloc(bufsize), *err = NULL;
+ char *schema = stack_get_string(sql, "current_schema");
+
+ if (buf == NULL)
+ throw(SQL, "sql_update_gsl", SQLSTATE(HY001) MAL_MALLOC_FAIL);
+ pos += snprintf(buf + pos, bufsize - pos,
+ "set schema \"sys\";\n"
+ "drop function sys.chi2prob(double, double);\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 */
+}
+
void
SQLupgrades(Client c, mvc *m)
{
@@ -1753,4 +1777,19 @@ SQLupgrades(Client c, mvc *m)
if (output != NULL)
res_tables_destroy(output);
}
+
+ /* temporarily use variable `err' to check existence of MAL
+ * module gsl */
+ if ((err = getName("gsl")) == NULL || getModule(err) == NULL) {
+ /* no MAL module gsl, check for SQL function sys.chi2prob */
+ sql_find_subtype(&tp, "double", 0, 0);
+ if (sql_bind_func(m->sa, s, "chi2prob", &tp, &tp, F_FUNC)) {
+ /* sys.chi2prob exists, but there is no
+ * implementation */
+ if ((err = sql_update_gsl(c, m)) != NULL) {
+ fprintf(stderr, "!%s\n", err);
+ freeException(err);
+ }
+ }
+ }
}
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
@@ -72,6 +72,13 @@ update sys._tables set system = true whe
set schema "sys";
commit;
+Running database upgrade commands:
+set schema "sys";
+drop function sys.chi2prob(double, double);
+delete from systemfunctions where function_id not in (select id from
functions);
+set schema "sys";
+commit;
+
# 12:37:06 >
# 12:37:06 > "mclient" "-lsql" "-ftest" "-tnone" "-Eutf-8" "-i" "-e"
"--host=/var/tmp/mtest-5246" "--port=36929"
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
@@ -72,6 +72,13 @@ update sys._tables set system = true whe
set schema "sys";
commit;
+Running database upgrade commands:
+set schema "sys";
+drop function sys.chi2prob(double, double);
+delete from systemfunctions where function_id not in (select id from
functions);
+set schema "sys";
+commit;
+
# 12:45:40 >
# 12:45:40 > "mclient" "-lsql" "-ftest" "-tnone" "-Eutf-8" "-i" "-e"
"--host=/var/tmp/mtest-30170" "--port=38749"
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
@@ -72,6 +72,13 @@ update sys._tables set system = true whe
set schema "sys";
commit;
+Running database upgrade commands:
+set schema "sys";
+drop function sys.chi2prob(double, double);
+delete from systemfunctions where function_id not in (select id from
functions);
+set schema "sys";
+commit;
+
# 12:54:59 >
# 12:54:59 > "mclient" "-lsql" "-ftest" "-tnone" "-Eutf-8" "-i" "-e"
"--host=/var/tmp/mtest-3953" "--port=34683"
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
@@ -5400,6 +5400,13 @@ update sys._tables set system = true whe
set schema "sys";
commit;
+Running database upgrade commands:
+set schema "sys";
+drop function sys.chi2prob(double, double);
+delete from systemfunctions where function_id not in (select id from
functions);
+set schema "sys";
+commit;
+
# 16:53:35 >
# 16:53:35 > "mclient" "-lsql" "-ftest" "-Eutf-8" "-i" "-e"
"--host=/var/tmp/mtest-30908" "--port=39660"
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
@@ -5400,6 +5400,13 @@ update sys._tables set system = true whe
set schema "sys";
commit;
+Running database upgrade commands:
+set schema "sys";
+drop function sys.chi2prob(double, double);
+delete from systemfunctions where function_id not in (select id from
functions);
+set schema "sys";
+commit;
+
# 15:43:25 >
# 15:43:25 > "mclient" "-lsql" "-ftest" "-tnone" "-Eutf-8" "-i" "-e"
"--host=/var/tmp/mtest-5725" "--port=37647"
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list