Changeset: d122ab45f0ec for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=d122ab45f0ec
Added Files:
        sql/test/BugTracker-2015/Tests/ukey_check_unaligned.Bug-3669.sql
        sql/test/BugTracker-2015/Tests/ukey_check_unaligned.Bug-3669.stable.err
        sql/test/BugTracker-2015/Tests/ukey_check_unaligned.Bug-3669.stable.out
Modified Files:
        sql/backends/monet5/rel_bin.c
        sql/test/BugTracker-2015/Tests/All
Branch: Oct2014
Log Message:

fixed bug 3669, correct alignment when removing nulls in ukey checks


diffs (201 lines):

diff --git a/sql/backends/monet5/rel_bin.c b/sql/backends/monet5/rel_bin.c
--- a/sql/backends/monet5/rel_bin.c
+++ b/sql/backends/monet5/rel_bin.c
@@ -3251,16 +3251,16 @@ update_check_ukey(mvc *sql, stmt **updat
                                ext = stmt_result(sql->sa, g, 1);
                                Cnt = stmt_result(sql->sa, g, 2);
 
-                               /* choose only groups with cnt > 1 */
+                               /* continue only with groups with a cnt > 1 */
                                cand = stmt_uselect(sql->sa, Cnt, 
stmt_atom_wrd(sql->sa, 1), cmp_gt, NULL);
-                                /* project cand on ext and Cnt */
+                               /* project cand on ext and Cnt */
                                Cnt = stmt_project(sql->sa, cand, Cnt);
                                ext = stmt_project(sql->sa, cand, ext);
 
-                               /* join ext with group to retrieve all oid's of 
the original
+                               /* join groups with extend to retrieve all 
oid's of the original
                                 * bat that belong to a group with Cnt >1 */
-                               g = stmt_join(sql->sa, ext, grp, cmp_equal);
-                               cand = stmt_result(sql->sa, g, 1);
+                               g = stmt_join(sql->sa, grp, ext, cmp_equal);
+                               cand = stmt_result(sql->sa, g, 0);
                                grp = stmt_project(sql->sa, cand, grp);
                        }
 
@@ -3274,7 +3274,7 @@ update_check_ukey(mvc *sql, stmt **updat
                                        upd = updates[updcol]->op1;
                                        upd = stmt_project(sql->sa, upd, 
stmt_col(sql, c->c, dels));
                                } else {
-                                       upd = stmt_col(sql, c->c, dels);
+                                       upd = stmt_project(sql->sa, tids, 
stmt_col(sql, c->c, dels));
                                }
 
                                /* apply cand list first */
@@ -3284,9 +3284,11 @@ update_check_ukey(mvc *sql, stmt **updat
                                /* remove nulls */
                                if ((k->type == ukey) && stmt_has_null(upd)) {
                                        stmt *nn = stmt_selectnonil(sql, upd, 
NULL);
-                                       upd = stmt_reorder_project(sql->sa, nn, 
upd);
+                                       upd = stmt_project(sql->sa, nn, upd);
                                        if (grp)
-                                               grp = 
stmt_reorder_project(sql->sa, nn, grp);
+                                               grp = stmt_project(sql->sa, nn, 
grp);
+                                       if (cand)
+                                               cand = stmt_project(sql->sa, 
nn, cand);
                                }
 
                                /* apply group by on groups with Cnt > 1 */
@@ -3327,7 +3329,6 @@ update_check_ukey(mvc *sql, stmt **updat
                        assert (updates);
 
                        h = updates[c->c->colnr]->op2;
-                       //o = stmt_diff(sql->sa, stmt_col(sql, c->c, dels), 
stmt_reverse(sql->sa, tids));
                        o = stmt_col(sql, c->c, nu_tids);
                        s = stmt_join(sql->sa, o, h, cmp_equal);
                        s = stmt_result(sql->sa, s, 0);
diff --git a/sql/test/BugTracker-2015/Tests/All 
b/sql/test/BugTracker-2015/Tests/All
--- a/sql/test/BugTracker-2015/Tests/All
+++ b/sql/test/BugTracker-2015/Tests/All
@@ -8,3 +8,4 @@ inet-ordering.Bug-3660
 row-value-constructor-crash.Bug-3662
 incorrect-ROW_NUMBER.Bug-3663
 string-to-inet.Bug-3666
+ukey_check_unaligned.Bug-3669
diff --git a/sql/test/BugTracker-2015/Tests/ukey_check_unaligned.Bug-3669.sql 
b/sql/test/BugTracker-2015/Tests/ukey_check_unaligned.Bug-3669.sql
new file mode 100644
--- /dev/null
+++ b/sql/test/BugTracker-2015/Tests/ukey_check_unaligned.Bug-3669.sql
@@ -0,0 +1,17 @@
+create table tab (id int not null, nm varchar(30) not null, dt date, qnt 
dec(18,10), descr text);
+-- table created.
+insert into tab (id, nm) values (1, 'A');
+insert into tab (id, nm, dt, qnt, descr) values (2, 'B', '2015-01-29', 
3.1415629, 'iasdfhiasdhagdsnfgankkkjfgjklfgjklsklsklsdfg');
+select * from tab;
+-- 2 rows.
+insert into tab (id, nm, dt, qnt, descr) select id, nm, dt, qnt, descr from 
tab;
+--- 2 rows inserted
+select * from tab;
+-- 4 rows.
+select count(*) as count_dupl_rows, id, nm, dt, qnt, descr from tab
+group by id, nm, dt, qnt, descr having count(*) > 1
+order by id, nm, dt, qnt, descr;
+-- 2 rows (id = 1 and 2) exists twice.
+alter table tab add constraint tab_uc6 unique (id, nm, dt, qnt, descr);
+
+drop table tab;
diff --git 
a/sql/test/BugTracker-2015/Tests/ukey_check_unaligned.Bug-3669.stable.err 
b/sql/test/BugTracker-2015/Tests/ukey_check_unaligned.Bug-3669.stable.err
new file mode 100644
--- /dev/null
+++ b/sql/test/BugTracker-2015/Tests/ukey_check_unaligned.Bug-3669.stable.err
@@ -0,0 +1,40 @@
+stderr of test 'ukey_check_unaligned.Bug-3669` in directory 
'sql/test/BugTracker-2015` itself:
+
+
+# 20:45:27 >  
+# 20:45:27 >  "mserver5" "--debug=10" "--set" "gdk_nr_threads=0" "--set" 
"mapi_open=true" "--set" "mapi_port=39026" "--set" 
"mapi_usock=/var/tmp/mtest-6699/.s.monetdb.39026" "--set" "monet_prompt=" 
"--forcemito" "--set" "mal_listing=2" 
"--dbpath=/home/niels/scratch/rc-clean/Linux-x86_64/var/MonetDB/mTests_sql_test_BugTracker-2015"
 "--set" "mal_listing=0" "--set" "embedded_r=yes"
+# 20:45:27 >  
+
+# 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 = 39026
+# cmdline opt  mapi_usock = /var/tmp/mtest-6699/.s.monetdb.39026
+# 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-2015
+# cmdline opt  mal_listing = 0
+# cmdline opt  embedded_r = yes
+# cmdline opt  gdk_debug = 536870922
+
+# 20:45:27 >  
+# 20:45:27 >  "mclient" "-lsql" "-ftest" "-Eutf-8" "-i" "-e" 
"--host=/var/tmp/mtest-6699" "--port=39026"
+# 20:45:27 >  
+
+MAPI  = (monetdb) /var/tmp/mtest-6699/.s.monetdb.39026
+QUERY = alter table tab add constraint tab_uc6 unique (id, nm, dt, qnt, descr);
+ERROR = !UPDATE: UNIQUE constraint 'tab.tab_uc6' violated
+
+# 20:45:27 >  
+# 20:45:27 >  "Done."
+# 20:45:27 >  
+
diff --git 
a/sql/test/BugTracker-2015/Tests/ukey_check_unaligned.Bug-3669.stable.out 
b/sql/test/BugTracker-2015/Tests/ukey_check_unaligned.Bug-3669.stable.out
new file mode 100644
--- /dev/null
+++ b/sql/test/BugTracker-2015/Tests/ukey_check_unaligned.Bug-3669.stable.out
@@ -0,0 +1,65 @@
+stdout of test 'ukey_check_unaligned.Bug-3669` in directory 
'sql/test/BugTracker-2015` itself:
+
+
+# 20:45:27 >  
+# 20:45:27 >  "mserver5" "--debug=10" "--set" "gdk_nr_threads=0" "--set" 
"mapi_open=true" "--set" "mapi_port=39026" "--set" 
"mapi_usock=/var/tmp/mtest-6699/.s.monetdb.39026" "--set" "monet_prompt=" 
"--forcemito" "--set" "mal_listing=2" 
"--dbpath=/home/niels/scratch/rc-clean/Linux-x86_64/var/MonetDB/mTests_sql_test_BugTracker-2015"
 "--set" "mal_listing=0" "--set" "embedded_r=yes"
+# 20:45:27 >  
+
+# MonetDB 5 server v11.19.8
+# This is an unreleased version
+# Serving database 'mTests_sql_test_BugTracker-2015', using 4 threads
+# Compiled for x86_64-unknown-linux-gnu/64bit with 64bit OIDs dynamically 
linked
+# Found 7.333 GiB available main-memory.
+# Copyright (c) 1993-July 2008 CWI.
+# Copyright (c) August 2008-2015 MonetDB B.V., all rights reserved
+# Visit http://www.monetdb.org/ for further information
+# Listening for connection requests on mapi:monetdb://localhost.nes.nl:39026/
+# Listening for UNIX domain connection requests on 
mapi:monetdb:///var/tmp/mtest-6699/.s.monetdb.39026
+# MonetDB/GIS module loaded
+# MonetDB/SQL module loaded
+# MonetDB/R   module loaded
+
+Ready.
+
+# 20:45:27 >  
+# 20:45:27 >  "mclient" "-lsql" "-ftest" "-Eutf-8" "-i" "-e" 
"--host=/var/tmp/mtest-6699" "--port=39026"
+# 20:45:27 >  
+
+#create table tab (id int not null, nm varchar(30) not null, dt date, qnt 
dec(18,10), descr text);
+#insert into tab (id, nm) values (1, 'A');
+[ 1    ]
+#insert into tab (id, nm, dt, qnt, descr) values (2, 'B', '2015-01-29', 
3.1415629, 'iasdfhiasdhagdsnfgankkkjfgjklfgjklsklsklsdfg');
+[ 1    ]
+#select * from tab;
+% sys.tab,     sys.tab,        sys.tab,        sys.tab,        sys.tab # 
table_name
+% id,  nm,     dt,     qnt,    descr # name
+% int, varchar,        date,   decimal,        clob # type
+% 1,   1,      10,     20,     44 # length
+[ 1,   "A",    NULL,   NULL,   NULL    ]
+[ 2,   "B",    2015-01-29,     3.1415629000,   
"iasdfhiasdhagdsnfgankkkjfgjklfgjklsklsklsdfg"  ]
+#insert into tab (id, nm, dt, qnt, descr) select id, nm, dt, qnt, descr from 
tab;
+[ 2    ]
+#select * from tab;
+% sys.tab,     sys.tab,        sys.tab,        sys.tab,        sys.tab # 
table_name
+% id,  nm,     dt,     qnt,    descr # name
+% int, varchar,        date,   decimal,        clob # type
+% 1,   1,      10,     20,     44 # length
+[ 1,   "A",    NULL,   NULL,   NULL    ]
+[ 2,   "B",    2015-01-29,     3.1415629000,   
"iasdfhiasdhagdsnfgankkkjfgjklfgjklsklsklsdfg"  ]
+[ 1,   "A",    NULL,   NULL,   NULL    ]
+[ 2,   "B",    2015-01-29,     3.1415629000,   
"iasdfhiasdhagdsnfgankkkjfgjklfgjklsklsklsdfg"  ]
+#select count(*) as count_dupl_rows, id, nm, dt, qnt, descr from tab
+#group by id, nm, dt, qnt, descr having count(*) > 1
+#order by id, nm, dt, qnt, descr;
+% sys.L1,      sys.tab,        sys.tab,        sys.tab,        sys.tab,        
sys.tab # table_name
+% count_dupl_rows,     id,     nm,     dt,     qnt,    descr # name
+% wrd, int,    varchar,        date,   decimal,        clob # type
+% 1,   1,      1,      10,     20,     44 # length
+[ 2,   1,      "A",    NULL,   NULL,   NULL    ]
+[ 2,   2,      "B",    2015-01-29,     3.1415629000,   
"iasdfhiasdhagdsnfgankkkjfgjklfgjklsklsklsdfg"  ]
+#drop table tab;
+
+# 20:45:27 >  
+# 20:45:27 >  "Done."
+# 20:45:27 >  
+
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to