Changeset: 7b42f71a6ce9 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/7b42f71a6ce9
Added Files:
sql/test/BugTracker-2026/Tests/8059-aggr-on-pipeline-local-string-col-causes-nulls.test
Modified Files:
monetdb5/modules/mal/pp_algebra.c
sql/test/BugTracker-2026/Tests/All
Branch: default
Log Message:
fixes in LALGmin for null handing, fixes issue #8059
diffs (105 lines):
diff --git a/monetdb5/modules/mal/pp_algebra.c
b/monetdb5/modules/mal/pp_algebra.c
--- a/monetdb5/modules/mal/pp_algebra.c
+++ b/monetdb5/modules/mal/pp_algebra.c
@@ -3789,22 +3789,26 @@ bail:
/* private (changing) heap */
#define vamin_(cmp, opos, in, i, bp)
\
{
\
- var_t off = VarHeapVal(r->theap->base, opos, r->twidth);
\
- if (!off || (in[i] != 0 && cmp(r->tvheap->base+off, bp+in[i]) > 0)) \
- if (tfastins_nocheckVAR( r, opos, bp+in[i]) != GDK_SUCCEED) {
\
+ var_t ooff = VarHeapVal(r->theap->base, opos, r->twidth);
\
+ var_t ioff = VarHeapVal(b->theap->base, i, b->twidth);
\
+ if (ioff && (!ooff || cmp(r->tvheap->base+ooff, bp+ioff) > 0)) {
\
+ if (ioff && tfastins_nocheckVAR( r, opos, bp+ioff) !=
GDK_SUCCEED) { \
err = createException(MAL, "ilockedaggr.min",
MAL_MALLOC_FAIL); \
goto error;
\
- }
\
+ }\
+ } \
}
#define vamax_(cmp, opos, in, i, bp)
\
{
\
- var_t off = VarHeapVal(r->theap->base, opos, r->twidth);
\
- if (!off || (in[i] != 0 && cmp(r->tvheap->base+off, bp+in[i]) < 0)) \
- if (tfastins_nocheckVAR( r, opos, bp+in[i]) != GDK_SUCCEED) {
\
+ var_t ooff = VarHeapVal(r->theap->base, opos, r->twidth);
\
+ var_t ioff = VarHeapVal(b->theap->base, i, b->twidth);
\
+ if (ioff && (!ooff || cmp(r->tvheap->base+ooff, bp+ioff) < 0)) {
\
+ if (ioff && tfastins_nocheckVAR( r, opos, bp+ioff) !=
GDK_SUCCEED) { \
err = createException(MAL, "ilockedaggr.max",
MAL_MALLOC_FAIL); \
goto error;
\
- }
\
+ }\
+ } \
}
#define gafunc_(f)
\
@@ -3813,25 +3817,8 @@ bail:
BATiter ri = bat_iterator(r);
\
char *bp = bi.vh->base;
\
int (*cmp)(const void *v1,const void *v2) = ATOMcompare(tt);
\
- if (b->twidth == 1) {
\
- bp += GDK_VAROFFSET;
\
- uint8_t *in = Tloc(b, 0);
\
- TIMEOUT_LOOP_IDX_DECL(i, cnt, qry_ctx)
\
- f##_(cmp, grp[i], in, i, bp);
\
- } else if (b->twidth == 2) {
\
- bp += GDK_VAROFFSET;
\
- uint16_t *in = Tloc(b, 0);
\
- TIMEOUT_LOOP_IDX_DECL(i, cnt, qry_ctx)
\
- f##_(cmp, grp[i], in, i, bp);
\
- } else if (b->twidth == 4) {
\
- uint32_t *in = Tloc(b, 0);
\
- TIMEOUT_LOOP_IDX_DECL(i, cnt, qry_ctx)
\
- f##_(cmp, grp[i], in, i, bp);
\
- } else if (b->twidth == 8) {
\
- var_t *in = Tloc(b, 0);
\
- TIMEOUT_LOOP_IDX_DECL(i, cnt, qry_ctx)
\
- f##_(cmp, grp[i], in, i, bp);
\
- }
\
+ TIMEOUT_LOOP_IDX_DECL(i, cnt, qry_ctx)
\
+ f##_(cmp, grp[i], in, i, bp);
\
bat_iterator_end(&bi);
\
bat_iterator_end(&ri);
\
}
diff --git
a/sql/test/BugTracker-2026/Tests/8059-aggr-on-pipeline-local-string-col-causes-nulls.test
b/sql/test/BugTracker-2026/Tests/8059-aggr-on-pipeline-local-string-col-causes-nulls.test
new file mode 100644
--- /dev/null
+++
b/sql/test/BugTracker-2026/Tests/8059-aggr-on-pipeline-local-string-col-causes-nulls.test
@@ -0,0 +1,25 @@
+statement ok
+CREATE TABLE t(g INTEGER, v VARCHAR(20))
+
+statement ok
+CREATE TABLE expected(g INTEGER, mn VARCHAR(20), mx VARCHAR(20))
+
+statement ok
+CREATE TABLE actual(g INTEGER, mn VARCHAR(20), mx VARCHAR(20))
+
+statement ok rowcount 7
+INSERT INTO t VALUES
+ (1, NULL), (1, 'z'), (1, 'a'),
+ (2, NULL), (2, NULL),
+ (3, 'm'), (3, NULL)
+
+statement ok rowcount 3
+INSERT INTO expected VALUES
+ (1, 'a', 'z'), (2, NULL, NULL), (3, 'm', 'm')
+
+query ITT
+SELECT g, MIN(v || '') AS mn, MAX(v || '') AS mx FROM t GROUP BY g ORDER BY g
+----
+1 a z
+2 NULL NULL
+3 m m
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
@@ -214,4 +214,5 @@ KNOWNFAIL?8030-inner-join-group-by-bug
8036-alter+insert-in-trans
8037-alter-table-decimal
8031-simplify-count-too-simple
+8059-aggr-on-pipeline-local-string-col-causes-nulls
8062-groupby-inet6
_______________________________________________
checkin-list mailing list -- [email protected]
To unsubscribe send an email to [email protected]