Changeset: 81da696d3623 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/81da696d3623
Modified Files:
monetdb5/modules/kernel/algebra.c
sql/test/SQLancer/Tests/sqlancer13.test
Branch: default
Log Message:
If the range limits are null, don't include them in the search (fixes
sqlancer13)
diffs (96 lines):
diff --git a/monetdb5/modules/kernel/algebra.c
b/monetdb5/modules/kernel/algebra.c
--- a/monetdb5/modules/kernel/algebra.c
+++ b/monetdb5/modules/kernel/algebra.c
@@ -285,14 +285,14 @@ ALGselect2nil(bat *result, const bat *bi
{
BAT *b, *s = NULL, *bn;
const void *nilptr;
- bit nanti = *anti;
+ bit nanti = *anti, nli = *li, nhi = *hi;
if (!*unknown)
return ALGselect2(result, bid, sid, low, high, li, hi, anti);
- if ((*li != 0 && *li != 1) ||
- (*hi != 0 && *hi != 1) ||
- (*anti != 0 && *anti != 1)) {
+ if ((nli != 0 && nli != 1) ||
+ (nhi != 0 && nhi != 1) ||
+ (nanti != 0 && nanti != 1)) {
throw(MAL, "algebra.select", ILLEGAL_ARGUMENT);
}
if ((b = BATdescriptor(*bid)) == NULL) {
@@ -306,13 +306,17 @@ ALGselect2nil(bat *result, const bat *bi
derefStr(b, high);
/* here we don't need open ended parts with nil */
nilptr = ATOMnilptr(b->ttype);
- if (*li == 1 && ATOMcmp(b->ttype, low, nilptr) == 0)
+ if (nli == 1 && ATOMcmp(b->ttype, low, nilptr) == 0) {
low = high;
- else if (*hi == 1 && ATOMcmp(b->ttype, high, nilptr) == 0)
+ nli = 0;
+ }
+ if (nhi == 1 && ATOMcmp(b->ttype, high, nilptr) == 0) {
high = low;
+ nhi = 0;
+ }
if (ATOMcmp(b->ttype, low, high) == 0 && ATOMcmp(b->ttype, high,
nilptr) == 0) /* ugh sql nil != nil */
nanti = !nanti;
- bn = BATselect(b, s, low, high, *li, *hi, nanti);
+ bn = BATselect(b, s, low, high, nli, nhi, nanti);
BBPunfix(b->batCacheid);
if (s)
BBPunfix(s->batCacheid);
diff --git a/sql/test/SQLancer/Tests/sqlancer13.test
b/sql/test/SQLancer/Tests/sqlancer13.test
--- a/sql/test/SQLancer/Tests/sqlancer13.test
+++ b/sql/test/SQLancer/Tests/sqlancer13.test
@@ -614,7 +614,48 @@ bebfb44f-1cfc-905c-fd0e-0e5feeb39d4d
15aaa8c9-16c4-40d6-cdd1-a19be9d2add7
query I rowsort
-SELECT 1 FROM t0 WHERE t0.c0 BETWEEN 0 AND NULL
+SELECT t0.c0 FROM t0 WHERE t0.c0 BETWEEN 0 AND 0
+----
+0
+
+query I rowsort
+SELECT t0.c0 FROM t0 WHERE t0.c0 BETWEEN 0 AND NULL
+----
+
+query I rowsort
+SELECT t0.c0 FROM t0 WHERE t0.c0 BETWEEN NULL AND 0
+----
+
+query I rowsort
+SELECT t0.c0 FROM t0 WHERE t0.c0 BETWEEN NULL AND NULL
+----
+
+query I rowsort
+SELECT t0.c0 FROM t0 WHERE t0.c0 NOT BETWEEN 0 AND 0
+----
+-7
+1
+2
+6
+7
+9
+
+query I rowsort
+SELECT t0.c0 FROM t0 WHERE t0.c0 NOT BETWEEN 0 AND NULL
+----
+-7
+
+query I rowsort
+SELECT t0.c0 FROM t0 WHERE t0.c0 NOT BETWEEN NULL AND 0
+----
+1
+2
+6
+7
+9
+
+query I rowsort
+SELECT t0.c0 FROM t0 WHERE t0.c0 NOT BETWEEN NULL AND NULL
----
query T rowsort
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list