Changeset: 8b11b8db30ce for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/8b11b8db30ce
Modified Files:
gdk/gdk_storage.c
sql/backends/monet5/sql_gencode.c
sql/test/BugTracker-2026/Tests/All
Branch: default
Log Message:
Merge with Dec2025 branch.
diffs (truncated from 2055 to 300 lines):
diff --git a/gdk/gdk_storage.c b/gdk/gdk_storage.c
--- a/gdk/gdk_storage.c
+++ b/gdk/gdk_storage.c
@@ -815,6 +815,8 @@ BATload_intern(bat bid, bool lock)
if (b->ttype != TYPE_void) {
b->theap->storage = b->theap->newstorage = STORE_INVALID;
if ((b->batCount == 0 ?
+ ATOMstorage(b->ttype) == TYPE_msk ?
+ HEAPalloc(b->theap, (b->batCapacity + 31) / 32, 4) :
HEAPalloc(b->theap, b->batCapacity, b->twidth) :
HEAPload(b->theap, b->theap->filename, NULL,
b->batRestricted == BAT_READ)) != GDK_SUCCEED) {
HEAPfree(b->theap, false);
diff --git a/sql/backends/monet5/sql_gencode.c
b/sql/backends/monet5/sql_gencode.c
--- a/sql/backends/monet5/sql_gencode.c
+++ b/sql/backends/monet5/sql_gencode.c
@@ -1463,12 +1463,18 @@ backend_create_sql_func_body(backend *be
sql_func *pf = NULL;
sql_rel *r;
+ allocator *sa = m->sa;
+ assert(!prepare || f->sa);
+ if (f->sa)
+ m->sa = f->sa;
r = rel_parse(m, f->s, f->query, prepare?m_prepare:m_instantiate);
if (r) {
r = sql_processrelation(m, r, 0, 1, 1, 0);
r = rel_physical(m, r);
}
if (!r) {
+ if (f->sa)
+ m->sa = sa;
goto cleanup;
}
@@ -1480,6 +1486,8 @@ backend_create_sql_func_body(backend *be
curInstr = table_func_create_result(curBlk, curInstr,
f, restypes);
if( curInstr == NULL) {
sql_error(m, 10, SQLSTATE(HY013)
MAL_MALLOC_FAIL);
+ if (f->sa)
+ m->sa = sa;
goto cleanup;
}
} else {
@@ -1501,6 +1509,8 @@ backend_create_sql_func_body(backend *be
(void) snprintf(buf, sizeof(buf), "A%d", argc);
if ((varid = newVariable(curBlk, buf, strlen(buf),
type)) < 0) {
sql_error(m, 10, SQLSTATE(42000) "Internal
error while compiling statement: variable id too long");
+ if (f->sa)
+ m->sa = sa;
goto cleanup;
}
curInstr = pushArgument(curBlk, curInstr, varid);
@@ -1526,10 +1536,14 @@ backend_create_sql_func_body(backend *be
}
if (!buf) {
sql_error(m, 10, SQLSTATE(HY013)
MAL_MALLOC_FAIL);
+ if (f->sa)
+ m->sa = sa;
goto cleanup;
}
if ((varid = newVariable(curBlk, buf, strlen(buf),
type)) < 0) {
sql_error(m, 10, SQLSTATE(42000) "Internal
error while compiling statement: variable id too long");
+ if (f->sa)
+ m->sa = sa;
goto cleanup;
}
curInstr = pushArgument(curBlk, curInstr, varid);
@@ -1538,10 +1552,13 @@ backend_create_sql_func_body(backend *be
}
/* for recursive functions, avoid infinite loops */
pf = m->forward;
- m->forward = f;
+ if (!prepare)
+ m->forward = f;
be->fimp = fimp; /* for recursive functions keep the generated name */
res = backend_dumpstmt(be, curBlk, r, prepare, 1, NULL);
m->forward = pf;
+ if (f->sa)
+ m->sa = sa;
if (res < 0)
goto cleanup;
/* selectively make functions available for inlineing */
@@ -1653,8 +1670,16 @@ backend_create_sql_func(backend *be, sql
*ma_get_eb(m->sa) = ebsave;
return 0;
bailout:
- if (!prepare)
+ if (!prepare) {
+ /* We need to #undef GDKfree in case the compiler optimizes and
+ * asserts are enabled (more specifically, NDEBUG is not defined
+ * but __GNUC__ is). In these specific circumstances, the
+ * assignment inside the GDKfree debug macro triggers a compiler
+ * warning about a variable that may get clobbered by
+ * longjmp. */
+#undef GDKfree
_DELETE(fimp);
+ }
*be = bebackup;
c->curprg = symbackup;
*ma_get_eb(m->sa) = ebsave;
diff --git a/sql/server/sql_qc.c b/sql/server/sql_qc.c
--- a/sql/server/sql_qc.c
+++ b/sql/server/sql_qc.c
@@ -178,6 +178,7 @@ qc_insert(qc *cache, allocator *sa, sql_
.query = cmd,
.ops = params,
.res = res,
+ .sa = sa,
};
base_init(sa, &f->base, 0, true, NULL);
f->base.new = 1;
diff --git a/sql/test/BugTracker-2026/Tests/7979-prepare-error-exec-113.test
b/sql/test/BugTracker-2026/Tests/7979-prepare-error-exec-113.test
new file mode 100644
--- /dev/null
+++ b/sql/test/BugTracker-2026/Tests/7979-prepare-error-exec-113.test
@@ -0,0 +1,1931 @@
+statement ok
+create table info ( attribute int )
+
+query TIITTT
+PREPARE WITH x as (SELECT 1) SELECT 1 as n, row_number() over() as rn FROM
(SELECT * FROM x, info where 0 = info.attribute) as z
+----
+tinyint
+1
+0
+(empty)
+(empty)
+n
+int
+31
+0
+(empty)
+(empty)
+rn
+
+query TIITTT
+PREPARE WITH x as (SELECT 1) SELECT 1 as n, row_number() over() as rn FROM
(SELECT * FROM x, info where 0 = info.attribute) as z
+----
+tinyint
+1
+0
+(empty)
+(empty)
+n
+int
+31
+0
+(empty)
+(empty)
+rn
+
+query TIITTT
+PREPARE WITH x as (SELECT 1) SELECT 1 as n, row_number() over() as rn FROM
(SELECT * FROM x, info where 0 = info.attribute) as z
+----
+tinyint
+1
+0
+(empty)
+(empty)
+n
+int
+31
+0
+(empty)
+(empty)
+rn
+
+query TIITTT
+PREPARE WITH x as (SELECT 1) SELECT 1 as n, row_number() over() as rn FROM
(SELECT * FROM x, info where 0 = info.attribute) as z
+----
+tinyint
+1
+0
+(empty)
+(empty)
+n
+int
+31
+0
+(empty)
+(empty)
+rn
+
+query TIITTT
+PREPARE WITH x as (SELECT 1) SELECT 1 as n, row_number() over() as rn FROM
(SELECT * FROM x, info where 0 = info.attribute) as z
+----
+tinyint
+1
+0
+(empty)
+(empty)
+n
+int
+31
+0
+(empty)
+(empty)
+rn
+
+query TIITTT
+PREPARE WITH x as (SELECT 1) SELECT 1 as n, row_number() over() as rn FROM
(SELECT * FROM x, info where 0 = info.attribute) as z
+----
+tinyint
+1
+0
+(empty)
+(empty)
+n
+int
+31
+0
+(empty)
+(empty)
+rn
+
+query TIITTT
+PREPARE WITH x as (SELECT 1) SELECT 1 as n, row_number() over() as rn FROM
(SELECT * FROM x, info where 0 = info.attribute) as z
+----
+tinyint
+1
+0
+(empty)
+(empty)
+n
+int
+31
+0
+(empty)
+(empty)
+rn
+
+query TIITTT
+PREPARE WITH x as (SELECT 1) SELECT 1 as n, row_number() over() as rn FROM
(SELECT * FROM x, info where 0 = info.attribute) as z
+----
+tinyint
+1
+0
+(empty)
+(empty)
+n
+int
+31
+0
+(empty)
+(empty)
+rn
+
+query TIITTT
+PREPARE WITH x as (SELECT 1) SELECT 1 as n, row_number() over() as rn FROM
(SELECT * FROM x, info where 0 = info.attribute) as z
+----
+tinyint
+1
+0
+(empty)
+(empty)
+n
+int
+31
+0
+(empty)
+(empty)
+rn
+
+query TIITTT
+PREPARE WITH x as (SELECT 1) SELECT 1 as n, row_number() over() as rn FROM
(SELECT * FROM x, info where 0 = info.attribute) as z
+----
+tinyint
+1
+0
+(empty)
+(empty)
+n
+int
+31
+0
+(empty)
+(empty)
+rn
+
+query TIITTT
+PREPARE WITH x as (SELECT 1) SELECT 1 as n, row_number() over() as rn FROM
(SELECT * FROM x, info where 0 = info.attribute) as z
+----
+tinyint
+1
+0
+(empty)
+(empty)
+n
+int
+31
+0
+(empty)
+(empty)
+rn
+
+query TIITTT
+PREPARE WITH x as (SELECT 1) SELECT 1 as n, row_number() over() as rn FROM
(SELECT * FROM x, info where 0 = info.attribute) as z
+----
+tinyint
+1
_______________________________________________
checkin-list mailing list -- [email protected]
To unsubscribe send an email to [email protected]