Changeset: 10125a9c3976 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=10125a9c3976
Added Files:
        sql/test/BugTracker-2013/Tests/sort_void_crash.Bug-3341.sql
        sql/test/BugTracker-2013/Tests/sort_void_crash.Bug-3341.stable.err
        sql/test/BugTracker-2013/Tests/sort_void_crash.Bug-3341.stable.out
Modified Files:
        gdk/gdk_batop.c
        monetdb5/mal/mal_dataflow.c
        monetdb5/optimizer/Tests/cst01.stable.out
        monetdb5/optimizer/opt_evaluate.c
        sql/test/BugTracker-2013/Tests/All
Branch: default
Log Message:

Merge with changeset 64d3c2e684de of Feb2013 branch.


diffs (263 lines):

diff --git a/gdk/gdk_batop.c b/gdk/gdk_batop.c
--- a/gdk/gdk_batop.c
+++ b/gdk/gdk_batop.c
@@ -1176,7 +1176,8 @@ BATorder_internal(BAT *b, int stable, in
                 * column needs to be key) */
                return BATrevert(b);
        }
-       if (do_sort(Hloc(b, BUNfirst(b)), Tloc(b, BUNfirst(b)),
+       if ((!(reverse && b->hrevsorted) && !(!reverse && b->hsorted)) &&
+           do_sort(Hloc(b, BUNfirst(b)), Tloc(b, BUNfirst(b)),
                    b->H->vheap ? b->H->vheap->base : NULL,
                    BATcount(b), Hsize(b), Tsize(b), b->htype,
                    reverse, stable) == GDK_FAIL) {
@@ -1419,7 +1420,15 @@ BATsubsort(BAT **sorted, BAT **order, BA
                bn->tsorted = r == 0 && !reverse;
                bn->trevsorted = r == 0 && reverse;
        } else {
-               if (do_sort(Tloc(bn, BUNfirst(bn)),
+               if (b->ttype == TYPE_void) {
+                       b->tsorted = 1;
+                       b->trevsorted = b->tseqbase == oid_nil || b->U->count 
<= 1;
+                       b->tkey |= b->tseqbase != oid_nil;
+               } else if (b->U->count <= 1) {
+                       b->tsorted = b->trevsorted = 1;
+               }
+               if ((!(reverse && bn->trevsorted) && !(!reverse && 
bn->tsorted)) &&
+                   do_sort(Tloc(bn, BUNfirst(bn)),
                            on ? Tloc(on, BUNfirst(on)) : NULL,
                            bn->T->vheap ? bn->T->vheap->base : NULL,
                            BATcount(bn), Tsize(bn), on ? Tsize(on) : 0,
diff --git a/monetdb5/optimizer/opt_evaluate.c 
b/monetdb5/optimizer/opt_evaluate.c
--- a/monetdb5/optimizer/opt_evaluate.c
+++ b/monetdb5/optimizer/opt_evaluate.c
@@ -133,7 +133,7 @@ OPTevaluateImplementation(Client cntxt, 
        int profiler;
        str msg;
        int debugstate = cntxt->itrace, actions = 0, constantblock = 0;
-       int *assigned, setonce; 
+       int *assigned, use; 
 
        cntxt->itrace = 0;
        (void)stk;
@@ -165,21 +165,21 @@ OPTevaluateImplementation(Client cntxt, 
                // The double count emerging from a barrier exit is ignored.
                if (! blockExit(p) || (blockExit(p) && p->retc != p->argc))
                for ( k =0;  k < p->retc; k++)
+               if ( p->retc != p->argc || p->token != ASSIGNsymbol )
                        assigned[getArg(p,k)]++;
        }
 
        for (i = 1; i < limit; i++) {
                p = getInstrPtr(mb, i);
+               // to avoid management of duplicate assignments over multiple 
blocks
+               // we limit ourselfs to evaluation of the first assignment only.
+               use = assigned[getArg(p,0)] == 1 && !(p->argc == p->retc && 
blockExit(p));
                for (k = p->retc; k < p->argc; k++)
                        if (alias[getArg(p, k)])
                                getArg(p, k) = alias[getArg(p, k)];
-               // to avoid management of duplicate assignments over multiple 
blocks
-               // we limit ourselfs to evaluation of the first assignment only.
-               setonce = assigned[getArg(p,0)] == 1;
                OPTDEBUGevaluate printInstruction(cntxt->fdout, mb, 0, p, 
LIST_MAL_ALL);
-
                /* be aware that you only assign once to a variable */
-               if (setonce && p->retc == 1 && OPTallConstant(cntxt, mb, p) && 
!isUnsafeFunction(p)) {
+               if (use && p->retc == 1 && OPTallConstant(cntxt, mb, p) && 
!isUnsafeFunction(p)) {
                        barrier = p->barrier;
                        p->barrier = 0;
                        profiler = malProfileMode;      /* we don't trace it */
@@ -229,7 +229,8 @@ OPTevaluateImplementation(Client cntxt, 
                                mb->errors = 0;
                        }
                }
-               constantblock +=  blockStart(p) && OPTallConstant(cntxt,mb,p);
+               constantblock +=  blockStart(p) && OPTallConstant(cntxt, mb, 
p);        /* default */
+               //constantblock += p->barrier > 0 && OPTallConstant(cntxt, mb, 
p);      /* Feb2013 */
        }
        if ( constantblock )
                actions += OPTremoveUnusedBlocks(cntxt, mb);
diff --git a/sql/test/BugTracker-2013/Tests/All 
b/sql/test/BugTracker-2013/Tests/All
--- a/sql/test/BugTracker-2013/Tests/All
+++ b/sql/test/BugTracker-2013/Tests/All
@@ -37,3 +37,4 @@ constraint_checking.Bug_3335
 pivot.Bug-3339
 qualified_aggrname.Bug-3332
 cannot_use_columns_after_groupby.Bug-3340
+sort_void_crash.Bug-3341
diff --git a/sql/test/BugTracker-2013/Tests/sort_void_crash.Bug-3341.sql 
b/sql/test/BugTracker-2013/Tests/sort_void_crash.Bug-3341.sql
new file mode 100644
--- /dev/null
+++ b/sql/test/BugTracker-2013/Tests/sort_void_crash.Bug-3341.sql
@@ -0,0 +1,43 @@
+CREATE TABLE orders (
+o_orderkey BIGINT NOT NULL,
+o_custkey INTEGER NOT NULL,
+o_orderstatus CHAR(1) NOT NULL,
+o_totalprice DECIMAL(12,2) NOT NULL,
+o_orderdate DATE NOT NULL,
+o_orderpriority CHAR(15) NOT NULL,
+o_clerk CHAR(15) NOT NULL,
+o_shippriority INTEGER NOT NULL,
+o_comment VARCHAR(79) NOT NULL
+);
+
+COPY 28 RECORDS into "orders" from STDIN;
+1|36901|O|173665.47|1996-01-02|5-LOW|Clerk#000000951|0|nstructions sleep 
furiously among |
+2|78002|O|46929.18|1996-12-01|1-URGENT|Clerk#000000880|0| foxes. pending 
accounts at the pending, silent asymptot|
+3|123314|F|193846.25|1993-10-14|5-LOW|Clerk#000000955|0|sly final accounts 
boost. carefully regular ideas cajole carefully. depos|
+4|136777|O|32151.78|1995-10-11|5-LOW|Clerk#000000124|0|sits. slyly regular 
warthogs cajole. regular, regular theodolites acro|
+5|44485|F|144659.20|1994-07-30|5-LOW|Clerk#000000925|0|quickly. bold deposits 
sleep slyly. packages use slyly|
+6|55624|F|58749.59|1992-02-21|4-NOT SPECIFIED|Clerk#000000058|0|ggle. special, 
final requests are against the furiously specia|
+7|39136|O|252004.18|1996-01-10|2-HIGH|Clerk#000000470|0|ly special requests |
+32|130057|O|208660.75|1995-07-16|2-HIGH|Clerk#000000616|0|ise blithely bold, 
regular requests. quickly unusual dep|
+33|66958|F|163243.98|1993-10-27|3-MEDIUM|Clerk#000000409|0|uriously. furiously 
final request|
+34|61001|O|58949.67|1998-07-21|3-MEDIUM|Clerk#000000223|0|ly final packages. 
fluffily final deposits wake blithely ideas. spe|
+35|127588|O|253724.56|1995-10-23|4-NOT SPECIFIED|Clerk#000000259|0|zzle. 
carefully enticing deposits nag furio|
+36|115252|O|68289.96|1995-11-03|1-URGENT|Clerk#000000358|0| quick packages are 
blithely. slyly silent accounts wake qu|
+37|86116|F|206680.66|1992-06-03|3-MEDIUM|Clerk#000000456|0|kly regular pinto 
beans. carefully unusual waters cajole never|
+38|124828|O|82500.05|1996-08-21|4-NOT SPECIFIED|Clerk#000000604|0|haggle 
blithely. furiously express ideas haggle blithely furiously regular re|
+39|81763|O|341734.47|1996-09-20|3-MEDIUM|Clerk#000000659|0|ole express, ironic 
requests: ir|
+64|32113|F|39414.99|1994-07-16|3-MEDIUM|Clerk#000000661|0|wake fluffily. 
sometimes ironic pinto beans about the dolphin|
+65|16252|P|110643.60|1995-03-18|1-URGENT|Clerk#000000632|0|ular requests are 
blithely pending orbits-- even requests against the deposit|
+66|129200|F|103740.67|1994-01-20|5-LOW|Clerk#000000743|0|y pending requests 
integrate|
+67|56614|O|169405.01|1996-12-19|4-NOT SPECIFIED|Clerk#000000547|0|symptotes 
haggle slyly around the furiously iron|
+68|28547|O|330793.52|1998-04-18|3-MEDIUM|Clerk#000000440|0| pinto beans sleep 
carefully. blithely ironic deposits haggle furiously acro|
+69|84487|F|197689.49|1994-06-04|4-NOT SPECIFIED|Clerk#000000330|0| depths atop 
the slyly thin deposits detect among the furiously silent accou|
+70|64340|F|113534.42|1993-12-18|5-LOW|Clerk#000000322|0| carefully ironic 
request|
+71|3373|O|276992.74|1998-01-24|4-NOT SPECIFIED|Clerk#000000271|0| express 
deposits along the blithely regul|
+96|107779|F|68989.90|1994-04-17|2-HIGH|Clerk#000000395|0|oost furiously. pinto|
+97|21061|F|110512.84|1993-01-29|3-MEDIUM|Clerk#000000547|0|hang blithely along 
the regular accounts. furiously even ideas after the|
+98|104480|F|69168.33|1994-09-25|1-URGENT|Clerk#000000448|0|c asymptotes. 
quickly regular packages should have to nag re|
+99|88910|F|112126.95|1994-03-13|4-NOT SPECIFIED|Clerk#000000973|0|e carefully 
ironic packages. pending|
+100|147004|O|187782.63|1998-02-28|4-NOT SPECIFIED|Clerk#000000577|0|heodolites 
detect slyly alongside of the ent|
+
+select rank() over(partition by o_custkey) from orders;
diff --git a/sql/test/BugTracker-2013/Tests/sort_void_crash.Bug-3341.stable.err 
b/sql/test/BugTracker-2013/Tests/sort_void_crash.Bug-3341.stable.err
new file mode 100644
--- /dev/null
+++ b/sql/test/BugTracker-2013/Tests/sort_void_crash.Bug-3341.stable.err
@@ -0,0 +1,35 @@
+stderr of test 'sort_void_crash.Bug-3341` in directory 
'sql/test/BugTracker-2013` itself:
+
+
+# 13:37:20 >  
+# 13:37:20 >  "mserver5" "--debug=10" "--set" "gdk_nr_threads=0" "--set" 
"mapi_open=true" "--set" "mapi_port=36185" "--set" 
"mapi_usock=/var/tmp/mtest-26703/.s.monetdb.36185" "--set" "monet_prompt=" 
"--forcemito" "--set" "mal_listing=2" 
"--dbpath=/home/niels/scratch/rc-clean/Linux-x86_64/var/MonetDB/mTests_sql_test_BugTracker-2013"
 "--set" "mal_listing=0"
+# 13:37:20 >  
+
+# 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 = yes
+# 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 = 36185
+# cmdline opt  mapi_usock = /var/tmp/mtest-26703/.s.monetdb.36185
+# cmdline opt  monet_prompt = 
+# cmdline opt  mal_listing = 2
+# cmdline opt  gdk_dbpath = 
/home/niels/scratch/rc-clean/Linux-x86_64/var/MonetDB/mTests_sql_test_BugTracker-2013
+# cmdline opt  mal_listing = 0
+
+# 13:37:20 >  
+# 13:37:20 >  "mclient" "-lsql" "-ftest" "-Eutf-8" "-i" "-e" 
"--host=/var/tmp/mtest-26703" "--port=36185"
+# 13:37:20 >  
+
+
+# 13:37:20 >  
+# 13:37:20 >  "Done."
+# 13:37:20 >  
+
diff --git a/sql/test/BugTracker-2013/Tests/sort_void_crash.Bug-3341.stable.out 
b/sql/test/BugTracker-2013/Tests/sort_void_crash.Bug-3341.stable.out
new file mode 100644
--- /dev/null
+++ b/sql/test/BugTracker-2013/Tests/sort_void_crash.Bug-3341.stable.out
@@ -0,0 +1,83 @@
+stdout of test 'sort_void_crash.Bug-3341` in directory 
'sql/test/BugTracker-2013` itself:
+
+
+# 13:37:20 >  
+# 13:37:20 >  "mserver5" "--debug=10" "--set" "gdk_nr_threads=0" "--set" 
"mapi_open=true" "--set" "mapi_port=36185" "--set" 
"mapi_usock=/var/tmp/mtest-26703/.s.monetdb.36185" "--set" "monet_prompt=" 
"--forcemito" "--set" "mal_listing=2" 
"--dbpath=/home/niels/scratch/rc-clean/Linux-x86_64/var/MonetDB/mTests_sql_test_BugTracker-2013"
 "--set" "mal_listing=0"
+# 13:37:20 >  
+
+# MonetDB 5 server v11.15.12
+# This is an unreleased version
+# Serving database 'mTests_sql_test_BugTracker-2013', using 4 threads
+# Compiled for x86_64-unknown-linux-gnu/64bit with 64bit OIDs dynamically 
linked
+# Found 3.775 GiB available main-memory.
+# Copyright (c) 1993-July 2008 CWI.
+# Copyright (c) August 2008-2013 MonetDB B.V., all rights reserved
+# Visit http://www.monetdb.org/ for further information
+# Listening for connection requests on 
mapi:monetdb://niels.nesco.mine.nu:36185/
+# Listening for UNIX domain connection requests on 
mapi:monetdb:///var/tmp/mtest-26703/.s.monetdb.36185
+# MonetDB/GIS module loaded
+# MonetDB/JAQL module loaded
+# MonetDB/SQL module loaded
+
+Ready.
+
+# 13:37:20 >  
+# 13:37:20 >  "mclient" "-lsql" "-ftest" "-Eutf-8" "-i" "-e" 
"--host=/var/tmp/mtest-26703" "--port=36185"
+# 13:37:20 >  
+
+#CREATE TABLE orders (
+#o_orderkey BIGINT NOT NULL,
+#o_custkey INTEGER NOT NULL,
+#o_orderstatus CHAR(1) NOT NULL,
+#o_totalprice DECIMAL(12,2) NOT NULL,
+#o_orderdate DATE NOT NULL,
+#o_orderpriority CHAR(15) NOT NULL,
+#o_clerk CHAR(15) NOT NULL,
+#o_shippriority INTEGER NOT NULL,
+#o_comment VARCHAR(79) NOT NULL
+#);
+#COPY 28 RECORDS into "orders" from STDIN;
+#1|36901|O|173665.47|1996-01-02|5-LOW|Clerk#000000951|0|nstructions sleep 
furiously among |
+#2|78002|O|46929.18|1996-12-01|1-URGENT|Clerk#000000880|0| foxes. pending 
accounts at the pending, silent asymptot|
+#3|123314|F|193846.25|1993-10-14|5-LOW|Clerk#000000955|0|sly final accounts 
boost. carefully regular ideas cajole carefully. depos|
+#4|136777|O|32151.78|1995-10-11|5-LOW|Clerk#000000124|0|sits. slyly regular 
warthogs cajole. regular, regular theodolites acro|
+#5|44485|F|144659.20|1994-07-30|5-LOW|Clerk#000000925|0|quickly. bold deposits 
sleep slyly. packages use slyly|
+[ 28   ]
+#select rank() over(partition by o_custkey) from orders;
+% .L # table_name
+% rank_o_custkey # name
+% int # type
+% 1 # length
+[ 1    ]
+[ 1    ]
+[ 1    ]
+[ 1    ]
+[ 1    ]
+[ 1    ]
+[ 1    ]
+[ 1    ]
+[ 1    ]
+[ 1    ]
+[ 1    ]
+[ 1    ]
+[ 1    ]
+[ 1    ]
+[ 1    ]
+[ 1    ]
+[ 1    ]
+[ 1    ]
+[ 1    ]
+[ 1    ]
+[ 1    ]
+[ 1    ]
+[ 1    ]
+[ 1    ]
+[ 1    ]
+[ 1    ]
+[ 1    ]
+[ 1    ]
+
+# 13:37:20 >  
+# 13:37:20 >  "Done."
+# 13:37:20 >  
+
_______________________________________________
checkin-list mailing list
checkin-list@monetdb.org
http://mail.monetdb.org/mailman/listinfo/checkin-list

Reply via email to