Changeset: 461b6d416053 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/461b6d416053
Branch: default
Log Message:

Merged with Jan2022


diffs (153 lines):

diff --git a/monetdb5/optimizer/opt_dict.c b/monetdb5/optimizer/opt_dict.c
--- a/monetdb5/optimizer/opt_dict.c
+++ b/monetdb5/optimizer/opt_dict.c
@@ -112,9 +112,9 @@ OPTdictImplementation(Client cntxt, MalB
                                        freeInstruction(p);
                                        done = 1;
                                        break;
-                               } else if (getModuleId(p) == batRef && 
getFunctionId(p) == mirrorRef) {
-                                       /* id = mirror(col) with col = 
dict.decompress(o,u)
-                                        * id = mirror(o) */
+                               } else if ((getModuleId(p) == batRef && 
getFunctionId(p) == mirrorRef) || (getModuleId(p) == batcalcRef && 
getFunctionId(p) == identityRef)) {
+                                       /* id = mirror/identity(col) with col = 
dict.decompress(o,u)
+                                        * id = mirror/identity(o) */
                                        InstrPtr r = copyInstruction(p);
                                        getArg(r, j) = varisdict[k];
                                        pushInstruction(mb,r);
diff --git a/monetdb5/optimizer/opt_for.c b/monetdb5/optimizer/opt_for.c
--- a/monetdb5/optimizer/opt_for.c
+++ b/monetdb5/optimizer/opt_for.c
@@ -108,16 +108,15 @@ OPTforImplementation(Client cntxt, MalBl
                                        freeInstruction(p);
                                        done = 1;
                                        break;
-                               } else if (getModuleId(p) == batRef && 
getFunctionId(p) == mirrorRef) {
-                                       /* id = mirror(col) with col = 
for.decompress(o,min_val)
-                                        * id = mirror(o) */
+                               } else if ((getModuleId(p) == batRef && 
getFunctionId(p) == mirrorRef) || (getModuleId(p) == batcalcRef && 
getFunctionId(p) == identityRef)) {
+                                       /* id = mirror/identity(col) with col = 
for.decompress(o,min_val)
+                                        * id = mirror/identity(o) */
                                        InstrPtr r = copyInstruction(p);
                                        getArg(r, j) = varisfor[k];
                                        pushInstruction(mb,r);
                                        freeInstruction(p);
                                        done = 1;
                                        break;
-                               //} else if (isSelect(p)) {
                                } else// if (isSelect(p)) {
                                        if (getFunctionId(p) == thetaselectRef) 
{
                                                /* pos = thetaselect(col, cand, 
l, ...) with col = for.decompress(o, minval)
diff --git a/sql/backends/monet5/dict.c b/sql/backends/monet5/dict.c
--- a/sql/backends/monet5/dict.c
+++ b/sql/backends/monet5/dict.c
@@ -283,6 +283,7 @@ DICTcompress_col(Client cntxt, MalBlkPtr
 BAT *
 DICTdecompress_(BAT *o, BAT *u, role_t role)
 {
+       bool nils = false;
        BAT *b = COLnew(o->hseqbase, u->ttype, BATcount(o), role);
 
        if (!b)
@@ -298,19 +299,27 @@ DICTdecompress_(BAT *o, BAT *u, role_t r
                        int *bp = Tloc(b, 0);
 
                        BATloop(o, p, q) {
-                               bp[p] = up[op[p]];
+                               int v = up[op[p]];
+                               nils |= is_int_nil(v);
+                               bp[p] = v;
                        }
                        BATsetcount(b, BATcount(o));
                        BATnegateprops(b);
+                       b->tnil = nils;
+                       b->tnonil = !nils;
                } else if (ATOMstorage(u->ttype) == TYPE_lng) {
                        lng *up = Tloc(u, 0);
                        lng *bp = Tloc(b, 0);
 
                        BATloop(o, p, q) {
-                               bp[p] = up[op[p]];
+                               lng v = up[op[p]];
+                               nils |= is_lng_nil(v);
+                               bp[p] = v;
                        }
                        BATsetcount(b, BATcount(o));
                        BATnegateprops(b);
+                       b->tnil = nils;
+                       b->tnonil = !nils;
                } else {
                        BATloop(o, p, q) {
                                BUN up = op[p];
@@ -330,19 +339,27 @@ DICTdecompress_(BAT *o, BAT *u, role_t r
                        int *bp = Tloc(b, 0);
 
                        BATloop(o, p, q) {
-                               bp[p] = up[op[p]];
+                               int v = up[op[p]];
+                               nils |= is_int_nil(v);
+                               bp[p] = v;
                        }
                        BATsetcount(b, BATcount(o));
                        BATnegateprops(b);
+                       b->tnil = nils;
+                       b->tnonil = !nils;
                } else if (ATOMstorage(u->ttype) == TYPE_lng) {
                        lng *up = Tloc(u, 0);
                        lng *bp = Tloc(b, 0);
 
                        BATloop(o, p, q) {
-                               bp[p] = up[op[p]];
+                               lng v = up[op[p]];
+                               nils |= is_lng_nil(v);
+                               bp[p] = v;
                        }
                        BATsetcount(b, BATcount(o));
                        BATnegateprops(b);
+                       b->tnil = nils;
+                       b->tnonil = !nils;
                } else {
                        BATloop(o, p, q) {
                                BUN up = op[p];
diff --git a/sql/server/sql_parser.y b/sql/server/sql_parser.y
--- a/sql/server/sql_parser.y
+++ b/sql/server/sql_parser.y
@@ -3058,6 +3058,7 @@ insert_atom:
 value:
     search_condition
  |  select_no_parens
+ |  with_query
  ;
 
 opt_distinct:
@@ -3608,7 +3609,7 @@ comparison_predicate:
                  append_symbol(l, $5);
                  append_int(l, $3);
                  $$ = _symbol_create_list(SQL_COMPARE, l ); }
- |  pred_exp '=' any_all_some  '(' value ')'
+ |  pred_exp '=' any_all_some '(' value ')'
                { dlist *l = L();
 
                  append_symbol(l, $1);
diff --git a/sql/test/SQLancer/Tests/sqlancer18.test 
b/sql/test/SQLancer/Tests/sqlancer18.test
--- a/sql/test/SQLancer/Tests/sqlancer18.test
+++ b/sql/test/SQLancer/Tests/sqlancer18.test
@@ -637,3 +637,19 @@ query T nosort
 SELECT ((SELECT 5) INTERSECT (SELECT 9)) = ALL(SELECT 4) >= TRUE
 ----
 NULL
+
+query T nosort
+SELECT 1 = ANY(WITH x(x) AS (SELECT 1) SELECT x FROM x)
+----
+True
+
+query T nosort
+SELECT 1 IN (WITH x(x) AS (SELECT 1) SELECT x FROM x)
+----
+True
+
+query T nosort
+SELECT EXISTS (WITH x(x) AS (SELECT 1) SELECT x FROM x)
+----
+True
+
_______________________________________________
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to