Changeset: 2afcb0a24df4 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=2afcb0a24df4
Modified Files:
        gdk/gdk_subquery.c
        sql/test/SQLancer/Tests/sqlancer11.stable.out
Branch: Oct2020
Log Message:

If both l and r are null, but later they are equal, then the nil value will be 
lift, so calculate existence of nils after the aggregate


diffs (76 lines):

diff --git a/gdk/gdk_subquery.c b/gdk/gdk_subquery.c
--- a/gdk/gdk_subquery.c
+++ b/gdk/gdk_subquery.c
@@ -574,7 +574,6 @@ alloc_fail:
                                                ret[gid] = VAL2; \
                                        } else if (is_##TYPE##_nil(vals1[i]) || 
is_##TYPE##_nil(vals2[i])) { \
                                                ret[gid] = bit_nil; \
-                                               hasnil = 1; \
                                        } else if (vals1[i] == vals2[i]) { \
                                                ret[gid] = VAL1; \
                                        } \
@@ -671,7 +670,6 @@ BATanyequal_grp2(BAT *l, BAT *r, BAT *ri
                                                        const void *rv = 
BUNtail(ri, i);
                                                        if (ocmp(lv, nilp) == 0 
|| ocmp(rv, nilp) == 0) {
                                                                ret[gid] = 
bit_nil;
-                                                               hasnil = 1;
                                                        } else if (ocmp(lv, rv) 
== 0)
                                                                ret[gid] = TRUE;
                                                }
@@ -680,6 +678,8 @@ BATanyequal_grp2(BAT *l, BAT *r, BAT *ri
                        }
                }
                }
+               for (BUN i = 0 ; i < ngrp ; i++)
+                       hasnil |= ret[i] == bit_nil;
                BATsetcount(res, ngrp);
                res->tkey = BATcount(res) <= 1;
                res->tsorted = BATcount(res) <= 1;
@@ -790,7 +790,6 @@ BATallnotequal_grp2(BAT *l, BAT *r, BAT 
                                                        const void *rv = 
BUNtail(ri, i);
                                                        if (ocmp(lv, nilp) == 0 
|| ocmp(rv, nilp) == 0) {
                                                                ret[gid] = 
bit_nil;
-                                                               hasnil = 1;
                                                        } else if (ocmp(lv, rv) 
== 0)
                                                                ret[gid] = 
FALSE;
                                                }
@@ -799,6 +798,8 @@ BATallnotequal_grp2(BAT *l, BAT *r, BAT 
                        }
                }
                }
+               for (BUN i = 0 ; i < ngrp ; i++)
+                       hasnil |= ret[i] == bit_nil;
                BATsetcount(res, ngrp);
                res->tkey = BATcount(res) <= 1;
                res->tsorted = BATcount(res) <= 1;
diff --git a/sql/test/SQLancer/Tests/sqlancer11.stable.out 
b/sql/test/SQLancer/Tests/sqlancer11.stable.out
--- a/sql/test/SQLancer/Tests/sqlancer11.stable.out
+++ b/sql/test/SQLancer/Tests/sqlancer11.stable.out
@@ -58,6 +58,27 @@ stdout of test 'sqlancer11` in directory
 #true  NULL
 #true  NULL
 [ 10   ]
+#drop table t0;
+#drop table t1;
+#START TRANSACTION;
+#CREATE TABLE "t0" ("c0" DOUBLE PRECISION,"c2" BIGINT);
+#INSERT INTO "t0" VALUES (NULL, 4), (NULL, 6), (NULL, 0), (NULL, 2), (NULL, 1);
+[ 5    ]
+#CREATE TABLE "t2" ("c0" DOUBLE PRECISION,"c1" bigint,"c2" BIGINT,"c4" REAL);
+#INSERT INTO "t2" VALUES (4, 0, 6, NULL),(0.692789052132086, -1, 9, NULL),(2, 
0, 6, NULL),(0.9469594820593024, 1, NULL, NULL),(NULL, 0, 6, NULL),
+#(0.39272912837466945, 8, NULL, NULL),(NULL, NULL, 4, NULL),(2, 0, 6, 
NULL),(-1596101049, 0, 6, NULL),(-1951243968, 0, 6, NULL),(NULL, 0, 6, NULL),
+#(NULL, 0, 6, NULL),(NULL, 0, 6, NULL),(NULL, 0, 6, NULL);
+[ 14   ]
+#SELECT 4 = ANY(SELECT t2.c2 FROM t2) FROM t0;
+% .%7 # table_name
+% %7 # name
+% boolean # type
+% 5 # length
+[ true ]
+[ true ]
+[ true ]
+[ true ]
+[ true ]
 #ROLLBACK;
 
 # 13:59:46 >  
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to