MonetDB: Dec2023 - fixed exp_ref bug
Changeset: f0c006e026ba for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/f0c006e026ba Modified Files: sql/server/rel_optimize_proj.c sql/test/BugTracker-2024/Tests/exp_ref-Bug-7479.test Branch: Dec2023 Log Message: fixed exp_ref bug diffs (59 lines): diff --git a/sql/server/rel_optimize_proj.c b/sql/server/rel_optimize_proj.c --- a/sql/server/rel_optimize_proj.c +++ b/sql/server/rel_optimize_proj.c @@ -90,6 +90,8 @@ rel_push_project_down_(visitor *v, sql_r } } } + /* ToDo handle usefull renames, ie new relation name and unique set of attribute names (could reduce set of * attributes) */ + /* handle both useless and usefull with project [ group by ] */ return rel; } @@ -391,6 +393,7 @@ exp_rename(mvc *sql, sql_exp *e, sql_rel } if (!ne) return e; + sql_exp *oe = e; e = NULL; if (exp_name(ne) && ne->r && ne->l) e = rel_bind_column2(sql, t, ne->l, ne->r, 0); @@ -401,6 +404,7 @@ exp_rename(mvc *sql, sql_exp *e, sql_rel sql->errstr[0] = 0; if (exp_is_atom(ne)) return ne; + return oe; } return exp_ref(sql, e); case e_cmp: diff --git a/sql/test/BugTracker-2024/Tests/exp_ref-Bug-7479.test b/sql/test/BugTracker-2024/Tests/exp_ref-Bug-7479.test --- a/sql/test/BugTracker-2024/Tests/exp_ref-Bug-7479.test +++ b/sql/test/BugTracker-2024/Tests/exp_ref-Bug-7479.test @@ -10,23 +10,16 @@ WITH x AS ( SELECT 1 x UNION SELECT - '1 1 1 -query IRI nosort +statment error syntax error, unexpected ')' in: "with x as ( select 1 x union select - '199419' ) select 1 from x as where x in (" WITH x AS ( SELECT 1 x UNION SELECT - '199419' ) SELECT 1 FROM x AS WHERE x IN ( SELECT min ( x ) OVER ( PARTITION BY x ) AS ) -1 -1.000 -1 -1 --199419.000 -1 -skipif knownfail query T nosort WITH x AS ( SELECT 1 x UNION SELECT - '199419' ) SELECT 1 FROM x AS WHERE x IN ( SELECT x FROM x , ( SELECT min ( x ) OVER ( PARTITION BY x ) ) AS ) +1 +1 -skipif knownfail -query T nosort +statment error GDK reported error: BATsubcross: more than one match SELECT ( WITH x AS ( SELECT 1 x UNION SELECT - '199419' ) SELECT 1 FROM x AS WHERE x IN ( SELECT x FROM x , ( SELECT min ( x ) OVER ( PARTITION BY x ) ) AS ) ) - ___ checkin-list mailing list -- checkin-list@monetdb.org To unsubscribe send an email to checkin-list-le...@monetdb.org
MonetDB: default - Merge with Dec2023 branch.
Changeset: 9b5649554a35 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/9b5649554a35 Modified Files: sql/test/miscellaneous/Tests/simple_plans.test testing/sqllogictest.py Branch: default Log Message: Merge with Dec2023 branch. diffs (92 lines): diff --git a/sql/test/miscellaneous/Tests/simple_plans.test b/sql/test/miscellaneous/Tests/simple_plans.test --- a/sql/test/miscellaneous/Tests/simple_plans.test +++ b/sql/test/miscellaneous/Tests/simple_plans.test @@ -208,7 +208,7 @@ EXPLAIN SELECT 1 FROM another_t t1 INNER algebra.project 1 algebra.projection -3 +2 algebra.rangejoin 1 bat.pack @@ -216,7 +216,7 @@ 5 querylog.define 1 sql.bind -2 +1 sql.mvc 1 sql.resultSet @@ -232,7 +232,7 @@ EXPLAIN SELECT 1 FROM another_t t1 INNER algebra.project 1 algebra.projection -3 +2 algebra.rangejoin 1 bat.pack @@ -240,7 +240,7 @@ 5 querylog.define 1 sql.bind -2 +1 sql.mvc 1 sql.resultSet @@ -256,7 +256,7 @@ EXPLAIN SELECT 1 FROM another_t t1 INNER algebra.project 2 algebra.projection -3 +2 algebra.rangejoin 1 bat.pack @@ -264,7 +264,7 @@ 5 querylog.define 1 sql.bind -2 +1 sql.mvc 1 sql.resultSet @@ -282,7 +282,7 @@ 1 algebra.project 1 algebra.projection -3 +2 bat.pack 5 bat.single @@ -290,7 +290,7 @@ 2 querylog.define 1 sql.bind -2 +1 sql.mvc 1 sql.resultSet diff --git a/testing/sqllogictest.py b/testing/sqllogictest.py --- a/testing/sqllogictest.py +++ b/testing/sqllogictest.py @@ -545,8 +545,12 @@ class SQLLogic: m.update(b'\n') result.append(col) if err and expected is not None: +recv = [] +for row in ndata: +for col in row: +recv.append(col) print('Differences:', file=self.out) -self.out.writelines(list(difflib.ndiff([x + '\n' for x in expected], [x + '\n' for x in ndata]))) +self.out.writelines(list(difflib.ndiff([x + '\n' for x in expected], [x + '\n' for x in recv]))) if resdata is not None: result = [] for row in resdata: ___ checkin-list mailing list -- checkin-list@monetdb.org To unsubscribe send an email to checkin-list-le...@monetdb.org
MonetDB: Dec2023 - Plan changed after changeset 9481eab21f67.
Changeset: 98b77f8e9a02 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/98b77f8e9a02 Modified Files: sql/test/miscellaneous/Tests/simple_plans.test Branch: Dec2023 Log Message: Plan changed after changeset 9481eab21f67. diffs (78 lines): diff --git a/sql/test/miscellaneous/Tests/simple_plans.test b/sql/test/miscellaneous/Tests/simple_plans.test --- a/sql/test/miscellaneous/Tests/simple_plans.test +++ b/sql/test/miscellaneous/Tests/simple_plans.test @@ -208,7 +208,7 @@ EXPLAIN SELECT 1 FROM another_t t1 INNER algebra.project 1 algebra.projection -3 +2 algebra.rangejoin 1 bat.pack @@ -216,7 +216,7 @@ 5 querylog.define 1 sql.bind -2 +1 sql.mvc 1 sql.resultSet @@ -232,17 +232,17 @@ EXPLAIN SELECT 1 FROM another_t t1 INNER algebra.project 1 algebra.projection -3 +2 algebra.rangejoin 1 bat.pack 5 batcalc.lng -2 +1 querylog.define 1 sql.bind -2 +1 sql.mvc 1 sql.resultSet @@ -258,7 +258,7 @@ EXPLAIN SELECT 1 FROM another_t t1 INNER algebra.project 2 algebra.projection -3 +2 algebra.rangejoin 1 bat.pack @@ -266,7 +266,7 @@ 5 querylog.define 1 sql.bind -2 +1 sql.mvc 1 sql.resultSet @@ -284,7 +284,7 @@ 1 algebra.project 1 algebra.projection -3 +2 bat.pack 5 bat.single @@ -292,7 +292,7 @@ 2 querylog.define 1 sql.bind -2 +1 sql.mvc 1 sql.resultSet ___ checkin-list mailing list -- checkin-list@monetdb.org To unsubscribe send an email to checkin-list-le...@monetdb.org
MonetDB: Dec2023 - Fix dealing with differences in Python filter.
Changeset: 5e5ec3e87703 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/5e5ec3e87703 Modified Files: testing/sqllogictest.py Branch: Dec2023 Log Message: Fix dealing with differences in Python filter. diffs (17 lines): diff --git a/testing/sqllogictest.py b/testing/sqllogictest.py --- a/testing/sqllogictest.py +++ b/testing/sqllogictest.py @@ -545,8 +545,12 @@ class SQLLogic: m.update(b'\n') result.append(col) if err: +recv = [] +for row in ndata: +for col in row: +recv.append(col) print('Differences:', file=self.out) -self.out.writelines(list(difflib.ndiff([x + '\n' for x in expected], [x + '\n' for x in ndata]))) +self.out.writelines(list(difflib.ndiff([x + '\n' for x in expected], [x + '\n' for x in recv]))) if resdata is not None: result = [] for row in resdata: ___ checkin-list mailing list -- checkin-list@monetdb.org To unsubscribe send an email to checkin-list-le...@monetdb.org
MonetDB: default - Merge with Dec2023 branch.
Changeset: 93c85de06b98 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/93c85de06b98 Branch: default Log Message: Merge with Dec2023 branch. diffs (20 lines): diff --git a/monetdb5/optimizer/opt_commonTerms.c b/monetdb5/optimizer/opt_commonTerms.c --- a/monetdb5/optimizer/opt_commonTerms.c +++ b/monetdb5/optimizer/opt_commonTerms.c @@ -139,7 +139,7 @@ OPTcommonTermsImplementation(Client cntx } /* simple SQL bind operations need not be merged, they are cheap * and/or can be duplicated eliminated elsewhere cheaper */ - if (getModuleId(p) == sqlRef && getFunctionId(p) != tidRef) { + if (getModuleId(p) == sqlRef && (getFunctionId(p) != tidRef && getFunctionId(p) != bindRef)) { pushInstruction(mb, p); old[i] = NULL; continue; diff --git a/sql/test/transactions/Tests/All b/sql/test/transactions/Tests/All --- a/sql/test/transactions/Tests/All +++ b/sql/test/transactions/Tests/All @@ -7,3 +7,4 @@ mergetable-deps-crash view-deps chaining truncate-insert-restart +update_drop_crash ___ checkin-list mailing list -- checkin-list@monetdb.org To unsubscribe send an email to checkin-list-le...@monetdb.org
MonetDB: Dec2023 - in commenterms handle both sql.tid and sql.bi...
Changeset: 9481eab21f67 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/9481eab21f67 Modified Files: monetdb5/optimizer/opt_commonTerms.c Branch: Dec2023 Log Message: in commenterms handle both sql.tid and sql.binds, such that statements using those can be optimized away (when used multiple times) diffs (12 lines): diff --git a/monetdb5/optimizer/opt_commonTerms.c b/monetdb5/optimizer/opt_commonTerms.c --- a/monetdb5/optimizer/opt_commonTerms.c +++ b/monetdb5/optimizer/opt_commonTerms.c @@ -139,7 +139,7 @@ OPTcommonTermsImplementation(Client cntx } /* simple SQL bind operations need not be merged, they are cheap * and/or can be duplicated eliminated elsewhere cheaper */ - if (getModuleId(p) == sqlRef && getFunctionId(p) != tidRef) { + if (getModuleId(p) == sqlRef && (getFunctionId(p) != tidRef && getFunctionId(p) != bindRef)) { pushInstruction(mb, p); old[i] = NULL; continue; ___ checkin-list mailing list -- checkin-list@monetdb.org To unsubscribe send an email to checkin-list-le...@monetdb.org
MonetDB: default - merge with distinct_from
Changeset: a44978a85641 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/a44978a85641 Branch: default Log Message: merge with distinct_from diffs (truncated from 345 to 300 lines): diff --git a/gdk/gdk_join.c b/gdk/gdk_join.c --- a/gdk/gdk_join.c +++ b/gdk/gdk_join.c @@ -3697,7 +3697,8 @@ joincost(BAT *r, BUN lcount, struct cand #define MASK_NE(MASK_LT | MASK_GT) static gdk_return -thetajoin(BAT **r1p, BAT **r2p, BAT *l, BAT *r, BAT *sl, BAT *sr, int opcode, BUN estimate, const char *reason, lng t0) +thetajoin(BAT **r1p, BAT **r2p, BAT *l, BAT *r, BAT *sl, BAT *sr, int opcode, + BUN estimate, bool nil_matches, const char *reason, lng t0) { struct canditer lci, rci; const char *lvals, *rvals; @@ -3737,23 +3738,29 @@ thetajoin(BAT **r1p, BAT **r2p, BAT *l, if (BATtvoid(l)) { if (!BATtdensebi(&li)) { - /* trivial: nils don't match anything */ - bat_iterator_end(&li); - bat_iterator_end(&ri); - return nomatch(r1p, r2p, NULL, l, r, &lci, - 0, false, false, __func__, t0); + if (!nil_matches) { + /* trivial: nils don't match anything */ + bat_iterator_end(&li); + bat_iterator_end(&ri); + return nomatch(r1p, r2p, NULL, l, r, &lci, + 0, false, false, __func__, t0); + } + } else { + loff = (lng) l->tseqbase - (lng) l->hseqbase; } - loff = (lng) l->tseqbase - (lng) l->hseqbase; } if (BATtvoid(r)) { if (!BATtdensebi(&ri)) { - /* trivial: nils don't match anything */ - bat_iterator_end(&li); - bat_iterator_end(&ri); - return nomatch(r1p, r2p, NULL, l, r, &lci, - 0, false, false, __func__, t0); + if (!nil_matches) { + /* trivial: nils don't match anything */ + bat_iterator_end(&li); + bat_iterator_end(&ri); + return nomatch(r1p, r2p, NULL, l, r, &lci, + 0, false, false, __func__, t0); + } + } else { + roff = (lng) r->tseqbase - (lng) r->hseqbase; } - roff = (lng) r->tseqbase - (lng) r->hseqbase; } BUN maxsize = joininitresults(r1p, r2p, NULL, lci.ncand, rci.ncand, false, false, @@ -3782,18 +3789,18 @@ thetajoin(BAT **r1p, BAT **r2p, BAT *l, lo = canditer_next(&lci); if (lvals) vl = VALUE(l, lo - l->hseqbase); - else + else if (BATtdensebi(&li)) lval = (oid) ((lng) lo + loff); nr = 0; - if (cmp(vl, nil) != 0) { + if (nil_matches || cmp(vl, nil) != 0) { canditer_reset(&rci); TIMEOUT_LOOP(rci.ncand, qry_ctx) { ro = canditer_next(&rci); if (rvals) vr = VALUE(r, ro - r->hseqbase); - else + else if (BATtdensebi(&ri)) rval = (oid) ((lng) ro + roff); - if (cmp(vr, nil) == 0) + if (!nil_matches && cmp(vr, nil) == 0) continue; c = cmp(vl, vr); if (!((opcode & MASK_LT && c < 0) || @@ -4437,7 +,7 @@ BATthetajoin(BAT **r1p, BAT **r2p, BAT * if (joinparamcheck(l, r, NULL, sl, sr, __func__) != GDK_SUCCEED) return GDK_FAIL; - return thetajoin(r1p, r2p, l, r, sl, sr, opcode, estimate, + return thetajoin(r1p, r2p, l, r, sl, sr, opcode, estimate, nil_matches, __func__, t0); } @@ -5063,14 +5070,14 @@ BATrangejoin(BAT **r1p, BAT **r2p, BAT * if (!anti) return nomatch(r1p, r2p, NULL, l, rl, &lci, 0, false, false, __func__, t0); - return thetajoin(r1p, r2p, l, rh, sl, sr, MASK_GT, estimate, + return thetajoin(r1p, r2p, l, rh, sl, sr, MASK_GT, estimate, false, __func__, t0); } if (rh->ttype == TYPE_void && is_oid_nil(rh->tseqbase)) { if (!anti) return nomatch(r1p, r2p, NULL, l, rl, &lci, 0, false, false,
MonetDB: distinct_from - merge with default
Changeset: de411981870d for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/de411981870d Branch: distinct_from Log Message: merge with default diffs (truncated from 2516 to 300 lines): diff --git a/gdk/ChangeLog b/gdk/ChangeLog --- a/gdk/ChangeLog +++ b/gdk/ChangeLog @@ -1,6 +1,14 @@ # ChangeLog file for GDK # This file is updated with Maddlog +* Tue Mar 26 2024 Sjoerd Mullender +- Made some changes to how BAT descriptors are allocated. They are now + allocated in bulk, meaning fewer malloc/free calls during processing. +- Removed macro BBP_cache and its associated code. Checking whether a + BAT is cached (loaded in memory) can be done by checking the BBPLOADED + bit in the BBP_status value. Getting a pointer to the BAT descriptor + can be done by using BBP_desc. + * Tue Feb 6 2024 Sjoerd Mullender - The SQL transaction ID is no longer saved in the BBP.dir file. diff --git a/gdk/gdk.h b/gdk/gdk.h --- a/gdk/gdk.h +++ b/gdk/gdk.h @@ -956,10 +956,9 @@ gdk_export void HEAPincref(Heap *h); * field. */ typedef struct { - BAT *cache; /* if loaded: BAT* handle */ char *logical; /* logical name (may point at bak) */ char bak[16]; /* logical name backup (tmp_%o) */ - BAT *desc; /* the BAT descriptor */ + BAT descr; /* the BAT descriptor */ char *options; /* A string list of options */ #if SIZEOF_VOID_P == 4 char physical[20]; /* dir + basename for storage */ @@ -993,19 +992,18 @@ gdk_export BBPrec *BBP[N_BBPINIT]; /* fast defines without checks; internal use only */ #define BBP_record(i) BBP[(i)>>BBPINITLOG][(i)&(BBPINIT-1)] -#define BBP_cache(i) BBP_record(i).cache #define BBP_logical(i) BBP_record(i).logical #define BBP_bak(i) BBP_record(i).bak #define BBP_next(i)BBP_record(i).next #define BBP_physical(i)BBP_record(i).physical #define BBP_options(i) BBP_record(i).options -#define BBP_desc(i)BBP_record(i).desc +#define BBP_desc(i)(&BBP_record(i).descr) #define BBP_refs(i)BBP_record(i).refs #define BBP_lrefs(i) BBP_record(i).lrefs #define BBP_status(i) ((unsigned) ATOMIC_GET(&BBP_record(i).status)) #define BBP_pid(i) BBP_record(i).pid #define BATgetId(b)BBP_logical((b)->batCacheid) -#define BBPvalid(i)(BBP_logical(i) != NULL && *BBP_logical(i) != '.') +#define BBPvalid(i)(BBP_logical(i) != NULL) #define BBPRENAME_ALREADY (-1) #define BBPRENAME_ILLEGAL (-2) diff --git a/gdk/gdk_aggr.c b/gdk/gdk_aggr.c --- a/gdk/gdk_aggr.c +++ b/gdk/gdk_aggr.c @@ -3675,7 +3675,6 @@ BATmin_skipnil(BAT *b, void *aggr, bit s if ((pb == NULL || bi.count == BATcount(pb)) && BATcheckimprints(b)) { if (pb != NULL) { - BAT *pb = BBP_cache(VIEWtparent(b)); MT_lock_set(&pb->batIdxLock); imprints = pb->timprints; if (imprints != NULL) @@ -3842,7 +3841,6 @@ BATmax_skipnil(BAT *b, void *aggr, bit s if ((pb == NULL || BATcount(b) == BATcount(pb)) && BATcheckimprints(b)) { if (pb != NULL) { - BAT *pb = BBP_cache(VIEWtparent(b)); MT_lock_set(&pb->batIdxLock); imprints = pb->timprints; if (imprints != NULL) diff --git a/gdk/gdk_bat.c b/gdk/gdk_bat.c --- a/gdk/gdk_bat.c +++ b/gdk/gdk_bat.c @@ -58,22 +58,49 @@ BAT * BATcreatedesc(oid hseq, int tt, bool heapnames, role_t role, uint16_t width) { + bat bid; BAT *bn; + Heap *h = NULL, *vh = NULL; /* * Alloc space for the BAT and its dependent records. */ assert(tt >= 0); - bn = GDKmalloc(sizeof(BAT)); + if (heapnames) { + if ((h = GDKmalloc(sizeof(Heap))) == NULL) { + return NULL; + } + *h = (Heap) { + .farmid = BBPselectfarm(role, tt, offheap), + .dirty = true, + }; - if (bn == NULL) + if (ATOMneedheap(tt)) { + if ((vh = GDKmalloc(sizeof(Heap))) == NULL) { + GDKfree(h); + return NULL; + } + *vh = (Heap) { + .farmid = BBPselectfarm(role, tt, varheap), + .dirty = true, + }; + } + } + + bid = BBPallocbat(tt); + if (bid == 0) { + GDK