Shouldn't this go to the Feb2013 branch? On 2013-03-20 15:55, Niels Nes wrote:
Changeset: 59ae06013de6 for MonetDB URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=59ae06013de6 Modified Files: sql/backends/monet5/rel_bin.c sql/test/BugTracker-2012/Tests/rewrite_like_into_likesubselect.Bug-3179.stable.out Branch: default Log Message:
approved output fixed bug view-view, bug 3245
diffs (281 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 @@ -2340,14 +2340,21 @@ rel2bin_select( mvc *sql, sql_rel *rel, if (!sub) return NULL; sub = row2cols(sql, sub); - } else { + } + if (!sub && !predicate) predicate = rel2bin_predicate(sql); - } + else if (!predicate) + predicate = stmt_const(sql->sa, bin_first_column(sql->sa, sub), stmt_bool(sql->sa, 1)); if (!rel->exps->h) { if (sub) return sub; return predicate; } + if (!sub && predicate) { + list *l = sa_list(sql->sa); + append(l, predicate); + sub = stmt_list(sql->sa, l); + } /* handle possible index lookups */ /* expressions are in index order ! */ if (sub && (en = rel->exps->h) != NULL) { @@ -2368,10 +2375,8 @@ rel2bin_select( mvc *sql, sql_rel *rel, assert(0); return NULL; } - if (s->nrcols == 0){ - if (!predicate) - predicate = rel2bin_predicate(sql); - predicate = stmt_uselect(sql->sa, predicate, s, cmp_equal, NULL); + if (s->nrcols == 0){ + sel = stmt_uselect(sql->sa, predicate, s, cmp_equal, sel); } else if (e->type != e_cmp) { sel = stmt_uselect(sql->sa, s, stmt_bool(sql->sa, 1), cmp_equal, NULL); } else { @@ -2379,14 +2384,6 @@ rel2bin_select( mvc *sql, sql_rel *rel, } }
- if (predicate && sel) { - sel = stmt_reverse(sql->sa, sel); - sel = stmt_join(sql->sa, sel, predicate, cmp_all); - sel = stmt_result(sql->sa, sel, 0); - predicate = NULL; - if (!sub) - predicate = sel; - } /* construct relation */ l = sa_list(sql->sa); if (sub && sel) { @@ -2399,22 +2396,6 @@ rel2bin_select( mvc *sql, sql_rel *rel, col = stmt_project(sql->sa, sel, col); list_append(l, col); } - } else if (sub && predicate) { - stmt *h = NULL; - n = sub->op4.lval->h; - h = stmt_join(sql->sa, column(sql->sa, n->data), predicate, cmp_all); - h = stmt_result(sql->sa, h, 0); - for( n = sub->op4.lval->h; n; n = n->next ) { - stmt *col = n->data; - - if (col->nrcols == 0) /* constant */ - col = stmt_const(sql->sa, h, col); - else - col = stmt_project(sql->sa, h, col); - list_append(l, col); - } - } else if (predicate) { - list_append(l, predicate); } return stmt_list(sql->sa, l); } diff --git a/sql/test/BugTracker-2012/Tests/rewrite_like_into_likesubselect.Bug-3179.stable.out b/sql/test/BugTracker-2012/Tests/rewrite_like_into_likesubselect.Bug-3179.stable.out --- a/sql/test/BugTracker-2012/Tests/rewrite_like_into_likesubselect.Bug-3179.stable.out +++ b/sql/test/BugTracker-2012/Tests/rewrite_like_into_likesubselect.Bug-3179.stable.out @@ -29,17 +29,17 @@ Ready. % .explain # table_name % mal # name % clob # type -% 117 # length +% 111 # length function user.s0_1(A0:str):void; X_2 := sql.mvc(); X_6 := sql.bind(X_2,"sys","functions","name",0); X_3:bat[:oid,:oid] := sql.tid(X_2,"sys","functions"); - X_49 := algebra.likesubselect(X_6,X_3,A0,"",false); + X_48 := algebra.likesubselect(X_6,X_3,A0,"",false); (X_9,r1_9) := sql.bind(X_2,"sys","functions","name",2); - X_50 := algebra.likesubselect(r1_9,A0,"",false); + X_49 := algebra.likesubselect(r1_9,A0,"",false); X_12 := sql.bind(X_2,"sys","functions","name",1); - X_51 := algebra.likesubselect(X_12,X_3,A0,"",false); - X_15 := sql.subdelta(X_49,X_9,X_50,X_51); + X_50 := algebra.likesubselect(X_12,X_3,A0,"",false); + X_15 := sql.subdelta(X_48,X_9,X_49,X_50); X_17 := sql.projectdelta(X_15,X_6,X_9,r1_9,X_12); X_18 := sql.bind(X_2,"sys","functions","func",0); (X_20,r1_28) := sql.bind(X_2,"sys","functions","func",2); @@ -55,17 +55,17 @@ end s0_1; % .explain # table_name % mal # name % clob # type -% 121 # length +% 115 # length function user.s1_1(A0:str):void; X_2 := sql.mvc(); X_6 := sql.bind(X_2,"sys","functions","name",0); X_3:bat[:oid,:oid] := sql.tid(X_2,"sys","functions"); - X_49 := algebra.likesubselect(X_6,X_3,A0,"",true); + X_48 := algebra.likesubselect(X_6,X_3,A0,"",true); (X_9,r1_9) := sql.bind(X_2,"sys","functions","name",2); - X_50 := algebra.likesubselect(r1_9,A0,"",true); + X_49 := algebra.likesubselect(r1_9,A0,"",true); X_12 := sql.bind(X_2,"sys","functions","name",1); - X_51 := algebra.likesubselect(X_12,X_3,A0,"",true); - X_15 := sql.subdelta(X_49,X_9,X_50,X_51); + X_50 := algebra.likesubselect(X_12,X_3,A0,"",true); + X_15 := sql.subdelta(X_48,X_9,X_49,X_50); X_17 := sql.projectdelta(X_15,X_6,X_9,r1_9,X_12); X_18 := sql.bind(X_2,"sys","functions","func",0); (X_20,r1_28) := sql.bind(X_2,"sys","functions","func",2); @@ -81,17 +81,17 @@ end s1_1; % .explain # table_name % mal # name % clob # type -% 118 # length +% 112 # length function user.s2_1(A0:str):void; X_2 := sql.mvc(); X_6 := sql.bind(X_2,"sys","functions","name",0); X_3:bat[:oid,:oid] := sql.tid(X_2,"sys","functions"); - X_49 := algebra.ilikesubselect(X_6,X_3,A0,"",false); + X_48 := algebra.ilikesubselect(X_6,X_3,A0,"",false); (X_9,r1_9) := sql.bind(X_2,"sys","functions","name",2); - X_50 := algebra.ilikesubselect(r1_9,A0,"",false); + X_49 := algebra.ilikesubselect(r1_9,A0,"",false); X_12 := sql.bind(X_2,"sys","functions","name",1); - X_51 := algebra.ilikesubselect(X_12,X_3,A0,"",false); - X_15 := sql.subdelta(X_49,X_9,X_50,X_51); + X_50 := algebra.ilikesubselect(X_12,X_3,A0,"",false); + X_15 := sql.subdelta(X_48,X_9,X_49,X_50); X_17 := sql.projectdelta(X_15,X_6,X_9,r1_9,X_12); X_18 := sql.bind(X_2,"sys","functions","func",0); (X_20,r1_28) := sql.bind(X_2,"sys","functions","func",2); @@ -107,17 +107,17 @@ end s2_1; % .explain # table_name % mal # name % clob # type -% 122 # length +% 116 # length function user.s3_1(A0:str):void; X_2 := sql.mvc(); X_6 := sql.bind(X_2,"sys","functions","name",0); X_3:bat[:oid,:oid] := sql.tid(X_2,"sys","functions"); - X_49 := algebra.ilikesubselect(X_6,X_3,A0,"",true); + X_48 := algebra.ilikesubselect(X_6,X_3,A0,"",true); (X_9,r1_9) := sql.bind(X_2,"sys","functions","name",2); - X_50 := algebra.ilikesubselect(r1_9,A0,"",true); + X_49 := algebra.ilikesubselect(r1_9,A0,"",true); X_12 := sql.bind(X_2,"sys","functions","name",1); - X_51 := algebra.ilikesubselect(X_12,X_3,A0,"",true); - X_15 := sql.subdelta(X_49,X_9,X_50,X_51); + X_50 := algebra.ilikesubselect(X_12,X_3,A0,"",true); + X_15 := sql.subdelta(X_48,X_9,X_49,X_50); X_17 := sql.projectdelta(X_15,X_6,X_9,r1_9,X_12); X_18 := sql.bind(X_2,"sys","functions","func",0); (X_20,r1_28) := sql.bind(X_2,"sys","functions","func",2); @@ -153,19 +153,19 @@ end s3_1; % .explain # table_name % mal # name % clob # type -% 121 # length +% 115 # length function user.s4_1(A0:str):void; X_2 := sql.mvc(); X_6 := sql.bind(X_2,"sys","functions","name",0); X_3:bat[:oid,:oid] := sql.tid(X_2,"sys","functions"); - X_52 := calc.+("%",A0); - X_53 := calc.+(X_52,"%"); - X_56 := algebra.likesubselect(X_6,X_3,X_53,"",false,false); + X_51 := calc.+("%",A0); + X_52 := calc.+(X_51,"%"); + X_55 := algebra.likesubselect(X_6,X_3,X_52,"",false,false); (X_9,r1_9) := sql.bind(X_2,"sys","functions","name",2); - X_57 := algebra.likesubselect(r1_9,X_53,"",false,false); + X_56 := algebra.likesubselect(r1_9,X_52,"",false,false); X_12 := sql.bind(X_2,"sys","functions","name",1); - X_58 := algebra.likesubselect(X_12,X_3,X_53,"",false,false); - X_14 := sql.subdelta(X_56,X_9,X_57,X_58); + X_57 := algebra.likesubselect(X_12,X_3,X_52,"",false,false); + X_14 := sql.subdelta(X_55,X_9,X_56,X_57); X_15 := sql.projectdelta(X_14,X_6,X_9,r1_9,X_12); X_16 := sql.bind(X_2,"sys","functions","func",0); (X_18,r1_35) := sql.bind(X_2,"sys","functions","func",2); @@ -181,19 +181,19 @@ end s4_1; % .explain # table_name % mal # name % clob # type -% 125 # length +% 119 # length function user.s5_1(A0:str):void; X_2 := sql.mvc(); X_6 := sql.bind(X_2,"sys","functions","name",0); X_3:bat[:oid,:oid] := sql.tid(X_2,"sys","functions"); - X_52 := calc.+("%",A0); - X_53 := calc.+(X_52,"%"); - X_57 := algebra.likesubselect(X_6,X_3,X_53,"",false,true); + X_51 := calc.+("%",A0); + X_52 := calc.+(X_51,"%"); + X_56 := algebra.likesubselect(X_6,X_3,X_52,"",false,true); (X_9,r1_9) := sql.bind(X_2,"sys","functions","name",2); - X_58 := algebra.likesubselect(r1_9,X_53,"",false,true); + X_57 := algebra.likesubselect(r1_9,X_52,"",false,true); X_12 := sql.bind(X_2,"sys","functions","name",1); - X_59 := algebra.likesubselect(X_12,X_3,X_53,"",false,true); - X_14 := sql.subdelta(X_57,X_9,X_58,X_59); + X_58 := algebra.likesubselect(X_12,X_3,X_52,"",false,true); + X_14 := sql.subdelta(X_56,X_9,X_57,X_58); X_15 := sql.projectdelta(X_14,X_6,X_9,r1_9,X_12); X_16 := sql.bind(X_2,"sys","functions","func",0); (X_18,r1_35) := sql.bind(X_2,"sys","functions","func",2); @@ -209,19 +209,19 @@ end s5_1; % .explain # table_name % mal # name % clob # type -% 122 # length +% 116 # length function user.s6_1(A0:str):void; X_2 := sql.mvc(); X_6 := sql.bind(X_2,"sys","functions","name",0); X_3:bat[:oid,:oid] := sql.tid(X_2,"sys","functions"); - X_52 := calc.+("%",A0); - X_53 := calc.+(X_52,"%"); - X_57 := algebra.likesubselect(X_6,X_3,X_53,"",true,false); + X_51 := calc.+("%",A0); + X_52 := calc.+(X_51,"%"); + X_56 := algebra.likesubselect(X_6,X_3,X_52,"",true,false); (X_9,r1_9) := sql.bind(X_2,"sys","functions","name",2); - X_58 := algebra.likesubselect(r1_9,X_53,"",true,false); + X_57 := algebra.likesubselect(r1_9,X_52,"",true,false); X_12 := sql.bind(X_2,"sys","functions","name",1); - X_59 := algebra.likesubselect(X_12,X_3,X_53,"",true,false); - X_14 := sql.subdelta(X_57,X_9,X_58,X_59); + X_58 := algebra.likesubselect(X_12,X_3,X_52,"",true,false); + X_14 := sql.subdelta(X_56,X_9,X_57,X_58); X_15 := sql.projectdelta(X_14,X_6,X_9,r1_9,X_12); X_16 := sql.bind(X_2,"sys","functions","func",0); (X_18,r1_35) := sql.bind(X_2,"sys","functions","func",2); @@ -237,19 +237,19 @@ end s6_1; % .explain # table_name % mal # name % clob # type -% 126 # length +% 120 # length function user.s7_1(A0:str):void; X_2 := sql.mvc(); X_6 := sql.bind(X_2,"sys","functions","name",0); X_3:bat[:oid,:oid] := sql.tid(X_2,"sys","functions"); - X_52 := calc.+("%",A0); - X_53 := calc.+(X_52,"%"); - X_56 := algebra.likesubselect(X_6,X_3,X_53,"",true,true); + X_51 := calc.+("%",A0); + X_52 := calc.+(X_51,"%"); + X_55 := algebra.likesubselect(X_6,X_3,X_52,"",true,true); (X_9,r1_9) := sql.bind(X_2,"sys","functions","name",2); - X_57 := algebra.likesubselect(r1_9,X_53,"",true,true); + X_56 := algebra.likesubselect(r1_9,X_52,"",true,true); X_12 := sql.bind(X_2,"sys","functions","name",1); - X_58 := algebra.likesubselect(X_12,X_3,X_53,"",true,true); - X_14 := sql.subdelta(X_56,X_9,X_57,X_58); + X_57 := algebra.likesubselect(X_12,X_3,X_52,"",true,true); + X_14 := sql.subdelta(X_55,X_9,X_56,X_57); X_15 := sql.projectdelta(X_14,X_6,X_9,r1_9,X_12); X_16 := sql.bind(X_2,"sys","functions","func",0); (X_18,r1_35) := sql.bind(X_2,"sys","functions","func",2); _______________________________________________ checkin-list mailing list checkin-list@monetdb.org http://mail.monetdb.org/mailman/listinfo/checkin-list
-- Sjoerd Mullender
participants (1)
-
Sjoerd Mullender