Changeset: a162c9245277 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/a162c9245277
Modified Files:
        gdk/gdk_analytic_func.c
        sql/test/BugTracker-2026/Tests/7922-sum-overflow-error-bug.test
        sql/test/BugTracker-2026/Tests/All
Branch: Dec2025
Log Message:

When calculating sum aggr in window funcs, ignore overflow in intermediates.
Only when the final result is calculated, we check that we didn't have
overflow.
Fixes #7922.


diffs (47 lines):

diff --git a/gdk/gdk_analytic_func.c b/gdk/gdk_analytic_func.c
--- a/gdk/gdk_analytic_func.c
+++ b/gdk/gdk_analytic_func.c
@@ -2137,11 +2137,6 @@ finishsum(allocator *ma, struct pergroup
        do {                                                    \
                if (pg.valseen) {                               \
                        double curval = finishsum(ta, &pg);     \
-                       if (isinf(curval) ||                    \
-                           isnan(curval) ||                    \
-                           curval > GDK_##TPE2##_max ||        \
-                           curval < -GDK_##TPE2##_max)         \
-                               goto calc_overflow;             \
                        computed = (TPE2) curval;               \
                }                                               \
                ma_close(&ta_state);                            \
diff --git a/sql/test/BugTracker-2026/Tests/7922-sum-overflow-error-bug.test 
b/sql/test/BugTracker-2026/Tests/7922-sum-overflow-error-bug.test
--- a/sql/test/BugTracker-2026/Tests/7922-sum-overflow-error-bug.test
+++ b/sql/test/BugTracker-2026/Tests/7922-sum-overflow-error-bug.test
@@ -30,8 +30,6 @@ INSERT INTO t_bug12_aux VALUES
   (2, 13)
 
 -- original window query
--- MonetDB returns: 22003!overflow in calculation. but other RDBMS do not.
--- the sum(t_bug12.vf) needs to add: -1e308 + -1e308 + 1e308, which apparently 
fails with overflow in calculation error, see below.
 query II nosort
 SELECT p, v
 FROM (
@@ -62,6 +60,7 @@ ORDER BY p, v
 960
 
 -- the sum(t_bug12.vf) needs to add: -1e308 + -1e308 + 1e308, which apparently 
fails with overflow in calculation error
+skipif knownfail
 query R nosort
 SELECT -1e308 + -1e308 + 1e308 as sum
 ----
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
@@ -115,7 +115,7 @@ KNOWNFAIL?7774-insert-into-renamed-table
 7919-correlated-count-distinct-bug
 7920-correlated-top-1-subquery-bug
 7921-correlated-floor-ratio-bug
-KNOWNFAIL?7922-sum-overflow-error-bug
+7922-sum-overflow-error-bug
 7923-sum-decimal-conversion-overflow-bug
 KNOWNFAIL?7924-sum-double-overflow-bug
 KNOWNFAIL?7925-inconsistent-compare-varchar-to-bte-bug
_______________________________________________
checkin-list mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to