Changeset: d97eed6a6aab for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/d97eed6a6aab
Branch: default
Log Message:

Merge with Dec2025 branch.


diffs (truncated from 3438 to 300 lines):

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
@@ -320,7 +320,6 @@ void GDKqsort(void *restrict h, void *re
 void *GDKrealloc(void *pold, size_t size) __attribute__((__alloc_size__(2))) 
__attribute__((__warn_unused_result__));
 gdk_return GDKrebuild_segment_tree(oid ncount, oid data_size, BAT *st, void 
**segment_tree, oid **levels_offset, oid *nlevels);
 void GDKreset(int status);
-void GDKsetbuf(char *);
 void GDKsetdebug(unsigned debug);
 gdk_return GDKsetenv(const char *name, const char *value);
 stream *GDKstdin;
@@ -382,6 +381,7 @@ 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);
diff --git a/gdk/gdk.h b/gdk/gdk.h
--- a/gdk/gdk.h
+++ b/gdk/gdk.h
@@ -1023,7 +1023,7 @@ BATnegateprops(BAT *b)
        b->tmaxpos = b->tminpos = BUN_NONE;
 }
 
-#define GDKMAXERRLEN   10240
+#define GDKMAXERRLEN   5120
 #define GDKERROR       "!ERROR: "
 #define GDKFATAL       "!FATAL: "
 
@@ -1774,8 +1774,6 @@ gdk_export void ma_info(const allocator 
 #define MA_NEW_ARRAY( sa, type, size )                 (type*)ma_alloc( sa, 
((size)*sizeof(type)))
 #define MA_ZNEW_ARRAY( sa, type, size )                        
(type*)ma_zalloc( sa, ((size)*sizeof(type)))
 #define MA_RENEW_ARRAY( sa, type, ptr, sz, osz )       (type*)ma_realloc( sa, 
ptr, ((sz)*sizeof(type)), ((osz)*sizeof(type)))
-#define MA_STRDUP( sa, s)                              ma_strdup(sa, s)
-#define MA_STRNDUP( sa, s, l)                          ma_strndup(sa, s, l)
 
 
 #if !defined(NDEBUG) && !defined(__COVERITY__) && defined(__GNUC__) && 
!defined(_CLANGD)
@@ -1811,6 +1809,15 @@ gdk_export void ma_info(const allocator 
                          _sa, ma_name(_sa), _ptr, _sz, _osz, _res);    \
                _res;                                                   \
        })
+#define ma_free(sa, p)                                 \
+       ({                                              \
+               allocator *_sa = (sa);                  \
+               void *_p = (p);                         \
+               TRC_DEBUG(ALLOC,                        \
+                         "ma_free(%p(%s),%p)\n",       \
+                         _sa, ma_name(_sa), _p);       \
+               ma_free(_sa, _p);                       \
+       })
 #define ma_strdup(sa, s)                                               \
        ({                                                              \
                allocator *_sa = (sa);                                  \
@@ -1832,7 +1839,18 @@ gdk_export void ma_info(const allocator 
                          _sa, ma_name(_sa), _l, _res);                 \
                _res;                                                   \
        })
-#define create_allocator(sa, nm, lk)                                           
\
+#define ma_strconcat(sa, s1, s2)                                       \
+       ({                                                              \
+               allocator *_sa = (sa);                                  \
+               const char *_s1 = (s1);                                 \
+               const char *_s2 = (s2);                                 \
+               char *_res = ma_strconcat(_sa, _s1, _s2);               \
+               TRC_DEBUG(ALLOC,                                        \
+                         "ma_strconcat(%p(%s),len1=%zu,len2=%zu) -> %p\n", \
+                         _sa, ma_name(_sa), strlen(_s1), strlen(_s2), _res); \
+               _res;                                                   \
+       })
+#define create_allocator(sa, nm, lk)                                   \
        ({                                                              \
                allocator *_sa = (sa);                                  \
                const char *_nm = (nm);                                 \
@@ -1843,6 +1861,41 @@ gdk_export void ma_info(const allocator 
                          _sa, ma_name(_sa), _res, ma_name(_res));      \
                _res;                                                   \
        })
+#define ma_open(sa)                                                    \
+       ({                                                              \
+               allocator *_sa = (sa);                                  \
+               allocator_state _as = ma_open(_sa);                     \
+               TRC_DEBUG(ALLOC,                                        \
+                         "ma_open(%p(%s)) -> tmp_used = %zu\n",        \
+                         _sa, ma_name(_sa), _as.tmp_used);             \
+               _as;                                                    \
+       })
+#define ma_close(sa, as)                                       \
+       ({                                                      \
+               allocator *_sa = (sa);                          \
+               allocator_state *_as = (as);                    \
+               TRC_DEBUG(ALLOC,                                \
+                         "ma_close(%p(%s), tmp_used = %zu)\n", \
+                         _sa, ma_name(_sa), _as->tmp_used);    \
+               ma_close(_sa, _as);                             \
+       })
+#define ma_reset(sa)                                                   \
+       ({                                                              \
+               allocator *_sa = (sa);                                  \
+               allocator *_sa2 = ma_reset(_sa);                        \
+               TRC_DEBUG(ALLOC,                                        \
+                         "ma_reset(%p(%s)) -> %p\n",                   \
+                         _sa, ma_name(_sa), _sa2);                     \
+               _sa2;                                                   \
+       })
+#define ma_destroy(sa)                                 \
+       ({                                              \
+               allocator *_sa = (sa);                  \
+               TRC_DEBUG(ALLOC,                        \
+                         "ma_destroy(%p(%s))\n",       \
+                         _sa, ma_name(_sa));           \
+               ma_destroy(_sa);                        \
+       })
 #endif
 
 #endif /* _GDK_H_ */
diff --git a/gdk/gdk_atoms.c b/gdk/gdk_atoms.c
--- a/gdk/gdk_atoms.c
+++ b/gdk/gdk_atoms.c
@@ -428,7 +428,7 @@ ATOMformat(allocator *ma, int t, const v
                }
                return buf;
        }
-       return MA_STRDUP(ma, "nil");
+       return ma_strdup(ma, "nil");
 }
 
 ptr
diff --git a/gdk/gdk_system.c b/gdk/gdk_system.c
--- a/gdk/gdk_system.c
+++ b/gdk/gdk_system.c
@@ -228,7 +228,8 @@ struct mtthread {
 #endif
        MT_Id tid;
        uintptr_t sp;
-       char *errbuf;
+       char gdkerrbuf[GDKMAXERRLEN];
+       char malexcept[GDKMAXERRLEN];
        struct freebats freebats;
 };
 static struct mtthread mainthread = {
@@ -552,20 +553,6 @@ MT_thread_getname(void)
        return self ? self->threadname : UNKNOWN_THREAD;
 }
 
-void
-GDKsetbuf(char *errbuf)
-{
-       struct mtthread *self;
-
-       self = thread_self();
-       if (self == NULL)
-               self = &mainthread;
-       assert(errbuf == NULL || self->errbuf == NULL);
-       self->errbuf = errbuf;
-       if (errbuf)
-               *errbuf = 0;            /* start clean */
-}
-
 char *
 GDKgetbuf(void)
 {
@@ -574,7 +561,7 @@ GDKgetbuf(void)
        self = thread_self();
        if (self == NULL)
                self = &mainthread;
-       return self->errbuf;
+       return self->gdkerrbuf;
 }
 
 struct freebats *
@@ -651,6 +638,16 @@ 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
@@ -189,8 +189,8 @@ gdk_export MT_Id MT_getpid(void);
 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 void GDKsetbuf(char *);
 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/gdk/gdk_utils.c b/gdk/gdk_utils.c
--- a/gdk/gdk_utils.c
+++ b/gdk/gdk_utils.c
@@ -1903,6 +1903,7 @@ static inline void
 /*
  * Reset allocator to initial state
  */
+#undef ma_reset
 allocator *
 ma_reset(allocator *sa)
 {
@@ -2156,6 +2157,7 @@ ma_zalloc(allocator *sa, size_t sz)
        return r;
 }
 
+#undef ma_destroy
 void
 ma_destroy(allocator *sa)
 {
@@ -2210,6 +2212,7 @@ ma_strdup(allocator *sa, const char *s)
        return ma_strndup(sa, s, strlen(s));
 }
 
+#undef ma_strconcat
 char *
 ma_strconcat(allocator *sa, const char *s1, const char *s2)
 {
@@ -2243,6 +2246,7 @@ ma_get_eb(allocator *sa)
        return &sa->eb;
 }
 
+#undef ma_open
 allocator_state
 ma_open(allocator *sa)
 {
@@ -2264,6 +2268,7 @@ ma_open(allocator *sa)
        return st;
 }
 
+#undef ma_close
 void
 ma_close(allocator *sa, const allocator_state *state)
 {
@@ -2303,6 +2308,7 @@ ma_tmp_active(const allocator *a)
     return a && (a->tmp_used > 0);
 }
 
+#undef ma_free
 void
 ma_free(allocator *sa, void *obj)
 {
diff --git a/gdk/gdk_value.c b/gdk/gdk_value.c
--- a/gdk/gdk_value.c
+++ b/gdk/gdk_value.c
@@ -290,7 +290,7 @@ VALformat(allocator *ma, const ValRecord
 {
        if (res->bat) {
                if (is_bat_nil(res->val.bval)) {
-                       return MA_STRDUP(ma, "nil");
+                       return ma_strdup(ma, "nil");
                }
                else
                        return ATOMformat(ma, TYPE_int, (const void *) 
&res->val.ival);
diff --git a/geom/monetdb5/geom.c b/geom/monetdb5/geom.c
--- a/geom/monetdb5/geom.c
+++ b/geom/monetdb5/geom.c
@@ -2372,11 +2372,11 @@ geoGetType(Client ctx, char **res, int *
 {
        allocator *ma = ctx->curprg->def->ma;
        if (is_int_nil(*info) || is_int_nil(*flag)) {
-               if ((*res = MA_STRDUP(ma, str_nil)) == NULL)
+               if ((*res = ma_strdup(ma, str_nil)) == NULL)
                        throw(MAL, "geom.getType", SQLSTATE(HY013) 
MAL_MALLOC_FAIL);
                return MAL_SUCCEED;
        }
-       if ((*res = MA_STRDUP(ma, geom_type2str(*info >> 2, *flag))) == NULL)
+       if ((*res = ma_strdup(ma, geom_type2str(*info >> 2, *flag))) == NULL)
                throw(MAL, "geom.getType", SQLSTATE(HY013) MAL_MALLOC_FAIL);
        return MAL_SUCCEED;
 }
@@ -2525,7 +2525,7 @@ wkbAsBinary(Client ctx, char **toStr, wk
        int i;
 
        if (is_wkb_nil(*geomWKB)) {
-               if ((*toStr = MA_STRDUP(ma, str_nil)) == NULL)
+               if ((*toStr = ma_strdup(ma, str_nil)) == NULL)
                        throw(MAL, "geom.AsBinary", SQLSTATE(HY013) 
MAL_MALLOC_FAIL);
                return MAL_SUCCEED;
        }
@@ -2721,7 +2721,7 @@ wkbAsText(Client ctx, char **txt, wkb **
        const char sridTxt[] = "SRID:";
 
        if (is_wkb_nil(*geomWKB) || (withSRID && is_int_nil(*withSRID))) {
-               if ((*txt = MA_STRDUP(ma, str_nil)) == NULL)
+               if ((*txt = ma_strdup(ma, str_nil)) == NULL)
                        throw(MAL, "geom.AsText", SQLSTATE(HY013) 
MAL_MALLOC_FAIL);
                return MAL_SUCCEED;
_______________________________________________
checkin-list mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to