Changeset: 150bd238b590 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=150bd238b590
Added Files:
        sql/test/BugTracker-2017/Tests/crash_in_null_cast.Bug-6186.sql
        sql/test/BugTracker-2017/Tests/crash_in_null_cast.Bug-6186.stable.err
        sql/test/BugTracker-2017/Tests/crash_in_null_cast.Bug-6186.stable.out
Modified Files:
        sql/server/rel_optimizer.c
        sql/test/BugTracker-2017/Tests/All
Branch: Dec2016
Log Message:

fixed bug 6186, preperly rename apply operators


diffs (204 lines):

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
@@ -7926,8 +7926,6 @@ exp_apply_rename(mvc *sql, sql_exp *e, l
                        ne = exp_op(sql->sa, nl, e->f);
                else 
                        ne = exp_aggr(sql->sa, nl, e->f, need_distinct(e), 
need_no_nil(e), e->card, has_nil(e));
-               if (e && e->rname)
-                       exp_setname(sql->sa, ne, e->rname, e->name);
                break;
        }       
        case e_atom:
@@ -7936,6 +7934,8 @@ exp_apply_rename(mvc *sql, sql_exp *e, l
        }
        if (ne && e->p)
                ne->p = prop_copy(sql->sa, e->p);
+       if (ne && !ne->used && e->rname)
+               exp_setname(sql->sa, ne, e->rname, e->name);
        return ne;
 }
 
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
@@ -4,6 +4,7 @@ semijoinunion.Bug-6150
 HAVE_LIBZ?heapextend.Bug-6134
 incorrect_error.Bug-6141
 empty-interval.Bug-6184
+crash_in_null_cast.Bug-6186
 drop_not_null_on_pkey.Bug-6189
 too-large-decimals.Bug-6192
 round-or-truncate.Bug-6193
diff --git a/sql/test/BugTracker-2017/Tests/crash_in_null_cast.Bug-6186.sql 
b/sql/test/BugTracker-2017/Tests/crash_in_null_cast.Bug-6186.sql
new file mode 100644
--- /dev/null
+++ b/sql/test/BugTracker-2017/Tests/crash_in_null_cast.Bug-6186.sql
@@ -0,0 +1,48 @@
+CREATE TABLE "sys"."unitTestDontDelete" (
+       "A" VARCHAR(255),
+       "B" BIGINT,
+       "C" DOUBLE,
+       "D" TIMESTAMP
+);
+COPY 10 RECORDS INTO "sys"."unitTestDontDelete" FROM stdin USING DELIMITERS 
'\t','\n','"';
+NULL   NULL    NULL    NULL
+"Cat1" 0       0.5     2013-06-10 11:10:10.000000
+"Cat2" 1       1.5     2013-06-11 12:11:11.000000
+"Cat1" 2       2.5     2013-06-12 13:12:12.000000
+"Cat2" 3       3.5     2013-06-13 14:13:13.000000
+"Cat1" 4       4.5     2013-06-14 15:14:14.000000
+"Cat2" 5       5.5     2013-06-15 16:15:15.000000
+"Cat1" 6       6.5     2013-06-16 17:16:16.000000
+"Cat2" 7       7.5     2013-06-17 18:17:17.000000
+"Cat1" 8       8.5     2013-06-18 19:18:18.000000
+
+
+CREATE TABLE "sys"."test_join_left_table" (
+       "a"   VARCHAR(255),
+       "b"   VARCHAR(255),
+       "l_c" VARCHAR(255)
+);
+COPY 4 RECORDS INTO "sys"."test_join_left_table" FROM stdin USING DELIMITERS 
'\t','\n','"';
+"a1"   "b1"    "c1"
+"a2"   "b2"    "c2"
+"a3"   "b3"    "c3"
+"a4"   "b4"    NULL
+
+
+
+select * from "test_join_left_table" as "ta" where not exists 
+       (select 1 as "one" from 
+               (select "t2"."A", "t2"."B", "t2"."C", "t2"."D", "t2"."l_c" from 
+               (
+                       (select "t0"."A" as "A", cast("B" as  CLOB) as "B", 
"t0"."C" as "C", "t0"."D" as "D", null as "l_c" from "unitTestDontDelete" as 
"t0")
+               union all 
+                       (select "t1"."a" as "A", "t1"."b" as "B", cast(null as 
double) as "C", cast(null as timestamp) as "D", "t1"."l_c" as "l_c" from 
"test_join_left_table" as "t1")
+               ) as "t2") as "tb" 
+       where ("ta"."l_c" = "tb"."l_c" or ("ta"."l_c" is null and "tb"."l_c" is 
null)));
+
+drop table test_join_left_table;
+drop table "unitTestDontDelete";
+
+
+
+       
diff --git 
a/sql/test/BugTracker-2017/Tests/crash_in_null_cast.Bug-6186.stable.err 
b/sql/test/BugTracker-2017/Tests/crash_in_null_cast.Bug-6186.stable.err
new file mode 100644
--- /dev/null
+++ b/sql/test/BugTracker-2017/Tests/crash_in_null_cast.Bug-6186.stable.err
@@ -0,0 +1,34 @@
+stderr of test 'crash_in_null_cast.Bug-6186` in directory 
'sql/test/BugTracker-2017` itself:
+
+
+# 21:51:16 >  
+# 21:51:16 >  "mserver5" "--debug=10" "--set" "gdk_nr_threads=0" "--set" 
"mapi_open=true" "--set" "mapi_port=33190" "--set" 
"mapi_usock=/var/tmp/mtest-28204/.s.monetdb.33190" "--set" "monet_prompt=" 
"--forcemito" 
"--dbpath=/home/niels/scratch/rc-clean/Linux-x86_64/var/MonetDB/mTests_sql_test_BugTracker-2017"
+# 21:51:16 >  
+
+# builtin opt  gdk_dbpath = 
/home/niels/scratch/rc-clean/Linux-x86_64/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 = 33190
+# cmdline opt  mapi_usock = /var/tmp/mtest-28204/.s.monetdb.33190
+# cmdline opt  monet_prompt = 
+# cmdline opt  gdk_dbpath = 
/home/niels/scratch/rc-clean/Linux-x86_64/var/MonetDB/mTests_sql_test_BugTracker-2017
+# cmdline opt  gdk_debug = 536870922
+
+# 21:51:16 >  
+# 21:51:16 >  "mclient" "-lsql" "-ftest" "-Eutf-8" "-i" "-e" 
"--host=/var/tmp/mtest-28204" "--port=33190"
+# 21:51:16 >  
+
+
+# 21:51:16 >  
+# 21:51:16 >  "Done."
+# 21:51:16 >  
+
diff --git 
a/sql/test/BugTracker-2017/Tests/crash_in_null_cast.Bug-6186.stable.out 
b/sql/test/BugTracker-2017/Tests/crash_in_null_cast.Bug-6186.stable.out
new file mode 100644
--- /dev/null
+++ b/sql/test/BugTracker-2017/Tests/crash_in_null_cast.Bug-6186.stable.out
@@ -0,0 +1,75 @@
+stdout of test 'crash_in_null_cast.Bug-6186` in directory 
'sql/test/BugTracker-2017` itself:
+
+
+# 21:51:16 >  
+# 21:51:16 >  "mserver5" "--debug=10" "--set" "gdk_nr_threads=0" "--set" 
"mapi_open=true" "--set" "mapi_port=33190" "--set" 
"mapi_usock=/var/tmp/mtest-28204/.s.monetdb.33190" "--set" "monet_prompt=" 
"--forcemito" 
"--dbpath=/home/niels/scratch/rc-clean/Linux-x86_64/var/MonetDB/mTests_sql_test_BugTracker-2017"
+# 21:51:16 >  
+
+# MonetDB 5 server v11.25.6
+# 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.615 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://mosquitto:33190/
+# Listening for UNIX domain connection requests on 
mapi:monetdb:///var/tmp/mtest-28204/.s.monetdb.33190
+# MonetDB/GIS module loaded
+# MonetDB/SQL module loaded
+
+Ready.
+
+# 21:51:16 >  
+# 21:51:16 >  "mclient" "-lsql" "-ftest" "-Eutf-8" "-i" "-e" 
"--host=/var/tmp/mtest-28204" "--port=33190"
+# 21:51:16 >  
+
+#CREATE TABLE "sys"."unitTestDontDelete" (
+#      "A" VARCHAR(255),
+#      "B" BIGINT,
+#      "C" DOUBLE,
+#      "D" TIMESTAMP
+#);
+#COPY 10 RECORDS INTO "sys"."unitTestDontDelete" FROM stdin USING DELIMITERS 
'\t','\n','"';
+#NULL  NULL    NULL    NULL
+#"Cat1"        0       0.5     2013-06-10 11:10:10.000000
+#"Cat2"        1       1.5     2013-06-11 12:11:11.000000
+#"Cat1"        2       2.5     2013-06-12 13:12:12.000000
+#"Cat2"        3       3.5     2013-06-13 14:13:13.000000
+#"Cat1"        4       4.5     2013-06-14 15:14:14.000000
+#"Cat2"        5       5.5     2013-06-15 16:15:15.000000
+#"Cat1"        6       6.5     2013-06-16 17:16:16.000000
+#"Cat2"        7       7.5     2013-06-17 18:17:17.000000
+#"Cat1"        8       8.5     2013-06-18 19:18:18.000000
+[ 10   ]
+#CREATE TABLE "sys"."test_join_left_table" (
+#      "a"   VARCHAR(255),
+#      "b"   VARCHAR(255),
+#      "l_c" VARCHAR(255)
+#);
+#COPY 4 RECORDS INTO "sys"."test_join_left_table" FROM stdin USING DELIMITERS 
'\t','\n','"';
+#"a1"  "b1"    "c1"
+#"a2"  "b2"    "c2"
+#"a3"  "b3"    "c3"
+#"a4"  "b4"    NULL
+[ 4    ]
+#select * from "test_join_left_table" as "ta" where not exists 
+#      (select 1 as "one" from 
+#              (select "t2"."A", "t2"."B", "t2"."C", "t2"."D", "t2"."l_c" from 
+#              (
+#                      (select "t0"."A" as "A", cast("B" as  CLOB) as "B", 
"t0"."C" as "C", "t0"."D" as "D", null as "l_c" from "unitTestDontDelete" as 
"t0")
+#              union all 
+#                      (select "t1"."a" as "A", "t1"."b" as "B", cast(null as 
double) as "C", cast(null as timestamp) as "D", "t1"."l_c" as "l_c" from 
"test_join_left_table" as "t1")
+#              ) as "t2") as "tb" 
+#      where ("ta"."l_c" = "tb"."l_c" or ("ta"."l_c" is null and "tb"."l_c" is 
null)));
+% sys.ta,      sys.ta, sys.ta # table_name
+% a,   b,      l_c # name
+% varchar,     varchar,        varchar # type
+% 0,   0,      0 # length
+#drop table test_join_left_table;
+#drop table "unitTestDontDelete";
+
+# 21:51:16 >  
+# 21:51:16 >  "Done."
+# 21:51:16 >  
+
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to