Changeset: 788ac4a4e0b9 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/788ac4a4e0b9
Modified Files:
buildtools/coverity_model.c
clients/Tests/exports.stable.out
gdk/gdk_system.c
gdk/gdk_system.h
geom/monetdb5/geom.c
geom/monetdb5/geom_atoms.c
monetdb5/mal/mal.c
monetdb5/mal/mal_authorize.c
monetdb5/mal/mal_builder.c
monetdb5/mal/mal_client.c
monetdb5/mal/mal_dataflow.c
monetdb5/mal/mal_exception.c
monetdb5/mal/mal_exception.h
monetdb5/mal/mal_import.c
monetdb5/mal/mal_instruction.c
monetdb5/mal/mal_interpreter.c
monetdb5/mal/mal_linker.c
monetdb5/mal/mal_module.c
monetdb5/mal/mal_parser.c
monetdb5/mal/mal_private.h
monetdb5/mal/mal_scenario.c
monetdb5/mal/mal_session.c
monetdb5/modules/atoms/json.c
monetdb5/modules/atoms/xml.c
monetdb5/modules/mal/mal_mapi.c
monetdb5/modules/mal/remote.c
monetdb5/modules/mal/tablet.c
monetdb5/optimizer/opt_evaluate.c
monetdb5/optimizer/opt_mergetable.c
monetdb5/optimizer/opt_remap.c
monetdb5/optimizer/opt_wrapper.c
sql/backends/monet5/UDF/pyapi3/connection3.c
sql/backends/monet5/UDF/pyapi3/conversion3.c
sql/backends/monet5/UDF/pyapi3/emit3.c
sql/backends/monet5/sql_cat.c
sql/backends/monet5/sql_execute.c
sql/backends/monet5/sql_gencode.c
sql/backends/monet5/sql_optimizer.c
sql/backends/monet5/sql_result.c
sql/backends/monet5/sql_scenario.c
sql/backends/monet5/sql_statement.c
sql/backends/monet5/sql_upgrades.c
sql/backends/monet5/sql_user.c
sql/server/rel_statistics_functions.c
sql/server/sql_mvc.c
tools/monetdbe/monetdbe.c
tools/mserver/mserver5.c
tools/mserver/shutdowntest.c
Branch: Dec2025
Log Message:
Reworking of exception handling.
MAL exceptions are now allocated using a per client context allocator
which is reset between queries.
diffs (truncated from 1839 to 300 lines):
diff --git a/buildtools/coverity_model.c b/buildtools/coverity_model.c
--- a/buildtools/coverity_model.c
+++ b/buildtools/coverity_model.c
@@ -17,9 +17,7 @@
* during any analysis they do on our code.
*
* We model our use of the various allocation functions.
- * Things we want to do is model that GDKmalloc and friends are paired
- * with GDKfree, and that exceptions created by createException and
- * createMalException should be freed with freeException.
+ * For now, we model that GDKmalloc and friends are paired with GDKfree.
*
* author: Sjoerd Mullender
*/
@@ -145,69 +143,3 @@ GDKmremap(const char *path, int mode, vo
}
return p;
}
-
-typedef struct {} *MalBlkPtr;
-enum malexception {
- MAL,
- ILLARG /*,
- OUTOFBNDS,
- IO,
- INVCRED,
- OPTIMIZER,
- STKOF,
- SYNTAX,
- TYPE,
- LOADER,
- PARSE,
- ARITH,
- PERMD,
- SQL */
-};
-
-char *
-createException(enum malexception type, const char *fcn, const char *format,
...)
-{
- char *p;
- __coverity_format_string_sink__(format);
- p = __coverity_alloc_nosize__();
- __coverity_mark_as_afm_allocated__(p, "freeException");
- return p;
-}
-
-char *
-createMalException(MalBlkPtr mb, int pc, enum malexception type, const char
*format, ...)
-{
- char *p;
- __coverity_format_string_sink__(format);
- p = __coverity_alloc_nosize__();
- __coverity_mark_as_afm_allocated__(p, "freeException");
- return p;
-}
-
-char *
-dupError(const char *err)
-{
- char *p;
- p = __coverity_alloc_nosize__();
- __coverity_mark_as_afm_allocated__(p, "freeException");
- return p;
-}
-
-void
-freeException(char *p)
-{
- if (p) {
- __coverity_free__(p);
- __coverity_mark_as_afm_freed__(p, "freeException");
- }
-}
-
-char *
-concatErrors(char *err1, const char *err2)
-{
- char *p;
- freeException(err1);
- p = __coverity_alloc_nosize__();
- __coverity_mark_as_afm_allocated__(p, "freeException");
- return p;
-}
diff --git a/clients/Tests/exports.stable.out b/clients/Tests/exports.stable.out
--- a/clients/Tests/exports.stable.out
+++ b/clients/Tests/exports.stable.out
@@ -379,7 +379,6 @@ int MT_join_thread(MT_Id t);
bool MT_path_absolute(const char *path);
void MT_sleep_ms(unsigned int ms);
void MT_thread_deregister(void);
-char *MT_thread_get_exceptbuf(void);
QryCtx *MT_thread_get_qry_ctx(void);
const char *MT_thread_getalgorithm(void);
allocator *MT_thread_getallocator(void);
@@ -838,7 +837,6 @@ const char alter_set_tableRef[];
const char alter_tableRef[];
const char alter_userRef[];
const char appendBulkRef[];
-str appendException(enum malexception, const char *, _In_z_
_Printf_format_string_ const char *, ...) __attribute__((__malloc__))
__attribute__((__format__(__printf__, 3, 4)))
__attribute__((__returns_nonnull__));
const char appendRef[];
const char assertRef[];
const char avgRef[];
@@ -885,7 +883,7 @@ void clrInstruction(InstrPtr p);
const char columnBindRef[];
const char comment_onRef[];
const char compressRef[];
-char *concatErrors(const char *err1, const char *err2)
__attribute__((__nonnull__(1, 2))) __attribute__((__returns_nonnull__));
+char *concatErrors(char *err1, const char *err2) __attribute__((__nonnull__(1,
2))) __attribute__((__returns_nonnull__));
const char connectRef[];
const char containsRef[];
str convertConstant(allocator *ma, malType type, ValPtr vr);
@@ -897,8 +895,8 @@ const char corrRef[];
const char countRef[];
const char count_no_nilRef[];
int cpyConstant(MalBlkPtr mb, VarPtr vr);
-str createException(enum malexception, const char *, _In_z_
_Printf_format_string_ const char *, ...) __attribute__((__malloc__))
__attribute__((__malloc__(freeException, 1)))
__attribute__((__format__(__printf__, 3, 4)))
__attribute__((__returns_nonnull__));
-str createMalException(MalBlkPtr, int, enum malexception, _In_z_
_Printf_format_string_ const char *, ...) __attribute__((__malloc__))
__attribute__((__malloc__(freeException, 1)))
__attribute__((__format__(__printf__, 4, 5)))
__attribute__((__returns_nonnull__));
+str createException(enum malexception, const char *, _In_z_
_Printf_format_string_ const char *, ...) __attribute__((__malloc__))
__attribute__((__format__(__printf__, 3, 4)))
__attribute__((__returns_nonnull__));
+str createMalException(MalBlkPtr, int, enum malexception, _In_z_
_Printf_format_string_ const char *, ...) __attribute__((__malloc__))
__attribute__((__format__(__printf__, 4, 5)))
__attribute__((__returns_nonnull__));
const char create_functionRef[];
const char create_roleRef[];
const char create_schemaRef[];
@@ -967,7 +965,6 @@ const char firstnRef[];
Module fixModule(const char *nme);
int fndConstant(MalBlkPtr mb, const ValRecord *cst, int depth);
const char forRef[];
-void freeException(str);
void freeInstruction(MalBlkPtr mb, InstrPtr p);
void freeMalBlk(MalBlkPtr mb);
void freeModule(Module cur);
diff --git a/gdk/gdk_system.c b/gdk/gdk_system.c
--- a/gdk/gdk_system.c
+++ b/gdk/gdk_system.c
@@ -229,7 +229,6 @@ struct mtthread {
MT_Id tid;
uintptr_t sp;
char gdkerrbuf[GDKMAXERRLEN];
- char malexcept[GDKMAXERRLEN];
struct freebats freebats;
};
static struct mtthread mainthread = {
@@ -638,16 +637,6 @@ MT_thread_get_qry_ctx(void)
return self ? self->qry_ctx : NULL;
}
-char *
-MT_thread_get_exceptbuf(void)
-{
- if (!thread_initialized)
- return NULL;
- struct mtthread *self = thread_self();
-
- return self ? self->malexcept : NULL;
-}
-
void
MT_thread_setlockwait(MT_Lock *lock)
{
diff --git a/gdk/gdk_system.h b/gdk/gdk_system.h
--- a/gdk/gdk_system.h
+++ b/gdk/gdk_system.h
@@ -169,6 +169,7 @@ typedef struct QryCtx {
struct bstream *bs;
ATOMIC_TYPE datasize;
ATOMIC_BASE_TYPE maxmem;
+ allocator *errorallocator;
} QryCtx;
gdk_export bool THRhighwater(void);
@@ -190,7 +191,6 @@ gdk_export int MT_join_thread(MT_Id t);
gdk_export QryCtx *MT_thread_get_qry_ctx(void);
gdk_export void MT_thread_set_qry_ctx(QryCtx *ctx);
gdk_export char *GDKgetbuf(void);
-gdk_export char *MT_thread_get_exceptbuf(void);
#if SIZEOF_VOID_P == 4
/* "limited" stack size on 32-bit systems */
diff --git a/geom/monetdb5/geom.c b/geom/monetdb5/geom.c
--- a/geom/monetdb5/geom.c
+++ b/geom/monetdb5/geom.c
@@ -3478,11 +3478,7 @@ wkbMakeLineAggr(Client ctx, wkb **outWKB
bat_iterator_end(&inBAT_iter);
err = wkbFromWKB(ctx, outWKB, &aWKB);
BBPunfix(inBAT->batCacheid);
- if (err) {
- freeException(err);
- throw(MAL, "geom.MakeLine", SQLSTATE(HY013)
MAL_MALLOC_FAIL);
- }
- return MAL_SUCCEED;
+ return err;
}
bWKB = (wkb *) BUNtvar(inBAT_iter, 1);
//create the first line using the first two geometries
@@ -4611,11 +4607,7 @@ wkbUnionAggr(Client ctx, wkb **outWKB, b
bat_iterator_end(&inBAT_iter);
err = wkbFromWKB(ctx, outWKB, &aWKB);
BBPunfix(inBAT->batCacheid);
- if (err) {
- freeException(err);
- throw(MAL, "geom.Union", SQLSTATE(HY013)
MAL_MALLOC_FAIL);
- }
- return MAL_SUCCEED;
+ return err;
}
bWKB = (wkb *) BUNtvar(inBAT_iter, 1);
//create the first union using the first two geometries
diff --git a/geom/monetdb5/geom_atoms.c b/geom/monetdb5/geom_atoms.c
--- a/geom/monetdb5/geom_atoms.c
+++ b/geom/monetdb5/geom_atoms.c
@@ -99,7 +99,6 @@ wkbFROMSTR(allocator *ma, const char *ge
err = wkbFROMSTR_withSRID(ma, geomWKT, len, geomWKB, 0, &parsedBytes);
if (err != MAL_SUCCEED) {
GDKerror("%s", getExceptionMessageAndState(err));
- freeException(err);
return -1;
}
return (ssize_t) parsedBytes;
diff --git a/monetdb5/mal/mal.c b/monetdb5/mal/mal.c
--- a/monetdb5/mal/mal.c
+++ b/monetdb5/mal/mal.c
@@ -95,7 +95,6 @@ mal_init(char *modules[], bool embedded,
if (err != MAL_SUCCEED) {
mal_client_reset();
TRC_CRITICAL(MAL_SERVER, "%s\n", err);
- freeException(err);
return -1;
}
initProfiler();
diff --git a/monetdb5/mal/mal_authorize.c b/monetdb5/mal/mal_authorize.c
--- a/monetdb5/mal/mal_authorize.c
+++ b/monetdb5/mal/mal_authorize.c
@@ -89,7 +89,7 @@ AUTHunlockVault(const char *password)
vaultKey = GDKstrdup(password);
if (vaultKey == NULL) {
MT_rwlock_wrunlock(&rt_lock);
- throw(MAL, "unlockVault", SQLSTATE(HY013) MAL_MALLOC_FAIL "
vault key");
+ return "unlockVault:" SQLSTATE(HY013) MAL_MALLOC_FAIL " vault
key";
}
MT_rwlock_wrunlock(&rt_lock);
return (MAL_SUCCEED);
diff --git a/monetdb5/mal/mal_builder.c b/monetdb5/mal/mal_builder.c
--- a/monetdb5/mal/mal_builder.c
+++ b/monetdb5/mal/mal_builder.c
@@ -38,7 +38,6 @@ newAssignmentArgs(MalBlkPtr mb, int args
str msg = createException(MAL, "newAssignment",
"Can not
allocate variable");
addMalException(mb, msg);
- freeException(msg);
freeInstruction(mb, q);
return NULL;
}
@@ -76,7 +75,6 @@ newStmtArgs(MalBlkPtr mb, const char *mo
str msg = createException(MAL, "newStmtArgs",
"Can not
allocate variable");
addMalException(mb, msg);
- freeException(msg);
freeInstruction(mb, q);
return NULL;
}
@@ -131,7 +129,6 @@ newComment(MalBlkPtr mb, const char *val
if (VALinit(mb->ma, &cst, TYPE_str, val) == NULL) {
str msg = createException(MAL, "newComment", "Can not allocate
comment");
addMalException(mb, msg);
- freeException(msg);
freeInstruction(mb, q);
return NULL;
}
@@ -161,7 +158,6 @@ newCatchStmt(MalBlkPtr mb, const char *n
str msg = createException(MAL, "newCatchStmt",
"Can
not allocate variable");
addMalException(mb, msg);
- freeException(msg);
freeInstruction(mb, q);
return NULL;
}
@@ -185,7 +181,6 @@ newRaiseStmt(MalBlkPtr mb, const char *n
str msg = createException(MAL, "newRaiseStmt",
"Can
not allocate variable");
addMalException(mb, msg);
- freeException(msg);
freeInstruction(mb, q);
return NULL;
}
@@ -209,7 +204,6 @@ newExitStmt(MalBlkPtr mb, const char *nm
str msg = createException(MAL, "newExitStmt",
"Can
not allocate variable");
addMalException(mb, msg);
- freeException(msg);
freeInstruction(mb, q);
return NULL;
}
@@ -491,7 +485,6 @@ pushStr(MalBlkPtr mb, InstrPtr q, const
str msg = createException(MAL, "pushStr",
"Can not
allocate string variable");
addMalException(mb, msg);
- freeException(msg);
} else {
_t = defConstant(mb, TYPE_str, &cst);
if (_t >= 0)
_______________________________________________
checkin-list mailing list -- [email protected]
To unsubscribe send an email to [email protected]