Changeset: 0dc104982efd for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/0dc104982efd
Modified Files:
        gdk/gdk_batop.c
        monetdb5/mal/mal.h
        monetdb5/mal/mal_interpreter.c
        monetdb5/mal/mal_stack.c
        sql/backends/monet5/rel_bin.c
        sql/backends/monet5/sql.c
        sql/backends/monet5/sql_gencode.c
        sql/backends/monet5/sql_rank.c
        sql/backends/monet5/sql_scenario.c
        sql/backends/monet5/sql_statement.c
        sql/server/rel_basetable.c
        sql/server/rel_distribute.c
        sql/server/rel_dump.c
        sql/server/rel_exp.c
        sql/server/rel_exp.h
        sql/server/rel_optimize_others.c
        sql/server/rel_optimize_proj.c
        sql/server/rel_optimizer.c
        sql/server/rel_propagate.c
        sql/server/rel_rel.c
        sql/server/rel_schema.c
        sql/server/rel_select.c
        sql/server/rel_statistics.c
        sql/server/rel_unnest.c
        sql/server/rel_updates.c
        sql/server/sql_atom.c
        sql/server/sql_atom.h
        sql/server/sql_parser.y
        sql/storage/bat/bat_storage.c
        sql/storage/store.c
        testing/Mtest.py.in
Branch: resource_management
Log Message:

merged with default


diffs (truncated from 5575 to 300 lines):

diff --git a/.hgtags b/.hgtags
--- a/.hgtags
+++ b/.hgtags
@@ -844,3 +844,4 @@ ad290be8174693266b1e4eeab06af0266686af38
 53b71d71caccc81358785cb852a186500fc95b08 Mar2025_5
 77b1be95dc79fe61215a34b84ed67e7097323977 Mar2025_7
 6d5be335a6c739e61682366f7a84b67b0cfc0be6 Mar2025_9
+6d5be335a6c739e61682366f7a84b67b0cfc0be6 Mar2025_SP1_release
diff --git a/ChangeLog.Mar2025 b/ChangeLog.Mar2025
--- a/ChangeLog.Mar2025
+++ b/ChangeLog.Mar2025
@@ -1,3 +1,7 @@
 # ChangeLog file for devel
 # This file is updated with Maddlog
 
+* Tue Jul  8 2025 Niels Nes <ni...@cwi.nl>
+- Fixed issue #7655, now the segments keep the number of deleted
+  rows. Only search for reuse when deleted rows are available.
+
diff --git a/gdk/gdk_batop.c b/gdk/gdk_batop.c
--- a/gdk/gdk_batop.c
+++ b/gdk/gdk_batop.c
@@ -2985,9 +2985,11 @@ PROPdestroy_nolock(BAT *b)
 void
 PROPdestroy(BAT *b)
 {
-       MT_lock_set(&b->theaplock);
-       PROPdestroy_nolock(b);
-       MT_lock_unset(&b->theaplock);
+       if (b->tprops) {
+               MT_lock_set(&b->theaplock);
+               PROPdestroy_nolock(b);
+               MT_lock_unset(&b->theaplock);
+       }
 }
 
 ValPtr
diff --git a/gdk/gdk_hash.c b/gdk/gdk_hash.c
--- a/gdk/gdk_hash.c
+++ b/gdk/gdk_hash.c
@@ -1350,7 +1350,7 @@ HASHlist(Hash *h, BUN i)
 void
 HASHdestroy(BAT *b)
 {
-       if (b) {
+       if (b && b->thash) {
                Hash *hs;
                MT_rwlock_wrlock(&b->thashlock);
                hs = b->thash;
diff --git a/gdk/gdk_orderidx.c b/gdk/gdk_orderidx.c
--- a/gdk/gdk_orderidx.c
+++ b/gdk/gdk_orderidx.c
@@ -534,7 +534,7 @@ OIDXfree(BAT *b)
 void
 OIDXdestroy(BAT *b)
 {
-       if (b) {
+       if (b && b->torderidx) {
                Heap *hp;
 
                MT_lock_set(&b->batIdxLock);
diff --git a/gdk/gdk_strimps.c b/gdk/gdk_strimps.c
--- a/gdk/gdk_strimps.c
+++ b/gdk/gdk_strimps.c
@@ -1012,7 +1012,7 @@ STRMPincref(Strimps *strimps)
 void
 STRMPdestroy(BAT *b)
 {
-       if (b) {
+       if (b && b->tstrimps) {
                MT_lock_set(&b->batIdxLock);
                if (b->tstrimps == (Strimps *)1) {
                        b->tstrimps = NULL;
diff --git a/monetdb5/mal/mal.h b/monetdb5/mal/mal.h
--- a/monetdb5/mal/mal.h
+++ b/monetdb5/mal/mal.h
@@ -219,7 +219,6 @@ typedef struct MALSTK {
  * It is handy to administer the timing in the stack frame
  * for use in profiling instructions.
  */
-       struct timeval clock;           /* time this stack was created */
        char status;                            /* running 'R' suspended 'S', 
quitting 'Q' */
        int pcup;                                       /* saved pc upon a 
recursive all */
        oid tag;                                        /* unique invocation 
call tag */
diff --git a/monetdb5/mal/mal_interpreter.c b/monetdb5/mal/mal_interpreter.c
--- a/monetdb5/mal/mal_interpreter.c
+++ b/monetdb5/mal/mal_interpreter.c
@@ -513,7 +513,7 @@ runMALsequence(allocator *tmp_alloc, Cli
        if (startpc + 1 == stoppc) {
                pci = getInstrPtr(mb, startpc);
                if (pci->argc > 16) {
-                       backup = ma_alloc(tmp_alloc, pci->argc * 
sizeof(ValRecord));
+                       backup = ma_alloc(tmp_alloc, pci->retc * 
sizeof(ValRecord));
                        garbage = (int *) ma_zalloc(tmp_alloc, pci->argc * 
sizeof(int));
                        if (backup == NULL || garbage == NULL) {
                                //GDKfree(backup);
@@ -650,9 +650,8 @@ runMALsequence(allocator *tmp_alloc, Cli
                 * garbage collected are identified. In the post-execution
                 * phase they are removed.
                 */
-               for (int i = 0; i < pci->retc; i++) {
+               for (int i = 0; i < pci->retc; i++)
                        backup[i] = stk->stk[getArg(pci, i)];
-               }
 
                if (garbageControl(pci)) {
                        for (int i = 0; i < pci->argc; i++) {
@@ -693,8 +692,7 @@ runMALsequence(allocator *tmp_alloc, Cli
                                        ret = createException(MAL, 
"mal.interpreter",
                                                                                
  SQLSTATE(HY013) MAL_MALLOC_FAIL);
                                        break;
-                               }
-                               if (lhs->bat && !is_bat_nil(lhs->val.bval))
+                               } else if (lhs->bat && 
!is_bat_nil(lhs->val.bval))
                                        BBPretain(lhs->val.bval);
                        }
                        break;
@@ -808,8 +806,7 @@ runMALsequence(allocator *tmp_alloc, Cli
                                        ret = createException(MAL, 
"mal.interpreter",
                                                                                
  SQLSTATE(HY013) MAL_MALLOC_FAIL);
                                        break;
-                               }
-                               if (lhs->bat)
+                               } else if (lhs->bat)
                                        BBPretain(lhs->val.bval);
                        }
                        if (ret == MAL_SUCCEED && ii == pci->argc) {
@@ -992,8 +989,6 @@ runMALsequence(allocator *tmp_alloc, Cli
                                if (v->val.sval && v->allocated)
                                        freeException(v->val.sval);     /* old 
exception */
                                VALset(v, TYPE_str, ret);
-                               //v->allocated = true;
-                               freeException(ret);
                                ret = MAL_SUCCEED;
                                MT_lock_unset(&mal_contextLock);
                        } else {
@@ -1225,8 +1220,7 @@ runMALsequence(allocator *tmp_alloc, Cli
                                                ret = createException(MAL, 
"mal.interpreter",
                                                                                
          SQLSTATE(HY013) MAL_MALLOC_FAIL);
                                                break;
-                                       }
-                                       if (lhs->bat)
+                                       } else if (lhs->bat)
                                                BBPretain(lhs->val.bval);
                                }
                                if (garbageControl(getInstrPtr(mb, 0)))
diff --git a/monetdb5/mal/mal_stack.c b/monetdb5/mal/mal_stack.c
--- a/monetdb5/mal/mal_stack.c
+++ b/monetdb5/mal/mal_stack.c
@@ -56,11 +56,25 @@ newGlobalStack(allocator *alloc, int siz
 {
        MalStkPtr s;
 
-       s = (MalStkPtr) alloc? ma_zalloc(alloc, stackSize(size)) : 
GDKzalloc(stackSize(size));
+       s = (MalStkPtr) alloc? ma_alloc(alloc, stackSize(size)) : 
GDKmalloc(stackSize(size));
        if (!s)
                return NULL;
        s->allocated = !alloc;
        s->stksize = size;
+       s->stktop = s->stkbot = s->stkdepth = s->calldepth = 0;
+    s->keepAlive = s->keepTmps = 0;
+    s->admit = s->wrapup = NULL;
+
+    s->status = 0;
+    s->pcup = 0;
+    s->tag = 0;
+    s->memory = 0;
+    s->up = NULL;
+       s->blk = NULL;
+       for(int i = 0; i < size; i++) {
+               s->stk[i].vtype = 0;
+               s->stk[i].bat = false;
+       }
        return s;
 }
 
diff --git a/sql/backends/monet5/rel_bin.c b/sql/backends/monet5/rel_bin.c
--- a/sql/backends/monet5/rel_bin.c
+++ b/sql/backends/monet5/rel_bin.c
@@ -484,7 +484,7 @@ handle_in_tuple_exps(backend *be, sql_ex
                lstmts = append(lstmts, c);
        }
 
-       sql_subtype *bt = sql_bind_localtype("bit");
+       sql_subtype *bt = sql_fetch_localtype(TYPE_bit);
        sql_subfunc *and = sql_bind_func(sql, "sys", "and", bt, bt, F_FUNC, 
true, true);
        sql_subfunc *or = sql_bind_func(sql, "sys", "or", bt, bt, F_FUNC, true, 
true);
        for (node *n = nl->h; n; n = n->next) {
@@ -537,7 +537,7 @@ handle_in_exps(backend *be, sql_exp *ce,
                c = stmt_const(be, bin_find_smallest_column(be, left), c);
 
        if (c->nrcols == 0 || depth || !reduce) {
-               sql_subtype *bt = sql_bind_localtype("bit");
+               sql_subtype *bt = sql_fetch_localtype(TYPE_bit);
                sql_subfunc *cmp = (in)
                        ?sql_bind_func(sql, "sys", "=", tail_type(c), 
tail_type(c), F_FUNC, true, true)
                        :sql_bind_func(sql, "sys", "<>", tail_type(c), 
tail_type(c), F_FUNC, true, true);
@@ -693,7 +693,7 @@ exp_count_no_nil_arg(sql_exp *e, stmt *e
 static stmt *
 exp_bin_conjunctive(backend *be, sql_exp *e, stmt *left, stmt *right, stmt 
*grp, stmt *ext, stmt *cnt, stmt *sel, int depth, bool reduce, int push)
 {
-       sql_subtype *bt = sql_bind_localtype("bit");
+       sql_subtype *bt = sql_fetch_localtype(TYPE_bit);
        list *l = e->l;
        node *n;
        stmt *sel1 = NULL, *s = NULL;
@@ -753,7 +753,7 @@ exp_bin_conjunctive(backend *be, sql_exp
 static stmt *
 exp_bin_disjunctive(backend *be, sql_exp *e, stmt *left, stmt *right, stmt 
*grp, stmt *ext, stmt *cnt, stmt *sel, int depth, bool reduce, int push)
 {
-       sql_subtype *bt = sql_bind_localtype("bit");
+       sql_subtype *bt = sql_fetch_localtype(TYPE_bit);
        list *l = e->l;
        node *n;
        stmt *s = NULL, *cur = NULL;
@@ -800,7 +800,7 @@ exp2bin_case(backend *be, sql_exp *fe, s
        stmt *res = NULL, *ires = NULL, *rsel = NULL, *osel = NULL, *ncond = 
NULL, *ocond = NULL, *cond = NULL;
        int next_cond = 1, single_value = (fe->card <= CARD_ATOM && (!left || 
!left->nrcols));
        char name[16], *nme = NULL;
-       sql_subtype *bt = sql_bind_localtype("bit");
+       sql_subtype *bt = sql_fetch_localtype(TYPE_bit);
        sql_subfunc *not = sql_bind_func(be->mvc, "sys", "not", bt, NULL, 
F_FUNC, true, true);
        sql_subfunc *or = sql_bind_func(be->mvc, "sys", "or", bt, bt, F_FUNC, 
true, true);
        sql_subfunc *and = sql_bind_func(be->mvc, "sys", "and", bt, bt, F_FUNC, 
true, true);
@@ -969,7 +969,7 @@ exp2bin_casewhen(backend *be, sql_exp *f
        stmt *res = NULL, *ires = NULL, *rsel = NULL, *osel = NULL, *ncond = 
NULL, *ocond = NULL, *cond = NULL;
        int next_cond = 1, single_value = (fe->card <= CARD_ATOM && (!left || 
!left->nrcols));
        char name[16], *nme = NULL;
-       sql_subtype *bt = sql_bind_localtype("bit");
+       sql_subtype *bt = sql_fetch_localtype(TYPE_bit);
        sql_subfunc *not = sql_bind_func(be->mvc, "sys", "not", bt, NULL, 
F_FUNC, true, true);
        sql_subfunc *or = sql_bind_func(be->mvc, "sys", "or", bt, bt, F_FUNC, 
true, true);
        sql_subfunc *and = sql_bind_func(be->mvc, "sys", "and", bt, bt, F_FUNC, 
true, true);
@@ -1152,7 +1152,7 @@ exp2bin_coalesce(backend *be, sql_exp *f
        stmt *res = NULL, *rsel = NULL, *osel = NULL, *ncond = NULL, *ocond = 
NULL;
        int single_value = (fe->card <= CARD_ATOM && (!left || !left->nrcols));
        char name[16], *nme = NULL;
-       sql_subtype *bt = sql_bind_localtype("bit");
+       sql_subtype *bt = sql_fetch_localtype(TYPE_bit);
        sql_subfunc *and = sql_bind_func(be->mvc, "sys", "and", bt, bt, F_FUNC, 
true, true);
        sql_subfunc *not = sql_bind_func(be->mvc, "sys", "not", bt, NULL, 
F_FUNC, true, true);
 
@@ -2737,8 +2737,8 @@ rel2bin_hash_lookup(backend *be, sql_rel
 {
        mvc *sql = be->mvc;
        node *n;
-       sql_subtype *it = sql_bind_localtype("int");
-       sql_subtype *lng = sql_bind_localtype("lng");
+       sql_subtype *it = sql_fetch_localtype(TYPE_int);
+       sql_subtype *lng = sql_fetch_localtype(TYPE_lng);
        stmt *h = NULL;
        stmt *bits = stmt_atom_int(be, 1 + 
((sizeof(lng)*8)-1)/(list_length(i->columns)+1));
        sql_exp *e = en->data;
@@ -2814,8 +2814,8 @@ join_hash_key(backend *be, list *l)
        stmt *h = NULL;
        stmt *bits = stmt_atom_int(be, 1 + 
((sizeof(lng)*8)-1)/(list_length(l)+1));
 
-       it = sql_bind_localtype("int");
-       lng = sql_bind_localtype("lng");
+       it = sql_fetch_localtype(TYPE_int);
+       lng = sql_fetch_localtype(TYPE_lng);
        for (m = l->h; m; m = m->next) {
                stmt *s = m->data;
 
@@ -3208,7 +3208,7 @@ rel2bin_groupjoin(backend *be, sql_rel *
                                if (exp_is_atom(e) && need_no_nil(e))
                                        m = sql_Nop_(be, "ifthenelse", 
sql_unop_(be, "isnull", m), stmt_bool(be, false), m, NULL);
                                if (!exist) {
-                                       sql_subtype *bt = 
sql_bind_localtype("bit");
+                                       sql_subtype *bt = 
sql_fetch_localtype(TYPE_bit);
                                        sql_subfunc *not = 
sql_bind_func(be->mvc, "sys", "not", bt, NULL, F_FUNC, true, true);
                                        m = stmt_unop(be, m, NULL, not);
                                }
@@ -3494,7 +3494,7 @@ rel2bin_join(backend *be, sql_rel *rel, 
 
                stmt *s = stmt_unop(be, last, NULL, isnil);
 
-               sql_subtype *bt = sql_bind_localtype("bit");
+               sql_subtype *bt = sql_fetch_localtype(TYPE_bit);
                sql_subfunc *not = sql_bind_func(be->mvc, "sys", "not", bt, 
NULL, F_FUNC, true, true);
 
                s = stmt_unop(be, s, NULL, not);
@@ -3620,7 +3620,7 @@ rel2bin_antijoin(backend *be, sql_rel *r
                        stmt *s = exp_bin(be, en->data, sub, NULL, NULL, NULL, 
NULL, NULL /* sel */, 0, 0/* just the project call not the select*/, 0);
 
                        /* ifthenelse if (not(predicate)) then false else true 
(needed for antijoin) */
-                       sql_subtype *bt = sql_bind_localtype("bit");
+                       sql_subtype *bt = sql_fetch_localtype(TYPE_bit);
                        sql_subfunc *not = sql_bind_func(be->mvc, "sys", "not", 
bt, NULL, F_FUNC, true, true);
                        s = stmt_unop(be, s, NULL, not);
                        s = sql_Nop_(be, "ifthenelse", s, stmt_bool(be, 0), 
stmt_bool(be, 1), NULL);
@@ -4101,7 +4101,7 @@ stmt_limit_value(backend *be, sql_rel *t
                        if(!l)
                                return NULL;
                        if (oe) {
-                               sql_subtype *lng = sql_bind_localtype("lng");
+                               sql_subtype *lng = 
sql_fetch_localtype(TYPE_lng);
                                sql_subfunc *add = 
sql_bind_func_result(be->mvc, "sys", "sql_add", F_FUNC, true, lng, 2, lng, lng);
                                stmt *o = exp_bin(be, oe, NULL, NULL, NULL, 
NULL, NULL, NULL, 0, 0, 0);
                                if(!o)
_______________________________________________
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org

Reply via email to