Changeset: 64367251584c for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/64367251584c Modified Files: gdk/gdk_bat.c Branch: default Log Message:
Merge with Jul2021 branch. diffs (195 lines): diff --git a/gdk/gdk_align.c b/gdk/gdk_align.c --- a/gdk/gdk_align.c +++ b/gdk/gdk_align.c @@ -255,7 +255,7 @@ BATmaterialize(BAT *b) b->tbaseoff = 0; b->theap->dirty = true; BATsetprop_nolock(b, GDK_NUNIQUE, TYPE_oid, &(oid){is_oid_nil(t) ? 1 : b->batCount}); - BATsetprop_nolock(b, GDK_UNIQUE_ESTIMATE, TYPE_dbl, &(dbl){is_oid_nil(t) ? 1 : b->batCount}); + BATsetprop_nolock(b, GDK_UNIQUE_ESTIMATE, TYPE_dbl, &(dbl){is_oid_nil(t) ? 1.0 : (dbl)b->batCount}); MT_lock_unset(&b->theaplock); b->ttype = TYPE_oid; BATsetdims(b); diff --git a/gdk/gdk_bat.c b/gdk/gdk_bat.c --- a/gdk/gdk_bat.c +++ b/gdk/gdk_bat.c @@ -674,7 +674,7 @@ BATfree(BAT *b) MT_lock_set(&b->theaplock); if (nunique != BUN_NONE) { BATsetprop_nolock(b, GDK_NUNIQUE, TYPE_oid, &(oid){nunique}); - BATsetprop_nolock(b, GDK_UNIQUE_ESTIMATE, TYPE_dbl, &(dbl){nunique}); + BATsetprop_nolock(b, GDK_UNIQUE_ESTIMATE, TYPE_dbl, &(dbl){(dbl)nunique}); BATsetprop_nolock(b, GDK_HASH_BUCKETS, TYPE_oid, &(oid){nbucket}); } if (b->theap) { diff --git a/monetdb5/optimizer/opt_pushselect.c b/monetdb5/optimizer/opt_pushselect.c --- a/monetdb5/optimizer/opt_pushselect.c +++ b/monetdb5/optimizer/opt_pushselect.c @@ -320,25 +320,29 @@ OPTpushselectImplementation(Client cntxt /* rewrite batalgebra.like + [theta]select -> likeselect */ if (getModuleId(p) == algebraRef && p->retc == 1 && - (getFunctionId(p) == selectRef || getFunctionId(p) == thetaselectRef)) { + (getFunctionId(p) == selectRef || getFunctionId(p) == thetaselectRef)) { int var = getArg(p, 1); InstrPtr q = mb->stmt[vars[var]]; /* BEWARE: the optimizer may not add or remove statements ! */ if (isLikeOp(q) && - !isaBatType(getArgType(mb, q, 2)) && /* pattern is a value */ - !isaBatType(getArgType(mb, q, 3)) && /* escape is a value */ - !isaBatType(getArgType(mb, q, 4)) && /* isensitive flag is a value */ - strcmp(getVarName(mb, getArg(q,0)), getVarName(mb, getArg(p,1))) == 0 /* the output variable from batalgebra.like is the input one for [theta]select */) { + isVarConstant(mb, getArg(q, 2)) && /* pattern is a value */ + isVarConstant(mb, getArg(q, 3)) && /* escape is a value */ + isVarConstant(mb, getArg(q, 4)) && /* isensitive flag is a value */ + strcmp(getVarName(mb, getArg(q,0)), getVarName(mb, getArg(p,1))) == 0 /* the output variable from batalgebra.like is the input one for [theta]select */) { int has_cand = (getArgType(mb, p, 2) == newBatType(TYPE_oid)), offset = 0, anti = (getFunctionId(q)[0] == 'n'); bit ignore_case = *(bit*)getVarValue(mb, getArg(q, 4)), selectok = TRUE; /* TODO at the moment we cannot convert if the select statement has NULL semantics we can convert it into VAL is NULL or PATTERN is NULL or ESCAPE is NULL */ - if (getFunctionId(p) == selectRef) { + if (getFunctionId(p) == selectRef && isVarConstant(mb, getArg(p, 2 + has_cand)) && + isVarConstant(mb, getArg(p, 3 + has_cand)) && isVarConstant(mb, getArg(p, 4 + has_cand)) && + isVarConstant(mb, getArg(p, 5 + has_cand)) && isVarConstant(mb, getArg(p, 6 + has_cand)) && + (p->argc < (has_cand ? 9 : 8) || isVarConstant(mb, getArg(p, 7 + has_cand)))) { bit low = *(bit*)getVarValue(mb, getArg(p, 2 + has_cand)), high = *(bit*)getVarValue(mb, getArg(p, 3 + has_cand)); bit li = *(bit*)getVarValue(mb, getArg(p, 4 + has_cand)), hi = *(bit*)getVarValue(mb, getArg(p, 5 + has_cand)); - bit santi = *(bit*)getVarValue(mb, getArg(p, 6 + has_cand)), sunknown = (p->argc == (has_cand ? 9 : 8)) ? 0 : *(bit*)getVarValue(mb, getArg(p, 7 + has_cand)); + bit santi = *(bit*)getVarValue(mb, getArg(p, 6 + has_cand)); + bit sunknown = (p->argc == (has_cand ? 9 : 8)) ? 0 : *(bit*)getVarValue(mb, getArg(p, 7 + has_cand)); /* semantic or not symmetric cases, it cannot be converted */ if (is_bit_nil(low) || is_bit_nil(li) || is_bit_nil(santi) || low != high || li != hi || sunknown) @@ -351,7 +355,8 @@ OPTpushselectImplementation(Client cntxt anti = !anti; if (santi) anti = !anti; - } else if (getFunctionId(p) == thetaselectRef) { + } else if (getFunctionId(p) == thetaselectRef && + isVarConstant(mb, getArg(p, 3)) && isVarConstant(mb, getArg(p, 4))) { bit truth_value = *(bit*)getVarValue(mb, getArg(p, 3)); str comparison = (str)getVarValue(mb, getArg(p, 4)); @@ -364,6 +369,8 @@ OPTpushselectImplementation(Client cntxt anti = !anti; else if (strcmp(comparison, "==") != 0) selectok = FALSE; + } else { + selectok = FALSE; } if (selectok) { diff --git a/sql/test/SQLancer/Tests/sqlancer16.test b/sql/test/SQLancer/Tests/sqlancer16.test --- a/sql/test/SQLancer/Tests/sqlancer16.test +++ b/sql/test/SQLancer/Tests/sqlancer16.test @@ -171,3 +171,108 @@ select length(soundex(t0.c1)) from t0 statement ok ROLLBACK + +statement ok +START TRANSACTION + +statement ok +CREATE TABLE "t1" ("c2" BIGINT NOT NULL, CONSTRAINT "con2" PRIMARY KEY ("c2")) + +statement ok rowcount 40 +COPY 40 RECORDS INTO "t1" FROM stdin USING DELIMITERS E'\t',E'\n','"' +<COPY_INTO_DATA> +2 +0 +-1765753 +-671746563 +6 +1921029267 +-825025708 +-2104297243 +8 +-129210606 +-1726103676 +1060807335 +5 +-1998039746 +-773178777 +9 +-1 +-9 +1978301412 +3 +4 +8077286484 +2091469291 +-132835704 +2042020815 +243455873 +-1382358507 +-1764685245 +7 +1 +-1819128901 +1992817175 +7885662936 +1052088495 +-358447186 +487372521 +904364548 +446252969 +-477681301 +-51400690 + +query I rowsort +SELECT t1.c2 FROM t1 WHERE (((CAST(t1.c2 AS STRING(268)))NOT ILIKE('%6I/2'''))) IN +((((('-')LIKE('0.2118767221584169')))OR(((((TRUE)AND(TRUE)))OR(FALSE))))) +---- +-1 +-129210606 +-132835704 +-1382358507 +-1726103676 +-1764685245 +-1765753 +-1819128901 +-1998039746 +-2104297243 +-358447186 +-477681301 +-51400690 +-671746563 +-773178777 +-825025708 +-9 +0 +1 +1052088495 +1060807335 +1921029267 +1978301412 +1992817175 +2 +2042020815 +2091469291 +243455873 +3 +4 +446252969 +487372521 +5 +6 +7 +7885662936 +8 +8077286484 +9 +904364548 + +query I rowsort +SELECT CAST(SUM(count) AS BIGINT) FROM (SELECT CAST((((CAST(t1.c2 AS STRING(268)))NOT ILIKE('%6I/2'))) IN +((((('-')LIKE('0.2118767221584169')))OR(((((TRUE)AND(TRUE)))OR(FALSE))))) AS INT) as count FROM t1) as res +---- +40 + +statement ok +ROLLBACK + _______________________________________________ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list