Changeset: ab1c7a9bdeb7 for MonetDB URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=ab1c7a9bdeb7 Added Files: sql/test/BugTracker-2017/Tests/crash_correlated_subqueries_in_select.Bug-6254.sql sql/test/BugTracker-2017/Tests/crash_correlated_subqueries_in_select.Bug-6254.stable.err sql/test/BugTracker-2017/Tests/crash_correlated_subqueries_in_select.Bug-6254.stable.out Modified Files: geom/monetdb5/geom.mal sql/server/rel_optimizer.c sql/test/BugTracker-2017/Tests/All sql/test/orderidx/Tests/oidx_all_types.sql sql/test/orderidx/Tests/oidx_all_types.stable.out Branch: data-vaults Log Message:
Merge with default diffs (278 lines): diff --git a/geom/monetdb5/geom.mal b/geom/monetdb5/geom.mal --- a/geom/monetdb5/geom.mal +++ b/geom/monetdb5/geom.mal @@ -666,11 +666,11 @@ comment "Returns the number of geometrie command NumRings(w:bat[:wkb], exterior:int) :bat[:int] address wkbNumRings_bat comment "Returns the number of interior rings+exterior on the first polygon of the geometry"; function NumInteriorRings(w:bat[:wkb]) :bat[:int]; - x := geom.NumRings(w, 0); + x := batgeom.NumRings(w, 0); return x; end NumInteriorRings; function NRings(w:bat[:wkb]) :bat[:int]; - x := geom.NumRings(w, 1); + x := batgeom.NumRings(w, 1); return x; end NRings; diff --git a/sql/server/rel_optimizer.c b/sql/server/rel_optimizer.c --- a/sql/server/rel_optimizer.c +++ b/sql/server/rel_optimizer.c @@ -8149,7 +8149,8 @@ rel_find_conflicts(mvc *sql, sql_rel *re case op_project: if (rel->l) exps_find_conflicts(sql, rel->exps, exps, conflicts); - rel->l = rel_find_conflicts(sql, rel->l, exps, conflicts); + if (rel->l && rel_uses_exps(rel->l, exps)) + rel->l = rel_find_conflicts(sql, rel->l, exps, conflicts); /* if project produces given names, then we have a conflict */ if (rel->l) exps_mark_conflicts(sql, rel->exps, conflicts, 0); @@ -8173,7 +8174,7 @@ rel_find_conflicts(mvc *sql, sql_rel *re case op_union: case op_inter: - case op_except: + case op_except: exps_find_conflicts(sql, rel->exps, exps, conflicts); rel->l = rel_find_conflicts(sql, rel->l, exps, conflicts); if (!is_semi(rel->op)) @@ -8358,7 +8359,7 @@ rel_apply_rewrite(int *changes, mvc *sql return l; } } - if (rel->flag == APPLY_LOJ && (r->op == op_select || is_join(r->op))) { + if (rel->flag == APPLY_LOJ && ((r->op == op_select && exps_uses_exps(r->exps, rel->exps)) || is_join(r->op))) { sql_rel *nr, *ns; nr = rel_project(sql->sa, rel_dup(r), diff --git a/sql/test/BugTracker-2017/Tests/All b/sql/test/BugTracker-2017/Tests/All --- a/sql/test/BugTracker-2017/Tests/All +++ b/sql/test/BugTracker-2017/Tests/All @@ -39,3 +39,4 @@ modulo.Bug-6225 one-plus-nil.Bug-6243 with-alias-bug.6246 crash_after_oidx_on_sys_statistics.Bug-6251 +crash_correlated_subqueries_in_select.Bug-6254 diff --git a/sql/test/BugTracker-2017/Tests/crash_correlated_subqueries_in_select.Bug-6254.sql b/sql/test/BugTracker-2017/Tests/crash_correlated_subqueries_in_select.Bug-6254.sql new file mode 100644 --- /dev/null +++ b/sql/test/BugTracker-2017/Tests/crash_correlated_subqueries_in_select.Bug-6254.sql @@ -0,0 +1,16 @@ +CREATE VIEW sys.view_stats AS +SELECT s.name AS schema_nm, s.id AS schema_id, t.name AS table_nm, t.id AS table_id, t.system AS is_system_view +, (SELECT CAST(COUNT(*) as int) FROM sys.columns c WHERE c.table_id = t.id) AS "# columns" + FROM sys.tables t JOIN sys.schemas s ON t.schema_id = s.id +WHERE query IS NOT NULL +; --ORDER BY s.name, t.name; + +SELECT * FROM sys.view_stats; +-- prints worrying output in console +SELECT * FROM sys.view_stats WHERE is_system_view; +-- crash +SELECT * FROM sys.view_stats WHERE NOT is_system_view; +-- crash + +DROP VIEW sys.view_stats; + diff --git a/sql/test/BugTracker-2017/Tests/crash_correlated_subqueries_in_select.Bug-6254.stable.err b/sql/test/BugTracker-2017/Tests/crash_correlated_subqueries_in_select.Bug-6254.stable.err new file mode 100644 --- /dev/null +++ b/sql/test/BugTracker-2017/Tests/crash_correlated_subqueries_in_select.Bug-6254.stable.err @@ -0,0 +1,36 @@ +stderr of test 'crash_correlated_subqueries_in_select.Bug-6254` in directory 'sql/test/BugTracker-2017` itself: + + +# 14:28:48 > +# 14:28:48 > "mserver5" "--debug=10" "--set" "gdk_nr_threads=0" "--set" "mapi_open=true" "--set" "mapi_port=33692" "--set" "mapi_usock=/var/tmp/mtest-6451/.s.monetdb.33692" "--set" "monet_prompt=" "--forcemito" "--dbpath=/export/scratch2/dinther/INSTALL/var/MonetDB/mTests_sql_test_BugTracker-2017" "--set" "embedded_r=yes" "--set" "embedded_py=true" +# 14:28:48 > + +# builtin opt gdk_dbpath = /export/scratch2/dinther/INSTALL/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 = 33692 +# cmdline opt mapi_usock = /var/tmp/mtest-6451/.s.monetdb.33692 +# cmdline opt monet_prompt = +# cmdline opt gdk_dbpath = /export/scratch2/dinther/INSTALL/var/MonetDB/mTests_sql_test_BugTracker-2017 +# cmdline opt embedded_r = yes +# cmdline opt embedded_py = true +# cmdline opt gdk_debug = 536870922 + +# 14:28:48 > +# 14:28:48 > "mclient" "-lsql" "-ftest" "-Eutf-8" "-i" "-e" "--host=/var/tmp/mtest-6451" "--port=33692" +# 14:28:48 > + + +# 14:28:49 > +# 14:28:49 > "Done." +# 14:28:49 > + diff --git a/sql/test/BugTracker-2017/Tests/crash_correlated_subqueries_in_select.Bug-6254.stable.out b/sql/test/BugTracker-2017/Tests/crash_correlated_subqueries_in_select.Bug-6254.stable.out new file mode 100644 --- /dev/null +++ b/sql/test/BugTracker-2017/Tests/crash_correlated_subqueries_in_select.Bug-6254.stable.out @@ -0,0 +1,90 @@ +stdout of test 'crash_correlated_subqueries_in_select.Bug-6254` in directory 'sql/test/BugTracker-2017` itself: + + +# 14:28:48 > +# 14:28:48 > "mserver5" "--debug=10" "--set" "gdk_nr_threads=0" "--set" "mapi_open=true" "--set" "mapi_port=33692" "--set" "mapi_usock=/var/tmp/mtest-6451/.s.monetdb.33692" "--set" "monet_prompt=" "--forcemito" "--dbpath=/export/scratch2/dinther/INSTALL/var/MonetDB/mTests_sql_test_BugTracker-2017" "--set" "embedded_r=yes" "--set" "embedded_py=true" +# 14:28:48 > + +# MonetDB 5 server v11.25.14 +# This is an unreleased version +# Serving database 'mTests_sql_test_BugTracker-2017', using 8 threads +# Compiled for x86_64-unknown-linux-gnu/64bit with 128bit integers +# Found 15.589 GiB available main-memory. +# Copyright (c) 1993-July 2008 CWI. +# Copyright (c) August 2008-2017 MonetDB B.V., all rights reserved +# Visit http://www.monetdb.org/ for further information +# Listening for connection requests on mapi:monetdb://toulouse.da.cwi.nl:33692/ +# Listening for UNIX domain connection requests on mapi:monetdb:///var/tmp/mtest-6451/.s.monetdb.33692 +# MonetDB/GIS module loaded +# MonetDB/SQL module loaded +# MonetDB/Python module loaded +# MonetDB/R module loaded + +Ready. +# SQL catalog created, loading sql scripts once + +# 10:01:40 > +# 10:01:40 > "mclient" "-lsql" "-ftest" "-Eutf-8" "-i" "-e" "--host=/var/tmp/mtest-24581" "--port=30412" +# 10:01:40 > + +#CREATE VIEW sys.view_stats AS +#SELECT s.name AS schema_nm, s.id AS schema_id, t.name AS table_nm, t.id AS table_id, t.system AS is_system_view +#, (SELECT CAST(COUNT(*) as int) FROM sys.columns c WHERE c.table_id = t.id) AS "# columns" +# FROM sys.tables t JOIN sys.schemas s ON t.schema_id = s.id +#WHERE query IS NOT NULL +#; --ORDER BY s.name, t.name; +#SELECT * FROM sys.view_stats; +% .view_stats, .view_stats, .view_stats, .view_stats, .view_stats, .view_stats # table_name +% schema_nm, schema_id, table_nm, table_id, is_system_view, "# columns" # name +% varchar, int, varchar, int, boolean, int # type +% 3, 4, 17, 4, 5, 2 # length +[ "sys", 2000, "tables", 5956, true, 9 ] +[ "sys", 2000, "columns", 5966, true, 10 ] +[ "sys", 2000, "users", 5988, true, 3 ] +[ "sys", 2000, "querylog_catalog", 6221, true, 8 ] +[ "sys", 2000, "querylog_calls", 6232, true, 9 ] +[ "sys", 2000, "querylog_history", 6250, true, 16 ] +[ "sys", 2000, "tracelog", 6289, true, 13 ] +[ "sys", 2000, "sessions", 6432, true, 6 ] +[ "sys", 2000, "optimizers", 6499, true, 3 ] +[ "sys", 2000, "environment", 6507, true, 2 ] +[ "sys", 2000, "queue", 6557, true, 8 ] +[ "sys", 2000, "rejects", 6587, true, 4 ] +[ "sys", 2000, "geometry_columns", 6914, true, 7 ] +[ "sys", 2000, "storage", 7743, true, 17 ] +[ "sys", 2000, "storagemodel", 7875, true, 13 ] +[ "sys", 2000, "tablestoragemodel", 7885, true, 8 ] +[ "sys", 2000, "view_stats", 8548, false, 6 ] +#SELECT * FROM sys.view_stats WHERE is_system_view; +% .view_stats, .view_stats, .view_stats, .view_stats, .view_stats, .view_stats # table_name +% schema_nm, schema_id, table_nm, table_id, is_system_view, "# columns" # name +% varchar, int, varchar, int, boolean, int # type +% 3, 4, 17, 4, 5, 2 # length +[ "sys", 2000, "tables", 5956, true, 9 ] +[ "sys", 2000, "columns", 5966, true, 10 ] +[ "sys", 2000, "users", 5988, true, 3 ] +[ "sys", 2000, "querylog_catalog", 6221, true, 8 ] +[ "sys", 2000, "querylog_calls", 6232, true, 9 ] +[ "sys", 2000, "querylog_history", 6250, true, 16 ] +[ "sys", 2000, "tracelog", 6289, true, 13 ] +[ "sys", 2000, "sessions", 6432, true, 6 ] +[ "sys", 2000, "optimizers", 6499, true, 3 ] +[ "sys", 2000, "environment", 6507, true, 2 ] +[ "sys", 2000, "queue", 6557, true, 8 ] +[ "sys", 2000, "rejects", 6587, true, 4 ] +[ "sys", 2000, "geometry_columns", 6914, true, 7 ] +[ "sys", 2000, "storage", 7743, true, 17 ] +[ "sys", 2000, "storagemodel", 7875, true, 13 ] +[ "sys", 2000, "tablestoragemodel", 7885, true, 8 ] +#SELECT * FROM sys.view_stats WHERE NOT is_system_view; +% .view_stats, .view_stats, .view_stats, .view_stats, .view_stats, .view_stats # table_name +% schema_nm, schema_id, table_nm, table_id, is_system_view, "# columns" # name +% varchar, int, varchar, int, boolean, int # type +% 3, 4, 10, 4, 5, 1 # length +[ "sys", 2000, "view_stats", 8548, false, 6 ] +#DROP VIEW sys.view_stats; + +# 10:01:40 > +# 10:01:40 > "Done." +# 10:01:40 > + diff --git a/sql/test/orderidx/Tests/oidx_all_types.sql b/sql/test/orderidx/Tests/oidx_all_types.sql --- a/sql/test/orderidx/Tests/oidx_all_types.sql +++ b/sql/test/orderidx/Tests/oidx_all_types.sql @@ -1,3 +1,5 @@ +SET TIME ZONE INTERVAL '+01:00' HOUR TO MINUTE; + -- first create a table for all basic data types and fill it with some data rows (including duplicate rows) create table all_types ( "boolean" boolean, diff --git a/sql/test/orderidx/Tests/oidx_all_types.stable.out b/sql/test/orderidx/Tests/oidx_all_types.stable.out --- a/sql/test/orderidx/Tests/oidx_all_types.stable.out +++ b/sql/test/orderidx/Tests/oidx_all_types.stable.out @@ -66,6 +66,7 @@ Ready. # 15:05:54 > "mclient" "-lsql" "-ftest" "-Eutf-8" "-i" "-e" "--host=/var/tmp/mtest-13546" "--port=31953" # 15:05:54 > +#SET TIME ZONE INTERVAL '+01:00' HOUR TO MINUTE; #create table all_types ( # "boolean" boolean, # "tinyint" tinyint, @@ -597,8 +598,8 @@ Ready. % blob # type % 0 # length [ 123456 ] +[ 123456 ] [ 01234567 ] -[ 123456 ] [ 01234567 ] #select "blob100" from all_types order by "blob100" ASC; % sys.all_types # table_name @@ -606,8 +607,8 @@ Ready. % blob # type % 0 # length [ 123456 ] +[ 123456 ] [ 01234567 ] -[ 123456 ] [ 01234567 ] #select "clob" from all_types order by "clob" ASC; % sys.all_types # table_name @@ -1086,6 +1087,24 @@ Ready. [ 08:30:00.00000+01:00 ] [ 07:30:00.00000+01:00 ] [ 07:30:00.00000+01:00 ] +#select "blob" from all_types order by "blob" DESC; +% sys.all_types # table_name +% blob # name +% blob # type +% 0 # length +[ 01234567 ] +[ 01234567 ] +[ 123456 ] +[ 123456 ] +#select "blob100" from all_types order by "blob100" DESC; +% sys.all_types # table_name +% blob100 # name +% blob # type +% 0 # length +[ 01234567 ] +[ 01234567 ] +[ 123456 ] +[ 123456 ] #select "clob" from all_types order by "clob" DESC; % sys.all_types # table_name % clob # name _______________________________________________ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list