Changeset: 38b7e9c52638 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/38b7e9c52638
Modified Files:
sql/backends/monet5/sql_gencode.c
Branch: Dec2025
Log Message:
fixed leak (and using wrong counter for function names) for recompiling
prepared statements.
diffs (51 lines):
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
@@ -1586,7 +1586,8 @@ backend_create_sql_func_body(backend *be
res = -1;
goto cleanup;
}
- f->imp = fimp;
+ if (fimp)
+ f->imp = fimp;
f->instantiated = TRUE; /* make sure 'instantiated' gets set
after 'imp' */
}
MT_lock_unset(&sql_gencodeLock);
@@ -1619,18 +1620,22 @@ backend_create_sql_func(backend *be, sql
exception_buffer ebsave = *ma_get_eb(m->sa);
char befname[IDLENGTH];
int nargs;
- char *fimp;
+ char *fimp = NULL;
/* already instantiated or instantiating a recursive function */
if (f->instantiated || (m->forward && m->forward->base.id ==
f->base.id))
return 0;
- (void) snprintf(befname, sizeof(befname), "f_" ULLFMT,
store_function_counter(m->store));
- TRC_INFO(SQL_PARSER, "Mapping SQL name '%s' to MAL name '%s'\n",
f->base.name, befname);
+ if (!prepare || !f->imp) {
+ (void) snprintf(befname, sizeof(befname), "f_" ULLFMT,
store_function_counter(m->store));
+ TRC_INFO(SQL_PARSER, "Mapping SQL name '%s' to MAL name
'%s'\n", f->base.name, befname);
+ }
nargs = (f->res && f->type == F_UNION ? list_length(f->res) : 1) +
(f->vararg && ops ? list_length(ops) : f->ops ? list_length(f->ops) : 0);
- c->curprg = newFunctionArgs(modname, putName(befname), FUNCTIONsymbol,
nargs);
+ c->curprg = newFunctionArgs(modname, putName(prepare ? f->imp :
befname), FUNCTIONsymbol, nargs);
- if ((fimp = _STRDUP(befname)) == NULL) {
+ if (prepare)
+ fimp = f->imp;
+ if (!fimp && (fimp = _STRDUP(befname)) == NULL) {
sql_error(m, 10, SQLSTATE(HY013) MAL_MALLOC_FAIL);
goto bailout;
} else if (c->curprg == NULL) {
@@ -1648,7 +1653,8 @@ backend_create_sql_func(backend *be, sql
*ma_get_eb(m->sa) = ebsave;
return 0;
bailout:
- _DELETE(fimp);
+ if (!prepare)
+ _DELETE(fimp);
*be = bebackup;
c->curprg = symbackup;
*ma_get_eb(m->sa) = ebsave;
_______________________________________________
checkin-list mailing list -- [email protected]
To unsubscribe send an email to [email protected]