Changeset: 102a061eef81 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/102a061eef81
Modified Files:
        gdk/gdk_batop.c
        sql/test/BugTracker-2026/Tests/All
Branch: pp_hashjoin
Log Message:

Merge with default branch.


diffs (153 lines):

diff --git a/gdk/gdk_batop.c b/gdk/gdk_batop.c
--- a/gdk/gdk_batop.c
+++ b/gdk/gdk_batop.c
@@ -1899,6 +1899,31 @@ BATappend_or_update(BAT *b, BAT *p, cons
                                    BUNappendmulti(b, NULL, (BUN) (updid - 
BATcount(b)), force) != GDK_SUCCEED) {
                                        goto bailout;
                                }
+                               if (i < ni.count - 1) {
+                                       BUN j = 1;
+                                       if (positions) {
+                                               for (j = 1; j < ni.count - i; 
j++) {
+                                                       if (positions[j - 1] != 
updid + j)
+                                                               break;
+                                               }
+                                       } else {
+                                               for (j = 1; j < ni.count - i; 
j++) {
+                                                       if (BUNtoid(p, i + j) 
!= updid + j)
+                                                               break;
+                                               }
+                                       }
+                                       if (j > 1) {
+                                               BAT *s = BATdense(0, i + 
n->hseqbase, j);
+                                               rc = BATappend2(b, n, s, force, 
true);
+                                               BBPreclaim(s);
+                                               if (rc != GDK_SUCCEED) {
+                                                       bat_iterator_end(&ni);
+                                                       return rc;
+                                               }
+                                               i += j - 1;
+                                               continue;
+                                       }
+                               }
                                if (BUNappend(b, new, force) != GDK_SUCCEED) {
                                        bat_iterator_end(&ni);
                                        return GDK_FAIL;
diff --git a/gdk/gdk_calc_private.h b/gdk/gdk_calc_private.h
--- a/gdk/gdk_calc_private.h
+++ b/gdk/gdk_calc_private.h
@@ -31,6 +31,11 @@
 
 #define GT(a, b)       ((bit) ((a) > (b)))
 
+#if !defined(__clang__) || __clang_major__ >= 21
+/* compiling with clang on Ubuntu 24.04 fails when using
+ * __builtin_mul_overflow, so we avoid using it when using the version
+ * of clang that is installed on said system (clang on Ubuntu 26.04 does
+ * work) */
 #ifdef __has_builtin
 #if __has_builtin(__builtin_add_overflow)
 #define OP_WITH_CHECK(lft, rgt, TYPE3, dst, op, max, on_overflow)      \
@@ -44,6 +49,7 @@
        } while (0)
 #endif
 #endif
+#endif
 
 /* dst = lft + rgt with overflow check */
 
diff --git a/sql/test/BugTracker-2026/Tests/7982-range-current-row-bug.test 
b/sql/test/BugTracker-2026/Tests/7982-range-current-row-bug.test
new file mode 100644
--- /dev/null
+++ b/sql/test/BugTracker-2026/Tests/7982-range-current-row-bug.test
@@ -0,0 +1,32 @@
+statement ok
+CREATE TABLE t7982(id INT, k INT, v INT)
+
+statement ok
+INSERT INTO t7982 VALUES (1, 1, 10), (2, 2, 20), (3, 2, 30)
+
+query IIII rowsort
+SELECT id, k,
+  COUNT(v) OVER (
+    ORDER BY k
+    RANGE BETWEEN CURRENT ROW AND CURRENT ROW
+  ) AS actual,
+  (SELECT COUNT(r.v) FROM t7982 r WHERE r.k = t7982.k) AS expected
+FROM t7982
+ORDER BY id
+----
+1
+1
+1
+1
+2
+2
+2
+2
+3
+2
+2
+2
+
+statement ok
+DROP TABLE IF EXISTS t7982
+
diff --git a/sql/test/BugTracker-2026/Tests/7984-exists-select-count-bug.test 
b/sql/test/BugTracker-2026/Tests/7984-exists-select-count-bug.test
new file mode 100644
--- /dev/null
+++ b/sql/test/BugTracker-2026/Tests/7984-exists-select-count-bug.test
@@ -0,0 +1,44 @@
+statement ok
+CREATE TABLE ea(x INT)
+
+statement ok
+INSERT INTO ea VALUES (1),(2)
+
+statement ok
+CREATE TABLE eb(y INT)
+
+statement ok
+INSERT INTO eb VALUES (1)
+
+query ITI rowsort
+SELECT ea.x,
+       EXISTS (SELECT COUNT(*) FROM eb WHERE eb.y = ea.x) AS e,  -- did the 
subquery produce a row?
+       (SELECT COUNT(*) FROM eb WHERE eb.y = ea.x)        AS v   -- the value 
of that same subquery
+FROM ea ORDER BY ea.x
+----
+1
+True
+1
+2
+True
+0
+
+-- MonetDB: {1}      expected: {1, 2}      one row silently dropped
+query I rowsort
+SELECT ea.x FROM ea WHERE     EXISTS (SELECT COUNT(*) FROM eb WHERE eb.y = 
ea.x) ORDER BY ea.x
+----
+1
+2
+
+-- MonetDB: {2}      expected: {}          one row silently invented
+query I rowsort
+SELECT ea.x FROM ea WHERE NOT EXISTS (SELECT COUNT(*) FROM eb WHERE eb.y = 
ea.x) ORDER BY ea.x
+----
+
+
+statement ok
+DROP TABLE IF EXISTS ea
+
+statement ok
+DROP TABLE IF EXISTS eb
+
diff --git a/sql/test/BugTracker-2026/Tests/All 
b/sql/test/BugTracker-2026/Tests/All
--- a/sql/test/BugTracker-2026/Tests/All
+++ b/sql/test/BugTracker-2026/Tests/All
@@ -165,3 +165,5 @@ KNOWNFAIL?7974-muli-column-not-in-subque
 7979-prepare-error-exec-113
 KNOWNFAIL?7980-lag-offset-ignored-bug
 7981-not-x-lt-x-bug
+KNOWNFAIL?7982-range-current-row-bug
+KNOWNFAIL?7984-exists-select-count-bug
_______________________________________________
checkin-list mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to