Changeset: 7159da221568 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=7159da221568
Modified Files:
        clients/mapiclient/dump.c
        clients/mapiclient/mclient.c
        clients/python2/monetdb/sql/monetize.py
        clients/python3/monetdb/sql/monetize.py
        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:

Merge with default.


diffs (truncated from 410 to 300 lines):

diff --git a/clients/python2/monetdb/sql/monetize.py 
b/clients/python2/monetdb/sql/monetize.py
--- a/clients/python2/monetdb/sql/monetize.py
+++ b/clients/python2/monetdb/sql/monetize.py
@@ -88,7 +88,7 @@ def convert(data):
     else:
         for type_, func in mapping:
             if issubclass(type(data), type_):
-                return func
+                return func(data)
         #if hasattr(data, '__str__'):
         #    return monet_escape
     raise ProgrammingError("type %s not supported as value" % type(data))
diff --git a/clients/python3/monetdb/sql/monetize.py 
b/clients/python3/monetdb/sql/monetize.py
--- a/clients/python3/monetdb/sql/monetize.py
+++ b/clients/python3/monetdb/sql/monetize.py
@@ -84,7 +84,7 @@ def convert(data):
     else:
         for type_, func in mapping:
             if issubclass(type(data), type_):
-                return func
+                return func(data)
         #if hasattr(data, '__str__'):
         #    return monet_escape
     raise ProgrammingError("type %s not supported as value" % type(data))
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
@@ -613,13 +613,8 @@ sql_update_jan2014(Client c)
        if (schvar)
                schema = strdup(schvar->val.sval);
 
-       
        pos += snprintf(buf + pos, bufsize - pos, "set schema \"sys\";\n");
 
-       /* remove table return types (#..), ie tt_generated from 
_tables/_columns */
-       pos += snprintf(buf + pos, bufsize - pos, "delete from _columns where 
table_id in (select id from _tables where name like '#%%');\n");
-       pos += snprintf(buf + pos, bufsize - pos, "delete from _tables where 
name like '#%%';\n");
-
        /* replaced 15_history.sql by 15_querylog.sql */
        pos += snprintf(buf + pos, bufsize - pos, "drop procedure 
sys.resetHistory;\n");
        pos += snprintf(buf + pos, bufsize - pos, "drop procedure 
sys.keepCall;\n");
@@ -853,8 +848,6 @@ sql_update_default(Client c)
        mvc *sql = ((backend*) c->sqlcontext)->mvc;
        ValRecord *schvar = stack_get_var(sql, "current_schema");
        char *schema = NULL;
-       char *fullname;
-       FILE *fp;
        sql_table *t;
        sql_schema *s;
 
@@ -863,19 +856,91 @@ sql_update_default(Client c)
 
        pos += snprintf(buf + pos, bufsize - pos, "set schema \"sys\";\n");
 
+       /* remove table return types (#..), ie tt_generated from
+        * _tables/_columns */
+       pos += snprintf(buf + pos, bufsize - pos, "delete from _columns where 
table_id in (select id from _tables where name like '#%%');\n");
+       pos += snprintf(buf + pos, bufsize - pos, "delete from _tables where 
name like '#%%';\n");
+
        /* change in 25_debug.sql */
        pos += snprintf(buf + pos, bufsize - pos, "drop function sys.bbp;\n");
        pos += snprintf(buf + pos, bufsize - pos, "create function sys.bbp() 
returns table (id int, name string, htype string, ttype string, count BIGINT, 
refcnt int, lrefcnt int, location string, heat int, dirty string, status 
string, kind string) external name bbp.get;\n");
 
        /* new file 40_json.sql */
-       snprintf(buf + pos, bufsize - pos, "createdb%c40_json", DIR_SEP);
-       if ((fullname = MSP_locate_sqlscript(buf + pos, 1)) != NULL) {
-               if ((fp = fopen(fullname, "r")) != NULL) {
-                       pos += fread(buf + pos, 1, bufsize - pos, fp);
-                       fclose(fp);
-               }
-               GDKfree(fullname);
-       }
+       pos += snprintf(buf + pos, bufsize - pos, "\
+create schema json;\n\
+\n\
+create type json external name json;\n\
+\n\
+create function json.filter(js json, pathexpr string)\n\
+returns json external name json.filter;\n\
+\n\
+create function json.filter(js json, name tinyint)\n\
+returns json external name json.filter;\n\
+\n\
+create function json.filter(js json, name integer)\n\
+returns json external name json.filter;\n\
+\n\
+create function json.filter(js json, name bigint)\n\
+returns json external name json.filter;\n\
+\n\
+create function json.text(js json, e string)\n\
+returns string external name json.text;\n\
+\n\
+create function json.number(js json)\n\
+returns float external name json.number;\n\
+\n\
+create function json.\"integer\"(js json)\n\
+returns bigint external name json.\"integer\";\n\
+\n\
+create function json.isvalid(js string)\n\
+returns bool external name json.isvalid;\n\
+\n\
+create function json.isobject(js string)\n\
+returns bool external name json.isobject;\n\
+\n\
+create function json.isarray(js string)\n\
+returns bool external name json.isarray;\n\
+\n\
+create function json.isvalid(js json)\n\
+returns bool external name json.isvalid;\n\
+\n\
+create function json.isobject(js json)\n\
+returns bool external name json.isobject;\n\
+\n\
+create function json.isarray(js json)\n\
+returns bool external name json.isarray;\n\
+\n\
+create function json.length(js json)\n\
+returns integer external name json.length;\n\
+\n\
+create function json.keyarray(js json)\n\
+returns json external name json.keyarray;\n\
+\n\
+create function json.valuearray(js json)\n\
+returns  json external name json.valuearray;\n\
+\n\
+create function json.text(js json)\n\
+returns string external name json.text;\n\
+create function json.text(js string)\n\
+returns string external name json.text;\n\
+create function json.text(js int)\n\
+returns string external name json.text;\n\
+\n\
+\n\
+create aggregate json.output(js json)\n\
+returns string external name json.output;\n\
+\n\
+create aggregate json.tojsonarray( x string ) returns string external name 
aggr.jsonaggr;\n\
+create aggregate json.tojsonarray( x double ) returns string external name 
aggr.jsonaggr;\n");
+
+       pos += snprintf(buf + pos, bufsize - pos,
+                       "update sys.schemas set system = true where name = 
'json';\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 ('filter', 'text', 'number', 
'integer', 'isvalid', 'isobject', 'isarray', 'length', 'keyarray', 
'valuearray') and f.type = %d and f.schema_id = s.id and s.name = 'json');\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 ('output', 'tojsonarray') and 
f.type = %d and f.schema_id = s.id and s.name = 'json');\n",
+                       F_AGGR);
 
        /* new file 41_jsonstore.sql */
        pos += snprintf(buf + pos, bufsize - pos, "create function sys.md5(v 
string) returns string external name clients.md5sum;\n");
@@ -885,15 +950,6 @@ sql_update_default(Client c)
        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);
-       }
-
        /* change to 75_storage functions */
        s = mvc_bind_schema(sql, "sys");
        if (s && (t = mvc_bind_table(sql, s, "storage")) != NULL)
@@ -940,6 +996,19 @@ sql_update_default(Client c)
        pos += snprintf(buf + pos, bufsize - pos, "create view sys.storagemodel 
as select * from sys.storagemodel();\n");
        pos += snprintf(buf + pos, bufsize - pos, "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 ('hashsize', 'imprintsize', 
'isauuid', 'md5', 'uuid') 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 ('bbp', 'storage', 
'storagemodel') and f.type = %d and f.schema_id = s.id and s.name = 'sys');\n",
+                       F_UNION);
+
+       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);
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
@@ -19,10 +19,105 @@ stdout of test 'upgrade` in directory 's
 # MonetDB/SQL module loaded
 
 Ready.
+Running database upgrade commands:
+set schema "sys";
+delete from _columns where table_id in (select id from _tables where name like 
'#%');
+delete from _tables where name like '#%';
+drop function sys.bbp;
+create function sys.bbp() returns table (id int, name string, htype string, 
ttype string, count BIGINT, refcnt int, lrefcnt int, location string, heat int, 
dirty string, status string, kind string) external name bbp.get;
+create schema json;
 
-# 09:28:56 >  
-# 09:28:56 >  "/usr/bin/python2" "upgrade.SQL.py" "upgrade"
-# 09:28:56 >  
+create type json external name json;
+
+create function json.filter(js json, pathexpr string)
+returns json external name json.filter;
+
+create function json.filter(js json, name tinyint)
+returns json external name json.filter;
+
+create function json.filter(js json, name integer)
+returns json external name json.filter;
+
+create function json.filter(js json, name bigint)
+returns json external name json.filter;
+
+create function json.text(js json, e string)
+returns string external name json.text;
+
+create function json.number(js json)
+returns float external name json.number;
+
+create function json."integer"(js json)
+returns bigint external name json."integer";
+
+create function json.isvalid(js string)
+returns bool external name json.isvalid;
+
+create function json.isobject(js string)
+returns bool external name json.isobject;
+
+create function json.isarray(js string)
+returns bool external name json.isarray;
+
+create function json.isvalid(js json)
+returns bool external name json.isvalid;
+
+create function json.isobject(js json)
+returns bool external name json.isobject;
+
+create function json.isarray(js json)
+returns bool external name json.isarray;
+
+create function json.length(js json)
+returns integer external name json.length;
+
+create function json.keyarray(js json)
+returns json external name json.keyarray;
+
+create function json.valuearray(js json)
+returns  json external name json.valuearray;
+
+create function json.text(js json)
+returns string external name json.text;
+create function json.text(js string)
+returns string external name json.text;
+create function json.text(js int)
+returns string external name json.text;
+
+
+create aggregate json.output(js json)
+returns string external name json.output;
+
+create aggregate json.tojsonarray( x string ) returns string external name 
aggr.jsonaggr;
+create aggregate json.tojsonarray( x double ) returns string external name 
aggr.jsonaggr;
+update sys.schemas set system = true where name = 'json';
+insert into sys.systemfunctions (select f.id from sys.functions f, sys.schemas 
s where f.name in ('filter', 'text', 'number', 'integer', 'isvalid', 
'isobject', 'isarray', 'length', 'keyarray', 'valuearray') and f.type = 1 and 
f.schema_id = s.id and s.name = 'json');
+insert into sys.systemfunctions (select f.id from sys.functions f, sys.schemas 
s where f.name in ('output', 'tojsonarray') and f.type = 3 and f.schema_id = 
s.id and s.name = 'json');
+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";
+update sys._tables set system = false where name in 
('storage','storagemodel','tablestoragemodel') and schema_id = (select id from 
sys.schemas where name = 'sys');
+drop view sys.storage;
+drop function sys.storage();
+drop view sys.storagemodel;
+drop view sys.tablestoragemodel;
+drop function sys.storagemodel();
+create function sys.storage() returns table ("schema" string, "table" string, 
"column" string, "type" string, location string, "count" bigint, typewidth int, 
columnsize bigint, heapsize bigint, hashes bigint, imprints bigint, sorted 
boolean) external name sql.storage;
+create view sys.storage as select * from sys.storage();
+create function sys.hashsize(b boolean, i bigint) returns bigint begin if  b = 
true then return 8 * i; end if; return 0; end;create function sys.imprintsize(i 
bigint, nme string) returns bigint begin if nme = 'boolean' or nme = 'tinyint' 
or nme = 'smallint' or nme = 'int'       or nme = 'bigint'       or nme = 
'decimal'      or nme = 'date' or nme = 'timestamp' or nme = 'real' or nme = 
'double' then return cast( i * 0.12 as bigint); end if ; return 0; end;create 
function sys.storagemodel() returns table (    "schema" string, "table" string, 
"column" string, "type" string, "count" bigint,    columnsize bigint, heapsize 
bigint, hashes bigint, imprints bigint, sorted boolean)      begin return 
select I."schema", I."table", I."column", I."type", I."count",             
columnsize(I."type", I.count, I."distinct"),            heapsize(I."type", 
I."distinct", I."atomwidth"),                hashsize(I."reference", 
I."count"),             imprintsize(I."count",I."type"),                
I.sorted                from sys.storagemodelinput I;   end;
+create view sys.tablestoragemodel as select "schema","table",max(count) as 
"count",    sum(columnsize) as columnsize,    sum(heapsize) as heapsize,    
sum(hashes) as hashes,    sum(imprints) as imprints,    sum(case when sorted = 
false then 8 * count else 0 end) as auxillary from sys.storagemodel() group by 
"schema","table";
+create view sys.storagemodel as select * from sys.storagemodel();
+update sys._tables set system = true where name in 
('storage','storagemodel','tablestoragemodel') and schema_id = (select id from 
sys.schemas where name = 'sys');
+insert into sys.systemfunctions (select f.id from sys.functions f, sys.schemas 
s where f.name in ('hashsize', 'imprintsize', 'isauuid', 'md5', '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 ('bbp', 'storage', 'storagemodel') and f.type = 5 and 
f.schema_id = s.id and s.name = 'sys');
+set schema "testschema";
+
+#Interpreting bte as bit.
+
+# 15:12:32 >  
+# 15:12:32 >  "/usr/bin/python2" "upgrade.SQL.py" "upgrade"
+# 15:12:32 >  
 
 #select count(*) from testschema.smallstring;
 % testschema.L1 # table_name
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
_______________________________________________
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to