Changeset: 97bc391c7436 for MonetDB URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=97bc391c7436 Added Files: sql/test/BugTracker-2016/Tests/data3987.csv sql/test/BugTracker-2016/Tests/malformed-copy-int.Bug-3987.sql.in sql/test/BugTracker-2016/Tests/malformed-copy-int.Bug-3987.stable.err sql/test/BugTracker-2016/Tests/malformed-copy-int.Bug-3987.stable.out Modified Files: clients/Tests/SQL-dump.stable.out clients/Tests/SQL-dump.stable.out.int128 clients/Tests/exports.stable.out common/stream/stream.c gdk/gdk.h gdk/gdk_private.h java/ChangeLog.Jun2016 java/src/main/java/nl/cwi/monetdb/jdbc/MonetResultSet.java java/tests/Test_Rmetadata.java monetdb5/modules/mal/tablet.c monetdb5/optimizer/opt_reorder.c sql/backends/monet5/sql.c sql/backends/monet5/sql_execute.c sql/backends/monet5/sql_execute.h sql/backends/monet5/sql_scenario.c sql/backends/monet5/sql_scenario.h sql/include/sql_catalog.h sql/jdbc/tests/Tests/Test_Dobjects.stable.out sql/jdbc/tests/Tests/Test_Rmetadata.stable.out sql/scripts/75_storagemodel.sql sql/server/sql_mvc.h sql/server/sql_parser.y sql/server/sql_scan.c sql/storage/bat/bat_storage.c sql/test/BugTracker-2010/Tests/limit_in_prepare.Bug-2552.sql sql/test/BugTracker-2011/Tests/count-count-distinct.Bug-2808.sql sql/test/BugTracker-2012/Tests/aggregate_vs_positional_column_crash.Bug-3085.sql sql/test/BugTracker-2012/Tests/predicate_select.Bug-3090.sql sql/test/BugTracker-2012/Tests/predicate_select.Bug-3090.stable.out sql/test/BugTracker-2013/Tests/qualified_aggrname.Bug-3332.sql sql/test/BugTracker-2013/Tests/swapped_likejoin.Bug-3375.sql sql/test/BugTracker-2013/Tests/swapped_likejoin.Bug-3375.stable.out sql/test/BugTracker-2014/Tests/select-having.Bug-3458.sql sql/test/BugTracker-2015/Tests/cardinality.Bug-3761.sql sql/test/BugTracker-2016/Tests/DISTINCT_with_correlated_scalar_subquery_crashes_mserver.Bug-3920.sql sql/test/BugTracker-2016/Tests/storagemodel.Bug-3923.sql sql/test/BugTracker-2016/Tests/storagemodel.Bug-3923.stable.out sql/test/Tests/systemfunctions.stable.out sql/test/Tests/systemfunctions.stable.out.int128 sql/test/bugs/Tests/crash_order_by.sql sql/test/bugs/Tests/simple_view.sql sql/test/bugs/insert_delete-bug-sf-904025.sql sql/test/orderidx/Tests/simpletable.sql sql/test/orderidx/Tests/smalltable.sql sql/test/pg_regress/Tests/vacuum.sql sql/test/pg_regress/Tests/without_oid.sql tools/embedded/build-on-windows.bat tools/embedded/build-rpkg.sh tools/embedded/inlined_scripts.c tools/embedded/inlined_scripts.sh tools/embedded/rpackage/DESCRIPTION tools/embedded/rpackage/configure.win tools/embedded/windows/sedscript.tpl Branch: data-vaults Log Message:
Merge with default diffs (truncated from 4332 to 300 lines): diff --git a/clients/Tests/SQL-dump.stable.out b/clients/Tests/SQL-dump.stable.out --- a/clients/Tests/SQL-dump.stable.out +++ b/clients/Tests/SQL-dump.stable.out @@ -846,7 +846,7 @@ create view sys.sessions as select * fro create view sys."storage" as select * from sys."storage"(); create view sys.storagemodel as select * from sys.storagemodel(); SELECT "id", "name", "schema_id", "query", CAST(CASE WHEN "system" THEN "type" + 10 ELSE (CASE WHEN "commit_action" = 0 THEN "type" ELSE "type" + 20 END) END AS SMALLINT) AS "type", "system", "commit_action", "access", CASE WHEN (NOT "system" AND "commit_action" > 0) THEN 1 ELSE 0 END AS "temporary" FROM "sys"."_tables" WHERE "type" <> 2 UNION ALL SELECT "id", "name", "schema_id", "query", CAST("type" + 30 AS SMALLINT) AS "type", "system", "commit_action", "access", 1 AS "temporary" FROM "tmp"."_tables"; -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 auxiliary from sys.storagemodel() group by "schema","table"; +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 auxiliary from sys.storagemodel() group by "schema","table"; create view sys.tracelog as select * from sys.tracelog(); SELECT u."name" AS "name", ui."fullname", ui."default_schema" FROM db_users() AS u LEFT JOIN "sys"."db_user_info" AS ui ON u."name" = ui."name" ; create function "abbrev" (p inet) returns clob external name inet."abbrev"; @@ -1160,11 +1160,11 @@ create aggregate stddev_samp(val time) r create aggregate stddev_samp(val timestamp) returns double external name "aggr"."stdev"; create procedure sys.stop(tag int) external name sql.sysmon_stop; create procedure sys.stop(tag bigint) external name sql.sysmon_stop; -create function sys."storage"() returns table ("schema" string, "table" string, "column" string, "type" string, "mode" string, location string, "count" bigint, typewidth int, columnsize bigint, heapsize bigint, hashes bigint, phash boolean, imprints bigint, sorted boolean, orderidx bigint) external name sql."storage"; -create function sys."storage"(sname string) returns table ("schema" string, "table" string, "column" string, "type" string, "mode" string, location string, "count" bigint, typewidth int, columnsize bigint, heapsize bigint, hashes bigint, phash boolean, imprints bigint, sorted boolean, orderidx bigint) external name sql."storage"; -create function sys."storage"(sname string, tname string) returns table ("schema" string, "table" string, "column" string, "type" string, "mode" string, location string, "count" bigint, typewidth int, columnsize bigint, heapsize bigint, hashes bigint, phash boolean, imprints bigint, sorted boolean, orderidx bigint) external name sql."storage"; -create function sys."storage"(sname string, tname string, cname string) returns table ("schema" string, "table" string, "column" string, "type" string, "mode" string, location string, "count" bigint, typewidth int, columnsize bigint, heapsize bigint, hashes bigint, phash boolean, imprints bigint, sorted boolean, orderidx bigint) external name sql."storage"; -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, orderidx bigint) 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, i.orderidx from sys.storagemodelinput i; end; +create function sys."storage"() returns table ("schema" string, "table" string, "column" string, "type" string, "mode" string, location string, "count" bigint, typewidth int, columnsize bigint, heapsize bigint, hashes bigint, phash boolean, "imprints" bigint, sorted boolean, orderidx bigint) external name sql."storage"; +create function sys."storage"(sname string) returns table ("schema" string, "table" string, "column" string, "type" string, "mode" string, location string, "count" bigint, typewidth int, columnsize bigint, heapsize bigint, hashes bigint, phash boolean, "imprints" bigint, sorted boolean, orderidx bigint) external name sql."storage"; +create function sys."storage"(sname string, tname string) returns table ("schema" string, "table" string, "column" string, "type" string, "mode" string, location string, "count" bigint, typewidth int, columnsize bigint, heapsize bigint, hashes bigint, phash boolean, "imprints" bigint, sorted boolean, orderidx bigint) external name sql."storage"; +create function sys."storage"(sname string, tname string, cname string) returns table ("schema" string, "table" string, "column" string, "type" string, "mode" string, location string, "count" bigint, typewidth int, columnsize bigint, heapsize bigint, hashes bigint, phash boolean, "imprints" bigint, sorted boolean, orderidx bigint) external name sql."storage"; +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, orderidx bigint) 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, i.orderidx from sys.storagemodelinput i; end; create procedure sys.storagemodelinit() begin delete from sys.storagemodelinput; insert into sys.storagemodelinput 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; update sys.storagemodelinput set reference = true where concat(concat("schema","table"), "column") in (select concat(concat("fkschema"."name", "fktable"."name"), "fkkeycol"."name") from "sys"."keys" as "fkkey", "sys"."objects" as "fkkeycol", "sys"."tables" as "fktable", "sys"."schemas" as "fkschema" where "fktable"."id" = "fkkey"."table_id" and "fkkey"."id" = "fkkeycol"."id" and "fkschema"."id" = "fktable"."schema_id" and "fkkey"."rkey" > -1); update sys.storagemodelinput set "distinct" = "count" where "type" = 'varchar' or "type"='clob'; end; create function str_to_date(s string, format string) returns date external name mtime."str_to_date"; create function str_to_time(s string, format string) returns time external name mtime."str_to_time"; @@ -1349,7 +1349,7 @@ drop function pcre_replace(string, strin [ "sys", "systemfunctions", NULL, 0, true, 0, 0 ] [ "sys", "table_types", NULL, 0, true, 0, 0 ] [ "sys", "tables", "SELECT \"id\", \"name\", \"schema_id\", \"query\", CAST(CASE WHEN \"system\" THEN \"type\" + 10 /* system table/view */ ELSE (CASE WHEN \"commit_action\" = 0 THEN \"type\" /* table/view */ ELSE \"type\" + 20 /* global temp table */ END) END AS SMALLINT) AS \"type\", \"system\", \"commit_action\", \"access\", CASE WHEN (NOT \"system\" AND \"commit_action\" > 0) THEN 1 ELSE 0 END AS \"temporary\" FROM \"sys\".\"_tables\" WHERE \"type\" <> 2 UNION ALL SELECT \"id\", \"name\", \"schema_id\", \"query\", CAST(\"type\" + 30 /* local temp table */ AS SMALLINT) AS \"type\", \"system\", \"commit_action\", \"access\", 1 AS \"temporary\" FROM \"tmp\".\"_tables\";", 1, true, 0, 0 ] -[ "sys", "tablestoragemodel", "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 auxiliary from sys.storagemodel() group by \"schema\",\"table\";", 1, true, 0, 0 ] +[ "sys", "tablestoragemodel", "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 auxiliary from sys.storagemodel() group by \"schema\",\"table\";", 1, true, 0, 0 ] [ "sys", "tracelog", "create view sys.tracelog as select * from sys.tracelog();", 1, true, 0, 0 ] [ "sys", "triggers", NULL, 0, true, 0, 0 ] [ "sys", "types", NULL, 0, true, 0, 0 ] @@ -3289,11 +3289,11 @@ drop function pcre_replace(string, strin [ "sys", "stddev_samp", "create aggregate stddev_samp(val wrd) returns double external name \"aggr\".\"stdev\";", "aggr", 1, 3, false, false, false ] [ "sys", "stop", "create procedure sys.stop(tag bigint) external name sql.sysmon_stop;", "sql", 1, 2, true, false, false ] [ "sys", "stop", "create procedure sys.stop(tag int) external name sql.sysmon_stop;", "sql", 1, 2, true, false, false ] -[ "sys", "storage", "create function sys.\"storage\"() returns table (\"schema\" string, \"table\" string, \"column\" string, \"type\" string, \"mode\" string, location string, \"count\" bigint, typewidth int, columnsize bigint, heapsize bigint, hashes bigint, phash boolean, imprints bigint, sorted boolean, orderidx bigint) external name sql.\"storage\";", "sql", 1, 5, false, false, false ] -[ "sys", "storage", "create function sys.\"storage\"(sname string) returns table (\"schema\" string, \"table\" string, \"column\" string, \"type\" string, \"mode\" string, location string, \"count\" bigint, typewidth int, columnsize bigint, heapsize bigint, hashes bigint, phash boolean, imprints bigint, sorted boolean, orderidx bigint) external name sql.\"storage\";", "sql", 1, 5, false, false, false ] -[ "sys", "storage", "create function sys.\"storage\"(sname string, tname string) returns table (\"schema\" string, \"table\" string, \"column\" string, \"type\" string, \"mode\" string, location string, \"count\" bigint, typewidth int, columnsize bigint, heapsize bigint, hashes bigint, phash boolean, imprints bigint, sorted boolean, orderidx bigint) external name sql.\"storage\";", "sql", 1, 5, false, false, false ] -[ "sys", "storage", "create function sys.\"storage\"(sname string, tname string, cname string) returns table (\"schema\" string, \"table\" string, \"column\" string, \"type\" string, \"mode\" string, location string, \"count\" bigint, typewidth int, columnsize bigint, heapsize bigint, hashes bigint, phash boolean, imprints bigint, sorted boolean, orderidx bigint) external name sql.\"storage\";", "sql", 1, 5, false, false, false ] -[ "sys", "storagemodel", "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, orderidx bigint) 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, i.orderidx from sys.storagemodelinput i; end;", "user", 2, 5, false, false, false ] +[ "sys", "storage", "create function sys.\"storage\"() returns table (\"schema\" string, \"table\" string, \"column\" string, \"type\" string, \"mode\" string, location string, \"count\" bigint, typewidth int, columnsize bigint, heapsize bigint, hashes bigint, phash boolean, \"imprints\" bigint, sorted boolean, orderidx bigint) external name sql.\"storage\";", "sql", 1, 5, false, false, false ] +[ "sys", "storage", "create function sys.\"storage\"(sname string) returns table (\"schema\" string, \"table\" string, \"column\" string, \"type\" string, \"mode\" string, location string, \"count\" bigint, typewidth int, columnsize bigint, heapsize bigint, hashes bigint, phash boolean, \"imprints\" bigint, sorted boolean, orderidx bigint) external name sql.\"storage\";", "sql", 1, 5, false, false, false ] +[ "sys", "storage", "create function sys.\"storage\"(sname string, tname string) returns table (\"schema\" string, \"table\" string, \"column\" string, \"type\" string, \"mode\" string, location string, \"count\" bigint, typewidth int, columnsize bigint, heapsize bigint, hashes bigint, phash boolean, \"imprints\" bigint, sorted boolean, orderidx bigint) external name sql.\"storage\";", "sql", 1, 5, false, false, false ] +[ "sys", "storage", "create function sys.\"storage\"(sname string, tname string, cname string) returns table (\"schema\" string, \"table\" string, \"column\" string, \"type\" string, \"mode\" string, location string, \"count\" bigint, typewidth int, columnsize bigint, heapsize bigint, hashes bigint, phash boolean, \"imprints\" bigint, sorted boolean, orderidx bigint) external name sql.\"storage\";", "sql", 1, 5, false, false, false ] +[ "sys", "storagemodel", "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, orderidx bigint) 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, i.orderidx from sys.storagemodelinput i; end;", "user", 2, 5, false, false, false ] [ "sys", "storagemodelinit", "create procedure sys.storagemodelinit() begin delete from sys.storagemodelinput; insert into sys.storagemodelinput 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; update sys.storagemodelinput set reference = true where concat(concat(\"schema\",\"table\"), \"column\") in (select concat(concat(\"fkschema\".\"name\", \"fktable\".\"name\"), \"fkkeycol\".\"name\") from \"sys\".\"keys\" as \"fkkey\", \"sys\".\"objects\" as \"fkkeycol\", \"sys\".\"tables\" as \"fktable\", \"sys\".\"schemas\" as \"fkschema\" where \"fktable\".\"id\" = \"fkkey\".\"table_id\" and \"fkkey\".\"id\" = \"fkkeycol\".\"id\" and \"fkschema\".\"id\" = \"fktable\".\"schema_id\" and \"fkkey\".\"rkey\" > -1); update sys.storagemodelinput set \"distinct\" = \"count\" where \"type\" = 'varchar' or \"type\"='clob'; end;", "user", 2, 2, true, false, false ] [ "sys", "str_to_date", "create function str_to_date(s string, format string) returns date external name mtime.\"str_to_date\";", "mtime", 1, 1, false, false, false ] [ "sys", "str_to_time", "create function str_to_time(s string, format string) returns time external name mtime.\"str_to_time\";", "mtime", 1, 1, false, false, false ] diff --git a/clients/Tests/SQL-dump.stable.out.int128 b/clients/Tests/SQL-dump.stable.out.int128 --- a/clients/Tests/SQL-dump.stable.out.int128 +++ b/clients/Tests/SQL-dump.stable.out.int128 @@ -842,7 +842,7 @@ create view sys.sessions as select * fro create view sys."storage" as select * from sys."storage"(); create view sys.storagemodel as select * from sys.storagemodel(); SELECT "id", "name", "schema_id", "query", CAST(CASE WHEN "system" THEN "type" + 10 ELSE (CASE WHEN "commit_action" = 0 THEN "type" ELSE "type" + 20 END) END AS SMALLINT) AS "type", "system", "commit_action", "access", CASE WHEN (NOT "system" AND "commit_action" > 0) THEN 1 ELSE 0 END AS "temporary" FROM "sys"."_tables" WHERE "type" <> 2 UNION ALL SELECT "id", "name", "schema_id", "query", CAST("type" + 30 AS SMALLINT) AS "type", "system", "commit_action", "access", 1 AS "temporary" FROM "tmp"."_tables"; -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 auxiliary from sys.storagemodel() group by "schema","table"; +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 auxiliary from sys.storagemodel() group by "schema","table"; create view sys.tracelog as select * from sys.tracelog(); SELECT u."name" AS "name", ui."fullname", ui."default_schema" FROM db_users() AS u LEFT JOIN "sys"."db_user_info" AS ui ON u."name" = ui."name" ; create function "abbrev" (p inet) returns clob external name inet."abbrev"; @@ -1165,11 +1165,11 @@ create aggregate stddev_samp(val timesta create aggregate stddev_samp(val hugeint) returns double external name "aggr"."stdev"; create procedure sys.stop(tag int) external name sql.sysmon_stop; create procedure sys.stop(tag bigint) external name sql.sysmon_stop; -create function sys."storage"() returns table ("schema" string, "table" string, "column" string, "type" string, "mode" string, location string, "count" bigint, typewidth int, columnsize bigint, heapsize bigint, hashes bigint, phash boolean, imprints bigint, sorted boolean, orderidx bigint) external name sql."storage"; -create function sys."storage"(sname string) returns table ("schema" string, "table" string, "column" string, "type" string, "mode" string, location string, "count" bigint, typewidth int, columnsize bigint, heapsize bigint, hashes bigint, phash boolean, imprints bigint, sorted boolean, orderidx bigint) external name sql."storage"; -create function sys."storage"(sname string, tname string) returns table ("schema" string, "table" string, "column" string, "type" string, "mode" string, location string, "count" bigint, typewidth int, columnsize bigint, heapsize bigint, hashes bigint, phash boolean, imprints bigint, sorted boolean, orderidx bigint) external name sql."storage"; -create function sys."storage"(sname string, tname string, cname string) returns table ("schema" string, "table" string, "column" string, "type" string, "mode" string, location string, "count" bigint, typewidth int, columnsize bigint, heapsize bigint, hashes bigint, phash boolean, imprints bigint, sorted boolean, orderidx bigint) external name sql."storage"; -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, orderidx bigint) 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, i.orderidx from sys.storagemodelinput i; end; +create function sys."storage"() returns table ("schema" string, "table" string, "column" string, "type" string, "mode" string, location string, "count" bigint, typewidth int, columnsize bigint, heapsize bigint, hashes bigint, phash boolean, "imprints" bigint, sorted boolean, orderidx bigint) external name sql."storage"; +create function sys."storage"(sname string) returns table ("schema" string, "table" string, "column" string, "type" string, "mode" string, location string, "count" bigint, typewidth int, columnsize bigint, heapsize bigint, hashes bigint, phash boolean, "imprints" bigint, sorted boolean, orderidx bigint) external name sql."storage"; +create function sys."storage"(sname string, tname string) returns table ("schema" string, "table" string, "column" string, "type" string, "mode" string, location string, "count" bigint, typewidth int, columnsize bigint, heapsize bigint, hashes bigint, phash boolean, "imprints" bigint, sorted boolean, orderidx bigint) external name sql."storage"; +create function sys."storage"(sname string, tname string, cname string) returns table ("schema" string, "table" string, "column" string, "type" string, "mode" string, location string, "count" bigint, typewidth int, columnsize bigint, heapsize bigint, hashes bigint, phash boolean, "imprints" bigint, sorted boolean, orderidx bigint) external name sql."storage"; +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, orderidx bigint) 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, i.orderidx from sys.storagemodelinput i; end; create procedure sys.storagemodelinit() begin delete from sys.storagemodelinput; insert into sys.storagemodelinput 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; update sys.storagemodelinput set reference = true where concat(concat("schema","table"), "column") in (select concat(concat("fkschema"."name", "fktable"."name"), "fkkeycol"."name") from "sys"."keys" as "fkkey", "sys"."objects" as "fkkeycol", "sys"."tables" as "fktable", "sys"."schemas" as "fkschema" where "fktable"."id" = "fkkey"."table_id" and "fkkey"."id" = "fkkeycol"."id" and "fkschema"."id" = "fktable"."schema_id" and "fkkey"."rkey" > -1); update sys.storagemodelinput set "distinct" = "count" where "type" = 'varchar' or "type"='clob'; end; create function str_to_date(s string, format string) returns date external name mtime."str_to_date"; create function str_to_time(s string, format string) returns time external name mtime."str_to_time"; @@ -1356,7 +1356,7 @@ drop function pcre_replace(string, strin [ "sys", "systemfunctions", NULL, 0, true, 0, 0 ] [ "sys", "table_types", NULL, 0, true, 0, 0 ] [ "sys", "tables", "SELECT \"id\", \"name\", \"schema_id\", \"query\", CAST(CASE WHEN \"system\" THEN \"type\" + 10 /* system table/view */ ELSE (CASE WHEN \"commit_action\" = 0 THEN \"type\" /* table/view */ ELSE \"type\" + 20 /* global temp table */ END) END AS SMALLINT) AS \"type\", \"system\", \"commit_action\", \"access\", CASE WHEN (NOT \"system\" AND \"commit_action\" > 0) THEN 1 ELSE 0 END AS \"temporary\" FROM \"sys\".\"_tables\" WHERE \"type\" <> 2 UNION ALL SELECT \"id\", \"name\", \"schema_id\", \"query\", CAST(\"type\" + 30 /* local temp table */ AS SMALLINT) AS \"type\", \"system\", \"commit_action\", \"access\", 1 AS \"temporary\" FROM \"tmp\".\"_tables\";", 1, true, 0, 0 ] -[ "sys", "tablestoragemodel", "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 auxiliary from sys.storagemodel() group by \"schema\",\"table\";", 1, true, 0, 0 ] +[ "sys", "tablestoragemodel", "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 auxiliary from sys.storagemodel() group by \"schema\",\"table\";", 1, true, 0, 0 ] [ "sys", "tracelog", "create view sys.tracelog as select * from sys.tracelog();", 1, true, 0, 0 ] [ "sys", "triggers", NULL, 0, true, 0, 0 ] [ "sys", "types", NULL, 0, true, 0, 0 ] @@ -3480,11 +3480,11 @@ drop function pcre_replace(string, strin [ "sys", "stddev_samp", "create aggregate stddev_samp(val wrd) returns double external name \"aggr\".\"stdev\";", "aggr", 1, 3, false, false, false ] [ "sys", "stop", "create procedure sys.stop(tag bigint) external name sql.sysmon_stop;", "sql", 1, 2, true, false, false ] [ "sys", "stop", "create procedure sys.stop(tag int) external name sql.sysmon_stop;", "sql", 1, 2, true, false, false ] -[ "sys", "storage", "create function sys.\"storage\"() returns table (\"schema\" string, \"table\" string, \"column\" string, \"type\" string, \"mode\" string, location string, \"count\" bigint, typewidth int, columnsize bigint, heapsize bigint, hashes bigint, phash boolean, imprints bigint, sorted boolean, orderidx bigint) external name sql.\"storage\";", "sql", 1, 5, false, false, false ] -[ "sys", "storage", "create function sys.\"storage\"(sname string) returns table (\"schema\" string, \"table\" string, \"column\" string, \"type\" string, \"mode\" string, location string, \"count\" bigint, typewidth int, columnsize bigint, heapsize bigint, hashes bigint, phash boolean, imprints bigint, sorted boolean, orderidx bigint) external name sql.\"storage\";", "sql", 1, 5, false, false, false ] -[ "sys", "storage", "create function sys.\"storage\"(sname string, tname string) returns table (\"schema\" string, \"table\" string, \"column\" string, \"type\" string, \"mode\" string, location string, \"count\" bigint, typewidth int, columnsize bigint, heapsize bigint, hashes bigint, phash boolean, imprints bigint, sorted boolean, orderidx bigint) external name sql.\"storage\";", "sql", 1, 5, false, false, false ] -[ "sys", "storage", "create function sys.\"storage\"(sname string, tname string, cname string) returns table (\"schema\" string, \"table\" string, \"column\" string, \"type\" string, \"mode\" string, location string, \"count\" bigint, typewidth int, columnsize bigint, heapsize bigint, hashes bigint, phash boolean, imprints bigint, sorted boolean, orderidx bigint) external name sql.\"storage\";", "sql", 1, 5, false, false, false ] -[ "sys", "storagemodel", "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, orderidx bigint) 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, i.orderidx from sys.storagemodelinput i; end;", "user", 2, 5, false, false, false ] +[ "sys", "storage", "create function sys.\"storage\"() returns table (\"schema\" string, \"table\" string, \"column\" string, \"type\" string, \"mode\" string, location string, \"count\" bigint, typewidth int, columnsize bigint, heapsize bigint, hashes bigint, phash boolean, \"imprints\" bigint, sorted boolean, orderidx bigint) external name sql.\"storage\";", "sql", 1, 5, false, false, false ] +[ "sys", "storage", "create function sys.\"storage\"(sname string) returns table (\"schema\" string, \"table\" string, \"column\" string, \"type\" string, \"mode\" string, location string, \"count\" bigint, typewidth int, columnsize bigint, heapsize bigint, hashes bigint, phash boolean, \"imprints\" bigint, sorted boolean, orderidx bigint) external name sql.\"storage\";", "sql", 1, 5, false, false, false ] +[ "sys", "storage", "create function sys.\"storage\"(sname string, tname string) returns table (\"schema\" string, \"table\" string, \"column\" string, \"type\" string, \"mode\" string, location string, \"count\" bigint, typewidth int, columnsize bigint, heapsize bigint, hashes bigint, phash boolean, \"imprints\" bigint, sorted boolean, orderidx bigint) external name sql.\"storage\";", "sql", 1, 5, false, false, false ] +[ "sys", "storage", "create function sys.\"storage\"(sname string, tname string, cname string) returns table (\"schema\" string, \"table\" string, \"column\" string, \"type\" string, \"mode\" string, location string, \"count\" bigint, typewidth int, columnsize bigint, heapsize bigint, hashes bigint, phash boolean, \"imprints\" bigint, sorted boolean, orderidx bigint) external name sql.\"storage\";", "sql", 1, 5, false, false, false ] +[ "sys", "storagemodel", "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, orderidx bigint) 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, i.orderidx from sys.storagemodelinput i; end;", "user", 2, 5, false, false, false ] [ "sys", "storagemodelinit", "create procedure sys.storagemodelinit() begin delete from sys.storagemodelinput; insert into sys.storagemodelinput 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; update sys.storagemodelinput set reference = true where concat(concat(\"schema\",\"table\"), \"column\") in (select concat(concat(\"fkschema\".\"name\", \"fktable\".\"name\"), \"fkkeycol\".\"name\") from \"sys\".\"keys\" as \"fkkey\", \"sys\".\"objects\" as \"fkkeycol\", \"sys\".\"tables\" as \"fktable\", \"sys\".\"schemas\" as \"fkschema\" where \"fktable\".\"id\" = \"fkkey\".\"table_id\" and \"fkkey\".\"id\" = \"fkkeycol\".\"id\" and \"fkschema\".\"id\" = \"fktable\".\"schema_id\" and \"fkkey\".\"rkey\" > -1); update sys.storagemodelinput set \"distinct\" = \"count\" where \"type\" = 'varchar' or \"type\"='clob'; end;", "user", 2, 2, true, false, false ] [ "sys", "str_to_date", "create function str_to_date(s string, format string) returns date external name mtime.\"str_to_date\";", "mtime", 1, 1, false, false, false ] [ "sys", "str_to_time", "create function str_to_time(s string, format string) returns time external name mtime.\"str_to_time\";", "mtime", 1, 1, false, false, false ] diff --git a/clients/Tests/exports.stable.out b/clients/Tests/exports.stable.out --- a/clients/Tests/exports.stable.out +++ b/clients/Tests/exports.stable.out @@ -268,6 +268,7 @@ var_t HEAP_malloc(Heap *heap, size_t nby gdk_return HEAPextend(Heap *h, size_t size, int mayshare); size_t HEAPmemsize(Heap *h); size_t HEAPvmsize(Heap *h); +void IMPSdestroy(BAT *b); lng IMPSimprintsize(BAT *b); int MT_check_nr_cores(void); int MT_create_thread(MT_Id *t, void( *function)(void *), void *arg, enum MT_thr_detach d); @@ -1566,6 +1567,7 @@ int OPTmultiplexImplementation(Client cn str OPTmultiplexSimple(Client cntxt, MalBlkPtr mb); str OPTorcam(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr p); int OPTorcamImplementation(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr p); +int OPTpostfixImplementation(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr p); int OPTprofilerImplementation(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr p); int OPTprojectionpathImplementation(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr p); int OPTpushselectImplementation(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci); diff --git a/common/stream/stream.c b/common/stream/stream.c --- a/common/stream/stream.c +++ b/common/stream/stream.c @@ -128,7 +128,7 @@ #define UTF8BOM "\xEF\xBB\xBF" /* UTF-8 encoding of Unicode BOM */ #define UTF8BOMLENGTH 3 /* length of above */ -#ifdef WIN32 +#ifdef _MSC_VER /* use intrinsic functions on Windows */ #define short_int_SWAP(s) ((short) _byteswap_ushort((unsigned short) (s))) /* on Windows, long is the same size as int */ diff --git a/gdk/gdk.h b/gdk/gdk.h --- a/gdk/gdk.h +++ b/gdk/gdk.h @@ -2021,6 +2021,7 @@ gdk_export gdk_return BAThash(BAT *b, BU */ gdk_export gdk_return BATimprints(BAT *b); +gdk_export void IMPSdestroy(BAT *b); gdk_export lng IMPSimprintsize(BAT *b); /* The ordered index structure */ diff --git a/gdk/gdk_private.h b/gdk/gdk_private.h --- a/gdk/gdk_private.h +++ b/gdk/gdk_private.h @@ -169,8 +169,6 @@ void BBPdump(void); /* never called: fo __attribute__((__visibility__("hidden"))); __hidden int HEAPwarm(Heap *h) __attribute__((__visibility__("hidden"))); -__hidden void IMPSdestroy(BAT *b) - __attribute__((__visibility__("hidden"))); __hidden void IMPSfree(BAT *b) __attribute__((__visibility__("hidden"))); __hidden int IMPSgetbin(int tpe, bte bits, const char *restrict bins, const void *restrict v) diff --git a/java/ChangeLog.Jun2016 b/java/ChangeLog.Jun2016 --- a/java/ChangeLog.Jun2016 +++ b/java/ChangeLog.Jun2016 @@ -1,6 +1,10 @@ # ChangeLog file for java # This file is updated with Maddlog +* Thu Apr 21 2016 Martin van Dinther <martin.van.dint...@monetdbsolutions.com> +- Fixed resource leak in ResultSetMetaData. It created and cached a ResultSet + object for each column but never closed the ResultSet objects. + * Thu Mar 31 2016 Martin van Dinther <martin.van.dint...@monetdbsolutions.com> - Corrected DatabaseMetaData methods which accept a catalog filter argument. Those methods will now filter the results on the specified catalog name, diff --git a/java/src/main/java/nl/cwi/monetdb/jdbc/MonetResultSet.java b/java/src/main/java/nl/cwi/monetdb/jdbc/MonetResultSet.java --- a/java/src/main/java/nl/cwi/monetdb/jdbc/MonetResultSet.java +++ b/java/src/main/java/nl/cwi/monetdb/jdbc/MonetResultSet.java @@ -21,6 +21,7 @@ import java.net.URL; import java.sql.Array; import java.sql.Blob; import java.sql.Clob; +import java.sql.Connection; import java.sql.DatabaseMetaData; import java.sql.NClob; import java.sql.Ref; @@ -683,44 +684,43 @@ public class MonetResultSet extends Mone * @throws SQLException if there is no such column */ @Override - public boolean getBoolean(int columnIndex) throws SQLException{ - int dataType = getJavaType(types[columnIndex - 1]); - if (dataType == Types.TINYINT || - dataType == Types.SMALLINT || - dataType == Types.INTEGER || - dataType == Types.BIGINT) - { - if (getLong(columnIndex) == 0L) { - return false; - } else { + public boolean getBoolean(int columnIndex) throws SQLException { + switch (getJavaType(types[columnIndex - 1])) { + case Types.TINYINT: + case Types.SMALLINT: + case Types.INTEGER: + if (getInt(columnIndex) == 0) { + return false; + } return true; - } - } else if (dataType == Types.REAL || - dataType == Types.FLOAT || - dataType == Types.DOUBLE) - { - if (getDouble(columnIndex) == 0.0) { - return false; - } else { + case Types.BIGINT: + if (getLong(columnIndex) == 0L) { + return false; + } return true; - } - } else if (dataType == Types.DECIMAL || - dataType == Types.NUMERIC) - { - if (getBigDecimal(columnIndex).compareTo(new BigDecimal(0.0)) == 0) { - return false; - } else { + case Types.DOUBLE: + case Types.FLOAT: + case Types.REAL: + if (getDouble(columnIndex) == 0.0) { + return false; + } return true; - } - } else if (dataType == Types.BIT || - dataType == Types.BOOLEAN || - dataType == Types.CHAR || - dataType == Types.VARCHAR || - dataType == Types.LONGVARCHAR) - { - return (Boolean.valueOf(getString(columnIndex))).booleanValue(); - } else { - throw new SQLException("Conversion from " + types[columnIndex - 1] + " to boolean type not supported", "M1M05"); + case Types.DECIMAL: + case Types.NUMERIC: + if (getBigDecimal(columnIndex).compareTo(BigDecimal.ZERO) == 0) { + return false; + } + return true; + case Types.BOOLEAN: + case Types.BIT: // MonetDB doesn't use type BIT, it's here for completeness + case Types.CHAR: + case Types.VARCHAR: + case Types.LONGVARCHAR: // MonetDB doesn't use type LONGVARCHAR, it's here for completeness + case Types.CLOB: + // check if string value equals "true" (case insensitive) or not + return (Boolean.valueOf(getString(columnIndex))).booleanValue(); + default: + throw new SQLException("Conversion from " + types[columnIndex - 1] + " to boolean type not supported", "M1M05"); } } @@ -1082,11 +1082,63 @@ public class MonetResultSet extends Mone public ResultSetMetaData getMetaData() { // return inner class which implements the ResultSetMetaData interface return new rsmdw() { - // for the more expensive methods, we provide a simple cache - // for the most expensive part; getting the ResultSet which - // contains the data + // for the more expensive methods (getPrecision(), getScale(), isNullable()), we provide a simple cache + // caches to store precision, scale and isNullable values from getColumns() + private boolean[] _is_fetched = new boolean[columns.length +1]; + private int[] _precision = new int[columns.length +1]; + private int[] _scale = new int[columns.length +1]; + private int[] _isNullable = new int[columns.length +1]; + private Connection conn = null; private DatabaseMetaData dbmd = null; - private ResultSet[] colrs = new ResultSet[columns.length]; + + /** + * A private method to fetch the precision, scale and isNuallble value for a fully qualified column. + * As md.getColumns() is an expensive method we call it only once per column + * and cache the precision, scale and isNullable values in the above array chaches. + * Also we only call md.getColumns() when we have a non empty schema name and table name and column name. + */ + private void fetchColumnInfo(int column) throws SQLException + { + if (column <= 0 || column > columns.length) + throw new SQLException("No such column " + column, "M1M05"); + + _is_fetched[column] = true; + _precision[column] = 0; + _scale[column] = 0; + _isNullable[column] = columnNullableUnknown; _______________________________________________ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list