Changeset: 3736bf1a6625 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=3736bf1a6625
Added Files:
sql/jdbc/tests/Tests/Test_CisValid.stable.err
sql/jdbc/tests/Tests/Test_CisValid.stable.out
Modified Files:
NT/monetdb_config.h.in
sql/backends/monet5/sql_upgrades.c
sql/server/sql_parser.y
sql/storage/store.c
sql/test/Tests/systemfunctions.stable.out
sql/test/Tests/systemfunctions.stable.out.int128
sql/test/emptydb-upgrade-chain-hge/Tests/check.stable.out.int128
sql/test/emptydb-upgrade-chain-hge/Tests/upgrade.stable.out.int128
sql/test/emptydb-upgrade-chain/Tests/check.stable.out
sql/test/emptydb-upgrade-chain/Tests/check.stable.out.int128
sql/test/emptydb-upgrade-chain/Tests/upgrade.stable.out
sql/test/emptydb-upgrade-chain/Tests/upgrade.stable.out.int128
sql/test/emptydb-upgrade-hge/Tests/check.stable.out.int128
sql/test/emptydb-upgrade-hge/Tests/upgrade.stable.out.int128
sql/test/emptydb-upgrade/Tests/check.stable.out
sql/test/emptydb-upgrade/Tests/check.stable.out.int128
sql/test/emptydb-upgrade/Tests/upgrade.stable.out
sql/test/emptydb-upgrade/Tests/upgrade.stable.out.int128
sql/test/emptydb/Tests/check.stable.out
sql/test/emptydb/Tests/check.stable.out.int128
sql/test/testdb-upgrade-chain-hge/Tests/upgrade.stable.out
sql/test/testdb-upgrade-chain/Tests/upgrade.stable.out
sql/test/testdb-upgrade-chain/Tests/upgrade.stable.out.int128
sql/test/testdb-upgrade-hge/Tests/upgrade.stable.out
sql/test/testdb-upgrade/Tests/upgrade.stable.out
sql/test/testdb-upgrade/Tests/upgrade.stable.out.int128
Branch: no-wrd
Log Message:
Merge with default branch.
diffs (truncated from 118173 to 300 lines):
diff --git a/NT/monetdb_config.h.in b/NT/monetdb_config.h.in
--- a/NT/monetdb_config.h.in
+++ b/NT/monetdb_config.h.in
@@ -1135,11 +1135,11 @@ typedef __uint128_t uhge;
#ifdef HAVE_EMBEDDED_R
#define _MSC_EXTENSIONS 1
#undef HAVE_CTIME_R
-#define PROMPT1 "\001\001\n" /* prompt: ready for new query
*/
-#define PROMPT2 "\001\002\n" /* prompt: more data needed */
#else
#define HAVE_MAPI 1
#endif
+#define PROMPT1 "\001\001\n" /* prompt: ready for new query
*/
+#define PROMPT2 "\001\002\n" /* prompt: more data needed */
#endif /* _SEEN_MONETDB_CONFIG_H */
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
@@ -1523,6 +1523,201 @@ sql_update_geom(Client c, mvc *sql, int
return err; /* usually MAL_SUCCEED */
}
+static str
+sql_update_default(Client c, mvc *sql)
+{
+ size_t bufsize = 10240, pos = 0;
+ char *buf = GDKmalloc(bufsize), *err = NULL;
+ ValRecord *schvar = stack_get_var(sql, "current_schema");
+ char *schema = NULL;
+ sql_schema *s;
+
+ s = mvc_bind_schema(sql, "sys");
+ if (schvar)
+ schema = strdup(schvar->val.sval);
+ pos += snprintf(buf + pos, bufsize - pos, "set schema \"sys\";\n");
+
+ {
+ sql_table *t;
+
+ if ((t = mvc_bind_table(sql, s, "storagemodel")) != NULL)
+ t->system = 0;
+ if ((t = mvc_bind_table(sql, s, "storagemodelinput")) != NULL)
+ t->system = 0;
+ if ((t = mvc_bind_table(sql, s, "storage")) != NULL)
+ t->system = 0;
+ if ((t = mvc_bind_table(sql, s, "tablestoragemodel")) != NULL)
+ t->system = 0;
+ }
+
+ /* 18_index.sql */
+ pos += snprintf(buf + pos, bufsize - pos,
+ "create procedure sys.createorderindex(sys string, tab
string, col string)\n"
+ "external name sql.createorderindex;\n"
+ "create procedure sys.droporderindex(sys string, tab
string, col string)\n"
+ "external name sql.droporderindex;\n");
+
+ /* 75_storagemodel.sql */
+ pos += snprintf(buf + pos, bufsize - pos,
+ "drop view sys.tablestoragemodel;\n"
+ "drop view sys.storagemodel;\n"
+ "drop function sys.storagemodel();\n"
+ "drop procedure sys.storagemodelinit();\n"
+ "drop function sys.\"storage\"(string, string,
string);\n"
+ "drop function sys.\"storage\"(string, string);\n"
+ "drop function sys.\"storage\"(string);\n"
+ "drop view sys.\"storage\";\n"
+ "drop function sys.\"storage\"();\n"
+ "alter table sys.storagemodelinput add column
\"orderidx\" bigint;\n"
+ "create function sys.\"storage\"()\n"
+ "returns table (\n"
+ " \"schema\" string,\n"
+ " \"table\" string,\n"
+ " \"column\" string,\n"
+ " \"type\" string,\n"
+ " \"mode\" string,\n"
+ " location string,\n"
+ " \"count\" bigint,\n"
+ " typewidth int,\n"
+ " columnsize bigint,\n"
+ " heapsize bigint,\n"
+ " hashes bigint,\n"
+ " phash boolean,\n"
+ " \"imprints\" bigint,\n"
+ " sorted boolean,\n"
+ " orderidx bigint\n"
+ ")\n"
+ "external name sql.\"storage\";\n"
+ "create view sys.\"storage\" as select * from
sys.\"storage\"();\n"
+ "create function sys.\"storage\"( sname string)\n"
+ "returns table (\n"
+ " \"schema\" string,\n"
+ " \"table\" string,\n"
+ " \"column\" string,\n"
+ " \"type\" string,\n"
+ " \"mode\" string,\n"
+ " location string,\n"
+ " \"count\" bigint,\n"
+ " typewidth int,\n"
+ " columnsize bigint,\n"
+ " heapsize bigint,\n"
+ " hashes bigint,\n"
+ " phash boolean,\n"
+ " \"imprints\" bigint,\n"
+ " sorted boolean,\n"
+ " orderidx bigint\n"
+ ")\n"
+ "external name sql.\"storage\";\n"
+ "create function sys.\"storage\"( sname string, tname
string)\n"
+ "returns table (\n"
+ " \"schema\" string,\n"
+ " \"table\" string,\n"
+ " \"column\" string,\n"
+ " \"type\" string,\n"
+ " \"mode\" string,\n"
+ " location string,\n"
+ " \"count\" bigint,\n"
+ " typewidth int,\n"
+ " columnsize bigint,\n"
+ " heapsize bigint,\n"
+ " hashes bigint,\n"
+ " phash boolean,\n"
+ " \"imprints\" bigint,\n"
+ " sorted boolean,\n"
+ " orderidx bigint\n"
+ ")\n"
+ "external name sql.\"storage\";\n"
+ "create function sys.\"storage\"( sname string, tname
string, cname string)\n"
+ "returns table (\n"
+ " \"schema\" string,\n"
+ " \"table\" string,\n"
+ " \"column\" string,\n"
+ " \"type\" string,\n"
+ " \"mode\" string,\n"
+ " location string,\n"
+ " \"count\" bigint,\n"
+ " typewidth int,\n"
+ " columnsize bigint,\n"
+ " heapsize bigint,\n"
+ " hashes bigint,\n"
+ " phash boolean,\n"
+ " \"imprints\" bigint,\n"
+ " sorted boolean,\n"
+ " orderidx bigint\n"
+ ")\n"
+ "external name sql.\"storage\";\n"
+ "create procedure sys.storagemodelinit()\n"
+ "begin\n"
+ " delete from sys.storagemodelinput;\n"
+ " insert into sys.storagemodelinput\n"
+ " select X.\"schema\", X.\"table\", X.\"column\",
X.\"type\", X.typewidth, X.count, 0, X.typewidth, false, X.sorted, X.orderidx
from sys.\"storage\"() X;\n"
+ " update sys.storagemodelinput\n"
+ " set reference = true\n"
+ " where concat(concat(\"schema\",\"table\"),
\"column\") in (\n"
+ " SELECT concat( concat(\"fkschema\".\"name\",
\"fktable\".\"name\"), \"fkkeycol\".\"name\" )\n"
+ " FROM \"sys\".\"keys\" AS \"fkkey\",\n"
+ " \"sys\".\"objects\" AS \"fkkeycol\",\n"
+ " \"sys\".\"tables\" AS \"fktable\",\n"
+ " \"sys\".\"schemas\" AS \"fkschema\"\n"
+ " WHERE \"fktable\".\"id\" =
\"fkkey\".\"table_id\"\n"
+ " AND \"fkkey\".\"id\" = \"fkkeycol\".\"id\"\n"
+ " AND \"fkschema\".\"id\" =
\"fktable\".\"schema_id\"\n"
+ " AND \"fkkey\".\"rkey\" > -1);\n"
+ " update sys.storagemodelinput\n"
+ " set \"distinct\" = \"count\"\n"
+ " where \"type\" = 'varchar' or \"type\"='clob';\n"
+ "end;\n"
+ "create function sys.storagemodel()\n"
+ "returns table (\n"
+ " \"schema\" string,\n"
+ " \"table\" string,\n"
+ " \"column\" string,\n"
+ " \"type\" string,\n"
+ " \"count\" bigint,\n"
+ " columnsize bigint,\n"
+ " heapsize bigint,\n"
+ " hashes bigint,\n"
+ " \"imprints\" bigint,\n"
+ " sorted boolean,\n"
+ " orderidx bigint)\n"
+ "begin\n"
+ " return select I.\"schema\", I.\"table\",
I.\"column\", I.\"type\", I.\"count\",\n"
+ " columnsize(I.\"type\", I.count, I.\"distinct\"),\n"
+ " heapsize(I.\"type\", I.\"distinct\",
I.\"atomwidth\"),\n"
+ " hashsize(I.\"reference\", I.\"count\"),\n"
+ " imprintsize(I.\"count\",I.\"type\"),\n"
+ " I.sorted, I.orderidx\n"
+ " from sys.storagemodelinput I;\n"
+ "end;\n"
+ "create view sys.storagemodel as select * from
sys.storagemodel();\n"
+ "create view sys.tablestoragemodel\n"
+ "as select \"schema\",\"table\",max(count) as
\"count\",\n"
+ " sum(columnsize) as columnsize,\n"
+ " sum(heapsize) as heapsize,\n"
+ " sum(hashes) as hashes,\n"
+ " sum(\"imprints\") as \"imprints\",\n"
+ " sum(case when sorted = false then 8 * count else 0
end) as auxiliary\n"
+ "from sys.storagemodel() group by
\"schema\",\"table\";\n"
+ "update sys._tables set system = true where name in
('storage', 'storagemodel', 'tablestoragemodel') and schema_id = (select id
from sys.schemas where name = 'sys');\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 ('storage', 'storagemodel') and
f.type = %d and f.schema_id = s.id and s.name = 'sys');\n",
+ F_UNION);
+ pos += snprintf(buf + pos, bufsize - pos,
+ "insert into sys.systemfunctions (select f.id from
sys.functions f, sys.schemas s where f.name in ('createorderindex',
'droporderindex', 'storagemodelinit') and f.type = %d and f.schema_id = s.id
and s.name = 'sys');\n",
+ F_PROC);
+
+ 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, NULL);
+ GDKfree(buf);
+ return err; /* usually MAL_SUCCEED */
+}
+
void
SQLupgrades(Client c, mvc *m)
{
@@ -1624,4 +1819,12 @@ SQLupgrades(Client c, mvc *m)
}
}
}
+
+ sql_find_subtype(&tp, "clob", 0, 0);
+ if (!sql_bind_func3(m->sa, s, "createorderindex", &tp, &tp, &tp,
F_PROC)) {
+ if ((err = sql_update_default(c, m)) != NULL) {
+ fprintf(stderr, "!%s\n", err);
+ GDKfree(err);
+ }
+ }
}
diff --git a/sql/jdbc/tests/Tests/Test_CisValid.stable.err
b/sql/jdbc/tests/Tests/Test_CisValid.stable.err
new file mode 100644
--- /dev/null
+++ b/sql/jdbc/tests/Tests/Test_CisValid.stable.err
@@ -0,0 +1,48 @@
+stderr of test 'Test_CisValid` in directory 'sql/jdbc/tests` itself:
+
+
+# 23:03:07 >
+# 23:03:07 > "mserver5" "--debug=10" "--set" "gdk_nr_threads=0" "--set"
"mapi_open=true" "--set" "mapi_port=36086" "--set"
"mapi_usock=/var/tmp/mtest-9079/.s.monetdb.36086" "--set" "monet_prompt="
"--forcemito" "--set" "mal_listing=2"
"--dbpath=/export/scratch2/zhang/monet-install/Jul2015/debug/var/MonetDB/mTests_sql_jdbc_tests"
"--set" "mal_listing=0" "--set" "embedded_r=yes"
+# 23:03:07 >
+
+# builtin opt gdk_dbpath =
/export/scratch2/zhang/monet-install/Jul2015/debug/var/monetdb5/dbfarm/demo
+# builtin opt gdk_debug = 0
+# builtin opt gdk_vmtrim = no
+# builtin opt monet_prompt = >
+# builtin opt monet_daemon = no
+# builtin opt mapi_port = 50000
+# builtin opt mapi_open = false
+# builtin opt mapi_autosense = false
+# builtin opt sql_optimizer = default_pipe
+# builtin opt sql_debug = 0
+# cmdline opt gdk_nr_threads = 0
+# cmdline opt mapi_open = true
+# cmdline opt mapi_port = 36086
+# cmdline opt mapi_usock = /var/tmp/mtest-9079/.s.monetdb.36086
+# cmdline opt monet_prompt =
+# cmdline opt mal_listing = 2
+# cmdline opt gdk_dbpath =
/export/scratch2/zhang/monet-install/Jul2015/debug/var/MonetDB/mTests_sql_jdbc_tests
+# cmdline opt mal_listing = 0
+# cmdline opt embedded_r = yes
+# cmdline opt gdk_debug = 536870922
+
+# 23:03:08 >
+# 23:03:08 > "./Test_CisValid.SQL.sh" "Test_CisValid"
+# 23:03:08 >
+
+
+# 23:03:08 >
+# 23:03:08 > java Test_CisValid
"jdbc:monetdb://toulouse:36086/mTests_sql_jdbc_tests?user=monetdb&password=monetdb"
+# 23:03:08 >
+
+java.sql.SQLException: SELECT: no such table 'doesnotexist'
+ at
nl.cwi.monetdb.jdbc.MonetConnection$ResponseList.executeQuery(MonetConnection.java:2603)
+ at
nl.cwi.monetdb.jdbc.MonetConnection$ResponseList.processQuery(MonetConnection.java:2351)
+ at
nl.cwi.monetdb.jdbc.MonetStatement.internalExecute(MonetStatement.java:507)
+ at nl.cwi.monetdb.jdbc.MonetStatement.execute(MonetStatement.java:345)
+ at Test_CisValid.main(Test_CisValid.java:23)
+
+# 23:03:08 >
+# 23:03:08 > "Done."
+# 23:03:08 >
+
diff --git a/sql/jdbc/tests/Tests/Test_CisValid.stable.out
b/sql/jdbc/tests/Tests/Test_CisValid.stable.out
new file mode 100644
--- /dev/null
+++ b/sql/jdbc/tests/Tests/Test_CisValid.stable.out
@@ -0,0 +1,77 @@
+stdout of test 'Test_CisValid` in directory 'sql/jdbc/tests` itself:
+
+
+# 23:03:07 >
+# 23:03:07 > "mserver5" "--debug=10" "--set" "gdk_nr_threads=0" "--set"
"mapi_open=true" "--set" "mapi_port=36086" "--set"
"mapi_usock=/var/tmp/mtest-9079/.s.monetdb.36086" "--set" "monet_prompt="
"--forcemito" "--set" "mal_listing=2"
"--dbpath=/export/scratch2/zhang/monet-install/Jul2015/debug/var/MonetDB/mTests_sql_jdbc_tests"
"--set" "mal_listing=0" "--set" "embedded_r=yes"
+# 23:03:07 >
+
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list