Changeset: 1f79d01e7cc3 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=1f79d01e7cc3
Modified Files:
clients/mapiclient/dump.c
clients/mapiclient/mclient.c
monetdb5/modules/mal/pcre.c
sql/backends/monet5/UDF/pyapi/connection.c
sql/backends/monet5/sql_upgrades.c
sql/scripts/51_sys_schema_extension.sql
sql/server/sql_parser.y
sql/test/emptydb-upgrade-chain-hge/Tests/upgrade.stable.out.int128
sql/test/emptydb-upgrade-chain-hge/Tests/upgrade.stable.out.powerpc64
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
sql/test/emptydb-upgrade-chain/Tests/upgrade.stable.out.powerpc64.int128
sql/test/emptydb-upgrade-hge/Tests/upgrade.stable.out.int128
sql/test/emptydb-upgrade/Tests/upgrade.stable.out
sql/test/emptydb-upgrade/Tests/upgrade.stable.out.32bit
sql/test/emptydb-upgrade/Tests/upgrade.stable.out.int128
sql/test/emptydb/Tests/check.SQL.py
sql/test/emptydb/Tests/check.stable.out
sql/test/emptydb/Tests/check.stable.out.32bit
sql/test/emptydb/Tests/check.stable.out.int128
sql/test/testdb-upgrade-chain-hge/Tests/upgrade.stable.out.int128
sql/test/testdb-upgrade-chain/Tests/upgrade.stable.out
sql/test/testdb-upgrade-chain/Tests/upgrade.stable.out.32bit
sql/test/testdb-upgrade-chain/Tests/upgrade.stable.out.int128
sql/test/testdb-upgrade-hge/Tests/upgrade.stable.out.int128
sql/test/testdb-upgrade/Tests/upgrade.stable.out
sql/test/testdb-upgrade/Tests/upgrade.stable.out.32bit
sql/test/testdb-upgrade/Tests/upgrade.stable.out.int128
Branch: data-vaults
Log Message:
Merge with default
diffs (truncated from 2448 to 300 lines):
diff --git a/clients/mapiclient/dump.c b/clients/mapiclient/dump.c
--- a/clients/mapiclient/dump.c
+++ b/clients/mapiclient/dump.c
@@ -817,8 +817,17 @@ describe_table(Mapi mid, const char *sch
remark = NULL;
goto bailout;
}
- if (view)
+ if (view) {
+ /* skip initial comments and empty lines */
+ while ((view[0] == '-' && view[1] == '-') || view[0] == '\n') {
+ view = strchr(view, '\n');
+ if (view == NULL)
+ view = "";
+ else
+ view++;
+ }
view = strdup(view);
+ }
if (remark)
remark = strdup(remark);
mapi_close_handle(hdl);
@@ -1384,17 +1393,17 @@ static int
dump_function(Mapi mid, stream *toConsole, const char *fid, int hashge)
{
MapiHdl hdl;
- size_t qlen = 200 + strlen(fid);
+ size_t qlen = 400 + strlen(fid);
char *query = malloc(qlen);
const char *sep;
- char *ffunc;
- const char *sname, *fname;
+ char *ffunc, *flkey;
+ const char *sname, *fname, *ftkey;
int flang, ftype;
if (!query)
return 1;
- snprintf(query, qlen, "SELECT f.id, f.func, f.language, f.type, s.name,
f.name FROM sys.functions f, sys.schemas s WHERE f.schema_id = s.id AND f.id =
%s", fid);
+ snprintf(query, qlen, "SELECT f.id, f.func, f.language, f.type, s.name,
f.name, ft.function_type_keyword, fl.language_keyword FROM sys.functions f JOIN
sys.schemas s ON f.schema_id = s.id JOIN sys.function_types ft ON f.type =
ft.function_type_id LEFT OUTER JOIN sys.function_languages fl ON f.language =
fl.language_id WHERE f.id = %s", fid);
hdl = mapi_query(mid, query);
if (mapi_fetch_row(hdl) == 0) {
free(query);
@@ -1406,40 +1415,28 @@ dump_function(Mapi mid, stream *toConsol
ftype = atoi(mapi_fetch_field(hdl, 3));
sname = mapi_fetch_field(hdl, 4);
fname = mapi_fetch_field(hdl, 5);
+ ftkey = mapi_fetch_field(hdl, 6);
+ flkey = mapi_fetch_field(hdl, 7);
if (flang == 1 || flang == 2) {
- /* all information is stored in the func column */
+ /* all information is stored in the func column
+ * first skip initial comments and empty lines */
+ while ((ffunc[0] == '-' && ffunc[1] == '-') || ffunc[0] ==
'\n') {
+ ffunc = strchr(ffunc, '\n');
+ if (ffunc == NULL)
+ ffunc = "";
+ else
+ ffunc++;
+ }
mnstr_printf(toConsole, "%s\n", ffunc);
mapi_close_handle(hdl);
free(query);
return 0;
}
- mnstr_printf(toConsole, "CREATE ");
- switch (ftype) {
- case 1: /* scalar function */
- case 5: /* table returning function */
- mnstr_printf(toConsole, "FUNCTION");
- break;
- case 2:
- mnstr_printf(toConsole, "PROCEDURE");
- break;
- case 3:
- mnstr_printf(toConsole, "AGGREGATE");
- break;
- case 4:
- mnstr_printf(toConsole, "FILTER FUNCTION");
- break;
- case 7:
- mnstr_printf(toConsole, "LOADER");
- break;
- default:
- /* shouldn't happen (6 is F_ANALYTIC, but no syntax to
- * create, or values are not defined) */
- free(query);
- mapi_close_handle(hdl);
- return -1;
- }
+ /* strdup these two because they are needed after another query */
ffunc = strdup(ffunc);
- mnstr_printf(toConsole, " ");
+ if (flkey)
+ flkey = strdup(flkey);
+ mnstr_printf(toConsole, "CREATE %s ", ftkey);
quoted_print(toConsole, sname, false);
mnstr_printf(toConsole, ".");
quoted_print(toConsole, fname, false);
@@ -1488,38 +1485,9 @@ dump_function(Mapi mid, stream *toConsol
} while (mapi_fetch_row(hdl) != 0);
}
mapi_close_handle(hdl);
- mnstr_printf(toConsole, " LANGUAGE ");
- switch (flang) {
- case 3:
- mnstr_printf(toConsole, "R");
- break;
- case 4:
- mnstr_printf(toConsole, "C");
- break;
- case 5:
- mnstr_printf(toConsole, "J");
- break;
- case 6:
- mnstr_printf(toConsole, "PYTHON");
- break;
- case 7:
- mnstr_printf(toConsole, "PYTHON_MAP");
- break;
- case 8:
- mnstr_printf(toConsole, "PYTHON2");
- break;
- case 9:
- mnstr_printf(toConsole, "PYTHON2_MAP");
- break;
- case 10:
- mnstr_printf(toConsole, "PYTHON3");
- break;
- case 11:
- mnstr_printf(toConsole, "PYTHON3_MAP");
- break;
- default: /* unknown language */
- free(ffunc);
- return -1;
+ if (flkey) {
+ mnstr_printf(toConsole, " LANGUAGE %s", flkey);
+ free(flkey);
}
mnstr_printf(toConsole, "\n%s\n", ffunc);
free(ffunc);
diff --git a/clients/mapiclient/mclient.c b/clients/mapiclient/mclient.c
--- a/clients/mapiclient/mclient.c
+++ b/clients/mapiclient/mclient.c
@@ -2543,12 +2543,12 @@ doFile(Mapi mid, stream *fp, bool useins
"WITH
describe_all_objects AS (\n"
" SELECT s.name AS
sname,\n"
" t.name,\n"
- " s.name || \'.\'
|| t.name AS fullname,\n"
+ " s.name || '.' ||
t.name AS fullname,\n"
" CAST(CASE
t.type\n"
" WHEN 1 THEN 2 --
ntype for views\n"
" ELSE 1\t --
ntype for tables\n"
" END AS SMALLINT)
AS ntype,\n"
- " (CASE WHEN
t.system THEN \'SYSTEM \' ELSE \'\' END) || tt.table_type_name AS type,\n"
+ " (CASE WHEN
t.system THEN 'SYSTEM ' ELSE '' END) || tt.table_type_name AS type,\n"
" t.system,\n"
" c.remark AS
remark\n"
" FROM sys._tables
t\n"
@@ -2558,9 +2558,9 @@ doFile(Mapi mid, stream *fp, bool useins
" UNION ALL\n"
" SELECT s.name AS
sname,\n"
" sq.name,\n"
- " s.name || \'.\'
|| sq.name AS fullname,\n"
+ " s.name || '.' ||
sq.name AS fullname,\n"
" CAST(4 AS
SMALLINT) AS ntype,\n"
- " \'SEQUENCE\' AS
type,\n"
+ " 'SEQUENCE' AS
type,\n"
" false AS
system,\n"
" c.remark AS
remark\n"
" FROM sys.sequences
sq\n"
@@ -2569,9 +2569,9 @@ doFile(Mapi mid, stream *fp, bool useins
" UNION ALL\n"
" SELECT DISTINCT
s.name AS sname, -- DISTINCT is needed to filter out duplicate overloaded
function/procedure names\n"
" f.name,\n"
- " s.name || \'.\'
|| f.name AS fullname,\n"
+ " s.name || '.' ||
f.name AS fullname,\n"
" CAST(8 AS
SMALLINT) AS ntype,\n"
- " (CASE WHEN
sf.function_id IS NOT NULL THEN \'SYSTEM \' ELSE \'\' END) ||
function_type_keyword AS type,\n"
+ " (CASE WHEN
sf.function_id IS NOT NULL THEN 'SYSTEM ' ELSE '' END) || function_type_keyword
AS type,\n"
" sf.function_id
IS NOT NULL AS system,\n"
" c.remark AS
remark\n"
" FROM sys.functions
f\n"
@@ -2584,7 +2584,7 @@ doFile(Mapi mid, stream *fp, bool useins
" s.name,\n"
" s.name AS
fullname,\n"
" CAST(16 AS
SMALLINT) AS ntype,\n"
- " (CASE WHEN
s.system THEN \'SYSTEM SCHEMA\' ELSE \'SCHEMA\' END) AS type,\n"
+ " (CASE WHEN
s.system THEN 'SYSTEM SCHEMA' ELSE 'SCHEMA' END) AS type,\n"
" s.system,\n"
" c.remark AS
remark\n"
" FROM sys.schemas
s\n"
diff --git a/monetdb5/modules/mal/pcre.c b/monetdb5/modules/mal/pcre.c
--- a/monetdb5/modules/mal/pcre.c
+++ b/monetdb5/modules/mal/pcre.c
@@ -630,7 +630,7 @@ single_replace(pcre *pcre_code, pcre_ext
len = 0;
} else {
off = ovector[backrefs[i].idx * 2];
- len = ovector[backrefs[i].idx * 2 + 1]
- ovector[backrefs[i].idx * 2];
+ len = ovector[backrefs[i].idx * 2 + 1]
- off;
}
addlen = backrefs[i].start - prevend + len;
if (len_result + addlen >= *max_result) {
@@ -649,7 +649,7 @@ single_replace(pcre *pcre_code, pcre_ext
}
if (len > 0) {
strncpy(result + len_result, origin_str
+ off, len);
- len_result += off;
+ len_result += len;
}
prevend = backrefs[i].end;
}
diff --git a/sql/backends/monet5/UDF/pyapi/connection.c
b/sql/backends/monet5/UDF/pyapi/connection.c
--- a/sql/backends/monet5/UDF/pyapi/connection.c
+++ b/sql/backends/monet5/UDF/pyapi/connection.c
@@ -54,9 +54,9 @@ static PyObject *_connection_execute(Py_
PyObject *result;
res_table *output = NULL;
char *res = NULL;
-Py_BEGIN_ALLOW_THREADS;
+//Py_BEGIN_ALLOW_THREADS;
res = _connection_query(self->cntxt, query, &output);
-Py_END_ALLOW_THREADS;
+//Py_END_ALLOW_THREADS;
GDKfree(query);
if (res != MAL_SUCCEED) {
PyErr_Format(PyExc_Exception, "SQL Query Failed: %s",
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
@@ -277,6 +277,7 @@ sql_update_hugeint(Client c, mvc *sql)
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);
@@ -326,6 +327,7 @@ sql_update_geom(Client c, mvc *sql, int
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);
@@ -543,6 +545,7 @@ sql_update_dec2016(Client c, mvc *sql)
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);
@@ -591,6 +594,7 @@ sql_update_dec2016_sp2(Client c, mvc *sq
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);
@@ -624,6 +628,7 @@ sql_update_dec2016_sp3(Client c, mvc *sq
"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);
@@ -742,6 +747,7 @@ sql_update_jul2017(Client c, mvc *sql)
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);
@@ -786,6 +792,7 @@ sql_update_jul2017_sp2(Client c)
"GRANT EXECUTE ON FUNCTION sys.environment() TO
PUBLIC;\n"
"GRANT SELECT ON sys.environment TO PUBLIC;\n"
);
+ 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);
@@ -838,6 +845,7 @@ sql_update_jul2017_sp3(Client c, mvc *sq
"create trigger system_update_tables after update on
sys._tables for each statement call sys_update_tables();\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);
@@ -879,6 +887,7 @@ sql_update_mar2018_geom(Client c, mvc *s
if (schema)
pos += snprintf(buf + pos, bufsize - pos, "set schema
\"%s\";\n", schema);
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list