Changeset: fd93e342de41 for MonetDB URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=fd93e342de41 Added Files: sql/jdbc/tests/Tests/Test_CisValid.stable.err sql/jdbc/tests/Tests/Test_CisValid.stable.out sql/test/BugTracker-2016/Tests/rename_exps.Bug-3974.stable.out.32bit Modified Files: NT/monetdb_config.h.in clients/R/MonetDB.R/R/dbi.R monetdb5/extras/mal_optimizer_template/Tests/opt_sql_append.stable.out.Windows monetdb5/extras/mal_optimizer_template/Tests/opt_sql_append.stable.out.Windows.single monetdb5/mal/mal_runtime.c monetdb5/optimizer/opt_constants.c sql/backends/monet5/sql_upgrades.c sql/server/sql_parser.y sql/storage/store.c sql/test/BugTracker-2013/Tests/binary_copy_into.Bug-3345.SQL.py sql/test/BugTracker-2016/Tests/decimal_vs_integer.Bug-3941.stable.out.32bit 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 testing/Mtest.py.in Branch: jit Log Message:
Merge with default diffs (truncated from 118399 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/clients/R/MonetDB.R/R/dbi.R b/clients/R/MonetDB.R/R/dbi.R --- a/clients/R/MonetDB.R/R/dbi.R +++ b/clients/R/MonetDB.R/R/dbi.R @@ -524,7 +524,7 @@ setMethod("dbWriteTable", signature(conn if (csvdump) { tmp <- tempfile(fileext = ".csv") write.table(value, tmp, sep = ",", quote = TRUE, row.names = FALSE, col.names = FALSE, na="", fileEncoding = "UTF-8") - dbSendQuery(conn, paste0("COPY INTO ", qname, " FROM '", tmp, "' USING DELIMITERS ',','\\n','\"' NULL AS ''")) + dbSendQuery(conn, paste0("COPY INTO ", qname, " FROM '", encodeString(tmp), "' USING DELIMITERS ',','\\n','\"' NULL AS ''")) file.remove(tmp) } else { vins <- paste("(", paste(rep("?", length(value)), collapse=', '), ")", sep='') @@ -924,7 +924,7 @@ monet.read.csv <- monetdb.read.csv <- fu delimspec <- paste0("USING DELIMITERS '", delim, "','", newline, "','", quote, "'") for(i in seq_along(files)) { - thefile <- normalizePath(files[i]) + thefile <- encodeString(normalizePath(files[i])) dbSendUpdate(conn, paste("COPY", if(header) "OFFSET 2", "INTO", tablename, "FROM", paste("'", thefile, "'", sep=""), delimspec, "NULL as", paste("'", na.strings[1], "'", sep=""), if(locked) "LOCKED", if(best.effort) "BEST EFFORT")) diff --git a/monetdb5/extras/mal_optimizer_template/Tests/opt_sql_append.stable.out.Windows.single b/monetdb5/extras/mal_optimizer_template/Tests/opt_sql_append.stable.out.Windows.single --- a/monetdb5/extras/mal_optimizer_template/Tests/opt_sql_append.stable.out.Windows.single +++ b/monetdb5/extras/mal_optimizer_template/Tests/opt_sql_append.stable.out.Windows.single @@ -56,7 +56,7 @@ Ready. % def # name % clob # type % 449 # length -[ "optimizer.inline();optimizer.remap();optimizer.costModel();optimizer.coercions();optimizer.evaluate();optimizer.aliases();optimizer.pushselect();optimizer.mitosis();optimizer.mergetable();optimizer.deadcode();optimizer.commonTerms();optimizer.joinPath();optimizer.reorder();optimizer.deadcode();optimizer.reduce();optimizer.matpack();optimizer.dataflow();optimizer.querylog();optimizer.multiplex();optimizer.generator();optimizer.garbageCollector();" ] +[ "optimizer.inline();optimizer.remap();optimizer.costModel();optimizer.coercions();optimizer.evaluate();optimizer.pushselect();optimizer.aliases();optimizer.mitosis();optimizer.mergetable();optimizer.deadcode();optimizer.commonTerms();optimizer.joinPath();optimizer.reorder();optimizer.deadcode();optimizer.reduce();optimizer.matpack();optimizer.dataflow();optimizer.querylog();optimizer.multiplex();optimizer.generator();optimizer.garbageCollector();" ] #explain copy into ttt from 'a:\tmp/xyz'; % .explain # table_name % mal # name @@ -88,7 +88,7 @@ end user.s4_1; % def # name % clob # type % 472 # length -[ "optimizer.inline();optimizer.remap();optimizer.costModel();optimizer.coercions();optimizer.evaluate();optimizer.aliases();optimizer.pushselect();optimizer.mitosis();optimizer.mergetable();optimizer.deadcode();optimizer.commonTerms();optimizer.joinPath();optimizer.reorder();optimizer.deadcode();optimizer.reduce();optimizer.matpack();optimizer.dataflow();optimizer.querylog();optimizer.multiplex();optimizer.generator();optimizer.sql_append();optimizer.garbageCollector();" ] +[ "optimizer.inline();optimizer.remap();optimizer.costModel();optimizer.coercions();optimizer.evaluate();optimizer.pushselect();optimizer.aliases();optimizer.mitosis();optimizer.mergetable();optimizer.deadcode();optimizer.commonTerms();optimizer.joinPath();optimizer.reorder();optimizer.deadcode();optimizer.reduce();optimizer.matpack();optimizer.dataflow();optimizer.querylog();optimizer.multiplex();optimizer.generator();optimizer.sql_append();optimizer.garbageCollector();" ] #explain copy into ttt from 'Z:/tmp/xyz'; % .explain # table_name % mal # name diff --git a/monetdb5/mal/mal_runtime.c b/monetdb5/mal/mal_runtime.c --- a/monetdb5/mal/mal_runtime.c +++ b/monetdb5/mal/mal_runtime.c @@ -229,9 +229,11 @@ getBatSpace(BAT *b){ if( b == NULL) return 0; space += BATcount(b) * b->T->width; - if( b->T->vheap) space += heapinfo(b->T->vheap, abs(b->batCacheid)); - if(b->T) space += hashinfo(b->T->hash, abs(b->batCacheid)); - space += IMPSimprintsize(b); + if( space){ + if( b->T->vheap) space += heapinfo(b->T->vheap, abs(b->batCacheid)); + if( b->T) space += hashinfo(b->T->hash, abs(b->batCacheid)); + space += IMPSimprintsize(b); + } return space; } diff --git a/monetdb5/optimizer/opt_constants.c b/monetdb5/optimizer/opt_constants.c --- a/monetdb5/optimizer/opt_constants.c +++ b/monetdb5/optimizer/opt_constants.c @@ -9,8 +9,7 @@ /* * Constant Duplicate Removal * The compilers may generate an abundance of constants on - * the stack. This simple optimizer re-organizes performs a complete - * job to use constants only once. + * the stack. This simple optimizer merges them into a single reference. * This makes it easier to search for statement duplicates * and alias their variables. */ @@ -79,11 +78,12 @@ OPTconstantsImplementation(Client cntxt, } } - for (i = 0; i < mb->stop; i++){ - p= getInstrPtr(mb,i); - for (k=0; k < p->argc; k++) - getArg(p,k) = alias[getArg(p,k)]; - } + if( actions) + for (i = 0; i < mb->stop; i++){ + p= getInstrPtr(mb,i); + for (k=0; k < p->argc; k++) + getArg(p,k) = alias[getArg(p,k)]; + } GDKfree(alias); GDKfree(cst); GDKfree(index); 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); _______________________________________________ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list