MonetDB: Aug2024 - Don't use same iterator for two different val...
Changeset: b07e9b4b7faf for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/b07e9b4b7faf Modified Files: gdk/gdk_select.c Branch: Aug2024 Log Message: Don't use same iterator for two different values at the same time. diffs (20 lines): diff --git a/gdk/gdk_select.c b/gdk/gdk_select.c --- a/gdk/gdk_select.c +++ b/gdk/gdk_select.c @@ -1365,6 +1365,7 @@ BATrange(BATiter *bi, const void *tl, co BAT *pb = NULL; int c; int (*atomcmp) (const void *, const void *) = ATOMcompare(bi->type); + BATiter bi2 = *bi; if (tl && (*atomcmp)(tl, ATOMnilptr(bi->type)) == 0) tl = NULL; @@ -1383,7 +1384,7 @@ BATrange(BATiter *bi, const void *tl, co else if ((minprop = BATgetprop_nolock(bi->b, GDK_MIN_BOUND)) != NULL) minval = VALptr(minprop); if (bi->maxpos != BUN_NONE) { - maxval = BUNtail(*bi, bi->maxpos); + maxval = BUNtail(bi2, bi->maxpos); maxincl = true; } else if ((maxprop = BATgetprop_nolock(bi->b, GDK_MAX_BOUND)) != NULL) { maxval = VALptr(maxprop); ___ checkin-list mailing list -- checkin-list@monetdb.org To unsubscribe send an email to checkin-list-le...@monetdb.org
MonetDB: Aug2024 - We're interested in whether we have a min/max...
Changeset: 3da51ea01918 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/3da51ea01918 Modified Files: gdk/gdk_select.c Branch: Aug2024 Log Message: We're interested in whether we have a min/max value, not the property. diffs (89 lines): diff --git a/gdk/gdk_select.c b/gdk/gdk_select.c --- a/gdk/gdk_select.c +++ b/gdk/gdk_select.c @@ -1390,14 +1390,14 @@ BATrange(BATiter *bi, const void *tl, co maxincl = false; } bool keep = false; /* keep lock on parent bat? */ - if (minprop == NULL || maxprop == NULL) { + if (minval == NULL || maxval == NULL) { if (pb != NULL) { MT_lock_set(&pb->theaplock); - if (minprop == NULL && (minprop = BATgetprop_nolock(pb, GDK_MIN_BOUND)) != NULL) { + if (minval == NULL && (minprop = BATgetprop_nolock(pb, GDK_MIN_BOUND)) != NULL) { keep = true; minval = VALptr(minprop); } - if (maxprop == NULL && (maxprop = BATgetprop_nolock(pb, GDK_MAX_BOUND)) != NULL) { + if (maxval == NULL && (maxprop = BATgetprop_nolock(pb, GDK_MAX_BOUND)) != NULL) { keep = true; maxval = VALptr(maxprop); maxincl = true; @@ -1408,20 +1408,20 @@ BATrange(BATiter *bi, const void *tl, co } } - if (minprop == NULL && maxprop == NULL) { + if (minval == NULL && maxval == NULL) { range = range_inside; /* strictly: unknown */ - } else if (maxprop && + } else if (maxval && tl && ((c = atomcmp(tl, maxval)) > 0 || ((!maxincl || !li) && c == 0))) { range = range_after; - } else if (minprop && + } else if (minval && th && ((c = atomcmp(th, minval)) < 0 || (!hi && c == 0))) { range = range_before; } else if (tl == NULL) { - if (minprop == NULL) { + if (minval == NULL) { c = atomcmp(th, maxval); if (c < 0 || ((maxincl || !hi) && c == 0)) range = range_atstart; @@ -1431,7 +1431,7 @@ BATrange(BATiter *bi, const void *tl, co c = atomcmp(th, minval); if (c < 0 || (!hi && c == 0)) range = range_before; - else if (maxprop == NULL) + else if (maxval == NULL) range = range_atstart; else { c = atomcmp(th, maxval); @@ -1442,7 +1442,7 @@ BATrange(BATiter *bi, const void *tl, co } } } else if (th == NULL) { - if (maxprop == NULL) { + if (maxval == NULL) { c = atomcmp(tl, minval); if (c >= 0) range = range_atend; @@ -1452,7 +1452,7 @@ BATrange(BATiter *bi, const void *tl, co c = atomcmp(tl, maxval); if (c > 0 || ((!maxincl || !li) && c == 0)) range = range_after; - else if (minprop == NULL) + else if (minval == NULL) range = range_atend; else { c = atomcmp(tl, minval); @@ -1462,13 +1462,13 @@ BATrange(BATiter *bi, const void *tl, co range = range_contains; } } - } else if (minprop == NULL) { + } else if (minval == NULL) { c = atomcmp(th, maxval); if (c < 0 || ((maxincl || !hi) && c == 0)) range = range_inside; else range = range_atend; - } else if (maxprop == NULL) { + } else if (maxval == NULL) { c = atomcmp(tl, minval); if (c >= 0) range = range_inside; ___ checkin-list mailing list -- checkin-list@monetdb.org To unsubscribe send an email to checkin-list-le...@monetdb.org
MonetDB: Aug2024 - For sorted bats we can easily find how it ove...
Changeset: f142a60fef9d for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/f142a60fef9d Modified Files: gdk/gdk_select.c Branch: Aug2024 Log Message: For sorted bats we can easily find how it overlaps with a search range. diffs (27 lines): diff --git a/gdk/gdk_select.c b/gdk/gdk_select.c --- a/gdk/gdk_select.c +++ b/gdk/gdk_select.c @@ -1379,11 +1379,21 @@ BATrange(BATiter *bi, const void *tl, co /* keep locked while we look at the property values */ MT_lock_set(&bi->b->theaplock); - if (bi->minpos != BUN_NONE) + if (bi->sorted && (bi->nonil || atomcmp(BUNtail(*bi, 0), ATOMnilptr(bi->type)) != 0)) + minval = BUNtail(*bi, 0); + else if (bi->revsorted && (bi->nonil || atomcmp(BUNtail(*bi, bi->count - 1), ATOMnilptr(bi->type)) != 0)) + minval = BUNtail(*bi, bi->count - 1); + else if (bi->minpos != BUN_NONE) minval = BUNtail(*bi, bi->minpos); else if ((minprop = BATgetprop_nolock(bi->b, GDK_MIN_BOUND)) != NULL) minval = VALptr(minprop); - if (bi->maxpos != BUN_NONE) { + if (bi->sorted && (bi->nonil || atomcmp(BUNtail(bi2, bi->count - 1), ATOMnilptr(bi->type)) != 0)) { + maxval = BUNtail(bi2, bi->count - 1); + maxincl = true; + } else if (bi->revsorted && (bi->nonil || atomcmp(BUNtail(bi2, 0), ATOMnilptr(bi->type)) != 0)) { + maxval = BUNtail(bi2, 0); + maxincl = true; + } else if (bi->maxpos != BUN_NONE) { maxval = BUNtail(bi2, bi->maxpos); maxincl = true; } else if ((maxprop = BATgetprop_nolock(bi->b, GDK_MAX_BOUND)) != NULL) { ___ checkin-list mailing list -- checkin-list@monetdb.org To unsubscribe send an email to checkin-list-le...@monetdb.org
MonetDB: Aug2024 - Not all errors are malloc errors.
Changeset: 86a34c6a2e80 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/86a34c6a2e80 Modified Files: monetdb5/modules/kernel/algebra.c Branch: Aug2024 Log Message: Not all errors are malloc errors. diffs (12 lines): diff --git a/monetdb5/modules/kernel/algebra.c b/monetdb5/modules/kernel/algebra.c --- a/monetdb5/modules/kernel/algebra.c +++ b/monetdb5/modules/kernel/algebra.c @@ -1003,7 +1003,7 @@ ALGfirstn(Client cntxt, MalBlkPtr mb, Ma BBPreclaim(s); BBPreclaim(g); if (rc != GDK_SUCCEED) - throw(MAL, "algebra.firstn", SQLSTATE(HY013) MAL_MALLOC_FAIL); + throw(MAL, "algebra.firstn", GDK_EXCEPTION); *ret1 = bn->batCacheid; BBPkeepref(bn); if (ret2) { ___ checkin-list mailing list -- checkin-list@monetdb.org To unsubscribe send an email to checkin-list-le...@monetdb.org
MonetDB: Aug2024 - Use binary search instead of hash on sorted b...
Changeset: 237093560788 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/237093560788 Modified Files: gdk/gdk_select.c Branch: Aug2024 Log Message: Use binary search instead of hash on sorted bat with available hash table. It turns out, even with large bats, binary search is faster than using a hash, even if the hash chain has length 1. diffs (30 lines): diff --git a/gdk/gdk_select.c b/gdk/gdk_select.c --- a/gdk/gdk_select.c +++ b/gdk/gdk_select.c @@ -1873,11 +1873,12 @@ BATselect(BAT *b, BAT *s, const void *tl else pb = NULL; pbi = bat_iterator(pb); - /* use hash only for equi-join, and then only if b or its -* parent already has a hash, or if b or its parent is -* persistent and the total size wouldn't be too large; check -* for existence of hash last since that may involve I/O */ - if (equi || antiequi) { + /* use hash only for equi-join if the bat is not sorted, but +* only if b or its parent already has a hash, or if b or its +* parent is persistent and the total size wouldn't be too +* large; check for existence of hash last since that may +* involve I/O */ + if ((equi || antiequi) && !bi.sorted && !bi.revsorted) { double cost = joincost(b, 1, &ci, &havehash, &phash, NULL); if (cost > 0 && cost < ci.ncand) { wanthash = true; @@ -1980,7 +1981,7 @@ BATselect(BAT *b, BAT *s, const void *tl } } - if (!havehash && (bi.sorted || bi.revsorted || oidxh != NULL)) { + if (bi.sorted || bi.revsorted || (!havehash && oidxh != NULL)) { BUN low = 0; BUN high = bi.count; ___ checkin-list mailing list -- checkin-list@monetdb.org To unsubscribe send an email to checkin-list-le...@monetdb.org
MonetDB: default - Do not adjust precision of decimal
Changeset: ea3fe38d68d5 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/ea3fe38d68d5 Modified Files: sql/server/sql_atom.c Branch: default Log Message: Do not adjust precision of decimal diffs (24 lines): diff --git a/sql/server/sql_atom.c b/sql/server/sql_atom.c --- a/sql/server/sql_atom.c +++ b/sql/server/sql_atom.c @@ -68,9 +68,9 @@ atom_int( allocator *sa, sql_subtype *tp atom *a = atom_create(sa); if(!a) return NULL; - a->isnull = 0; a->tpe = *tpe; + a->data.len = 0; a->data.vtype = tpe->type->localtype; switch (ATOMstorage(a->data.vtype)) { case TYPE_bte: @@ -99,9 +99,6 @@ atom_int( allocator *sa, sql_subtype *tp int bits = number_bits(val); if (a->tpe.type->eclass == EC_NUM) a->tpe.digits = bits; - else if (a->tpe.type->eclass == EC_DEC) - a->tpe.digits = bits2digits(bits) + 1;; - a->data.len = 0; return a; } } ___ checkin-list mailing list -- checkin-list@monetdb.org To unsubscribe send an email to checkin-list-le...@monetdb.org
MonetDB: default - Introduce division_min_scale global sql env v...
Changeset: a9ba7c301167 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/a9ba7c301167 Modified Files: sql/ChangeLog sql/server/rel_exp.c sql/server/sql_decimal.c sql/server/sql_env.c sql/server/sql_mvc.c sql/server/sql_mvc.h sql/server/sql_var.c sql/test/BugTracker-2015/Tests/grantRole.Bug-3772.test sql/test/BugTracker-2018/Tests/grant-role-not-idempotent.Bug-6660.test sql/test/Users/Tests/grantMonetdb.test sql/test/Users/Tests/renameUser.SQL.py sql/test/Users/Tests/role.test sql/test/scoping/Tests/scoping02.test Branch: default Log Message: Introduce division_min_scale global sql env variable diffs (truncated from 393 to 300 lines): diff --git a/sql/ChangeLog b/sql/ChangeLog --- a/sql/ChangeLog +++ b/sql/ChangeLog @@ -1,3 +1,7 @@ # ChangeLog file for sql # This file is updated with Maddlog +* Tue Sep 10 2024 Lucas Pereira +- Introduce division_min_scale SQL environment variable for specifying + minimum scale of the division result. The default value is 3. + diff --git a/sql/server/rel_exp.c b/sql/server/rel_exp.c --- a/sql/server/rel_exp.c +++ b/sql/server/rel_exp.c @@ -3261,16 +3261,15 @@ exp_scale_algebra(mvc *sql, sql_subfunc sql_subtype *lt = exp_subtype(l); sql_subtype *rt = exp_subtype(r); - if (!EC_INTERVAL(lt->type->eclass) && lt->type->scale == SCALE_FIX && (lt->scale || rt->scale) && - strcmp(sql_func_imp(f->func), "/") == 0) { + if (!EC_INTERVAL(lt->type->eclass) && lt->type->scale == SCALE_FIX && + (lt->scale || rt->scale) && strcmp(sql_func_imp(f->func), "/") == 0) { sql_subtype *res = f->res->h->data; unsigned int scale, digits, digL, scaleL; sql_subtype nlt; /* scale fixing may require a larger type ! */ - /* TODO make '3' setable by user (division_minimal_scale or so) */ - scaleL = (lt->scale < 3) ? 3 : lt->scale; - scaleL += (scaleL < rt->scale)?(rt->scale - scaleL):0; + scaleL = (lt->scale < sql->div_min_scale) ? sql->div_min_scale : lt->scale; + scaleL += (scaleL < rt->scale) ? rt->scale - scaleL : 0; scale = scaleL; scaleL += rt->scale; digL = lt->digits + (scaleL - lt->scale); diff --git a/sql/server/sql_decimal.c b/sql/server/sql_decimal.c --- a/sql/server/sql_decimal.c +++ b/sql/server/sql_decimal.c @@ -201,13 +201,13 @@ number_bits(lng val) val = -val; unsigned bits = 0; #ifdef HAVE_HGE - hge m = ((hge)1)< m; bits++) - m = ((hge)1)< m; bits++) + m = (hge)1 << bits; #else - lng m = ((lng)1)< m; bits++) - m = ((lng)1)< m; bits++) + m = ((lng)1) << bits; #endif if (!bits) bits = 1; diff --git a/sql/server/sql_env.c b/sql/server/sql_env.c --- a/sql/server/sql_env.c +++ b/sql/server/sql_env.c @@ -54,30 +54,43 @@ str sql_update_var(mvc *m, sql_schema *s, const char *name, const ValRecord *ptr) { if (strcmp(s->base.name, "sys") == 0) { - if (strcmp(name, "debug") == 0 || strcmp(name, "current_timezone") == 0 || strcmp(name, "sql_optimizer") == 0) { + if (strcmp(name, "debug") == 0 || + strcmp(name, "current_timezone") == 0 || + strcmp(name, "sql_optimizer") == 0 || + strcmp(name, "division_min_scale") == 0) { VAR_UPCAST sgn = val_get_number(ptr); - if (VALisnil(ptr)) - throw(SQL,"sql.update_var", SQLSTATE(42000) "Variable '%s.%s' cannot be NULL\n", s->base.name, name); + throw(SQL, "sql_update_var", SQLSTATE(HY009) + "Variable '%s.%s' cannot be NULL", s->base.name, name); if (sgn <= (VAR_UPCAST) GDK_int_min) - throw(SQL,"sql.update_var", SQLSTATE(42000) "Value too small for '%s.%s'\n", s->base.name, name); + throw(SQL, "sql_update_var", SQLSTATE(HY009) + "Value too small for '%s.%s'", s->base.name, name); if (sgn > (VAR_UPCAST) GDK_int_max) - throw(SQL,"sql.update_var", SQLSTATE(42000) "Value too large for '%s.%s'\n", s->base.name, name); - + throw(SQL, "sql_update_var", SQLSTATE(HY009) + "Value too large for '%s.%s'", s->base.name, name); if (/* DISABLES CODE */ (0) && strcmp(name, "debug") == 0) { m->debug = (int) sgn; } else if (strcmp(name, "current_timezone") == 0) { m->timezone = (int) sgn; +
MonetDB: Aug2024 - Better maintain tnil/tnonil properties when a...
Changeset: 23052201fcbe for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/23052201fcbe Modified Files: gdk/gdk_bat.c monetdb5/mal/Tests/dataflow01.maltest monetdb5/mal/Tests/tst901a.maltest monetdb5/modules/mal/Tests/bigsum.maltest monetdb5/modules/mal/Tests/imprints.maltest monetdb5/modules/mal/Tests/manifold.maltest monetdb5/modules/mal/Tests/manifoldstr.maltest sql/test/BugTracker-2009/Tests/use_order_column_first.SF-2686008.test sql/test/BugTracker-2010/Tests/LIMIT_OFFSET_big-endian.Bug-2622.test sql/test/BugTracker-2011/Tests/crash_on_alias.Bug-2798.test sql/test/BugTracker-2015/Tests/large_join.Bug-3809.test sql/test/BugTracker-2016/Tests/merge_project.Bug-3955.test sql/test/BugTracker-2018/Tests/count_from_commented_function_signatures.Bug-6542.test sql/test/BugTracker-2021/Tests/plan-not-optimal-view.Bug-7140.test sql/test/BugTracker-2023/Tests/join-on-row_number-over-7403.test sql/test/BugTracker/Tests/explain.SF-1739353.test sql/test/FeatureRequests/Tests/foreign_key_outer_join_dead_code_elimination-plan-1join-query.test sql/test/FeatureRequests/Tests/foreign_key_outer_join_dead_code_elimination-plan-1join-view.test sql/test/FeatureRequests/Tests/foreign_key_outer_join_dead_code_elimination-plan-2join-query.test sql/test/FeatureRequests/Tests/foreign_key_outer_join_dead_code_elimination-plan-2join-view.test sql/test/FeatureRequests/Tests/foreign_key_outer_join_dead_code_elimination-plan-3join-query.test sql/test/Tests/keys.test sql/test/merge-partitions/Tests/mergepart31.test sql/test/miscellaneous/Tests/groupby_error.test sql/test/miscellaneous/Tests/groupby_expressions.test sql/test/miscellaneous/Tests/simple_plans.test sql/test/miscellaneous/Tests/unique_keys.test sql/test/out2in/Tests/out2in.test sql/test/rel-optimizers/Tests/groupby-cse.test sql/test/rel-optimizers/Tests/join-merge-remote-replica-plan.test sql/test/rel-optimizers/Tests/local-replica.test sql/test/rel-optimizers/Tests/merge-unions.test sql/test/rel-optimizers/Tests/replicas-join-plan.test sql/test/sysmon/timeout/Tests/timeout_aggr.maltest sql/test/sysmon/timeout/Tests/timeout_join.maltest Branch: Aug2024 Log Message: Better maintain tnil/tnonil properties when appending data. diffs (truncated from 2721 to 300 lines): diff --git a/gdk/gdk_bat.c b/gdk/gdk_bat.c --- a/gdk/gdk_bat.c +++ b/gdk/gdk_bat.c @@ -1200,6 +1200,9 @@ BUNappendmulti(BAT *b, const void *value maxvalp = t; } } + } else { + b->tnil = true; + b->tnonil = false; } p++; } @@ -1219,6 +1222,8 @@ BUNappendmulti(BAT *b, const void *value } else if (ATOMstorage(b->ttype) == TYPE_msk) { bi.minpos = bi.maxpos = BUN_NONE; minvalp = maxvalp = NULL; + b->tnil = false; + b->tnonil = true; for (BUN i = 0; i < count; i++) { t = (void *) ((char *) values + (i << b->tshift)); mskSetVal(b, p, *(msk *) t); @@ -1255,12 +1260,16 @@ BUNappendmulti(BAT *b, const void *value maxvalp = t; } } + } else { + b->tnil = true; + b->tnonil = false; } p++; } nunique = b->thash ? b->thash->nunique : 0; } } else { + /* inserting nils, unless it's msk */ for (BUN i = 0; i < count; i++) { gdk_return rc = tfastins_nocheck(b, p, t); if (rc != GDK_SUCCEED) { @@ -1273,6 +1282,8 @@ BUNappendmulti(BAT *b, const void *value p++; } nunique = b->thash ? b->thash->nunique : 0; + b->tnil = b->ttype != TYPE_msk; + b->tnonil = false; } MT_lock_set(&b->theaplock); b->tminpos = bi.minpos; @@ -1283,8 +1294,6 @@ BUNappendmulti(BAT *b, const void *value if (b->ttype == TYPE_oid) { /* spend extra effort on oid (possible candidate list) */ if (values == NULL || is_oid_nil(((oid *) values)[0])) { -
MonetDB: ordered-set-aggregates - merged with default
Changeset: 29486adb8cba for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/29486adb8cba Modified Files: sql/server/sql_env.c sql/server/sql_mvc.c sql/server/sql_mvc.h sql/test/BugDay_2005-10-06_2.9.3/Tests/CrashMe_SQL_server_crash-2.SF-921673.test sql/test/Dependencies/Tests/dependency_owner_schema_3.test sql/test/bugs/Tests/innerjoin_multiple-bug-sf-943661.test Branch: ordered-set-aggregates Log Message: merged with default diffs (truncated from 27932 to 300 lines): diff --git a/clients/mapiclient/mhelp.c b/clients/mapiclient/mhelp.c --- a/clients/mapiclient/mhelp.c +++ b/clients/mapiclient/mhelp.c @@ -68,7 +68,7 @@ SQLhelp sqlhelp1[] = { {"ALTER TABLE", "", "ALTER TABLE [ IF EXISTS ] qname ADD [ COLUMN ] column_def\n" -"ALTER TABLE [ IF EXISTS ] qname ADD table_constraint\n" +"ALTER TABLE [ IF EXISTS ] qname ADD [ CONSTRAINT ident ] table_constraint\n" "ALTER TABLE [ IF EXISTS ] qname ALTER [ COLUMN ] ident SET DEFAULT value\n" "ALTER TABLE [ IF EXISTS ] qname ALTER [ COLUMN ] ident SET [NOT] NULL\n" "ALTER TABLE [ IF EXISTS ] qname ALTER [ COLUMN ] ident DROP DEFAULT\n" @@ -910,9 +910,10 @@ SQLhelp sqlhelp2[] = { NULL,}, {"table_constraint", NULL, -"[ CONSTRAINT ident ] { PRIMARY KEY column_list | UNIQUE column_list |\n" +"[ CONSTRAINT ident ] { CHECK '(' search_condition ')' |\n" +"PRIMARY KEY column_list | UNIQUE column_list |\n" "FOREIGN KEY column_list REFERENCES qname [ column_list ] [ match_options ] [ reference_action ] }", -"column_list,match_options,reference_action", +"column_list,search_condition,match_options,reference_action", "See also https://www.monetdb.org/documentation/user-guide/sql-manual/data-definition/table-elements/"}, {"table_element", NULL, diff --git a/clients/mapilib/mapi.c b/clients/mapilib/mapi.c --- a/clients/mapilib/mapi.c +++ b/clients/mapilib/mapi.c @@ -1217,7 +1217,7 @@ mapi_log_header(Mapi mid, const char *fu if (firstcall == 0) firstcall = now; double seconds = (double)(now - firstcall) / 1e6; - mnstr_printf(mid->tracelog, "\342\226\266 [%u] t=%.3fs %s%s %s(), line %ld\n", mid->index, seconds, mark1, mark2, funcname, line); /* U+25B6: right-pointing triangle */ + mnstr_printf(mid->tracelog, "\n** [%u] t=%.3fs %s%s %s(), line %ld\n", mid->index, seconds, mark1, mark2, funcname, line); } void diff --git a/gdk/gdk_join.c b/gdk/gdk_join.c --- a/gdk/gdk_join.c +++ b/gdk/gdk_join.c @@ -4212,7 +4212,7 @@ leftjoin(BAT **r1p, BAT **r2p, BAT **r3p /* maybe do a hash join on the swapped operands; if we * do, we need to sort the output, so we take that into * account as well */ - bool lhash, plhash, lcand; + bool lhash, plhash, lcand, rkey = r->tkey; double lcost; lcost = joincost(l, rci.ncand, &lci, &lhash, &plhash, &lcand); @@ -4220,7 +4220,7 @@ leftjoin(BAT **r1p, BAT **r2p, BAT **r3p rc = GDK_FAIL; goto doreturn; } - if (semi) + if (semi && !rkey) lcost += rci.ncand; /* cost of BATunique(r) */ /* add cost of sorting; obviously we don't know the * size, so we guess that the size of the output is @@ -4229,7 +4229,7 @@ leftjoin(BAT **r1p, BAT **r2p, BAT **r3p if (lcost < rcost) { BAT *tmp = sr; BAT *r1, *r2; - if (semi) { + if (semi && !rkey) { sr = BATunique(r, sr); if (sr == NULL) { rc = GDK_FAIL; @@ -4240,7 +4240,7 @@ leftjoin(BAT **r1p, BAT **r2p, BAT **r3p rc = hashjoin(&r2, &r1, NULL, r, l, &rci, &lci, nil_matches, false, false, false, false, false, false, estimate, t0, true, lhash, plhash, lcand, func); - if (semi) + if (semi && !rkey) BBPunfix(sr->batCacheid); if (rc != GDK_SUCCEED) goto doreturn; diff --git a/gdk/gdk_select.c b/gdk/gdk_select.c --- a/gdk/gdk_select.c +++ b/gdk/gdk_select.c @@ -1986,30 +1986,27 @@ BATselect(BAT *b, BAT *s, const void *tl MT_lock_unset(&pb->batIdxLock); } if (oidxh) { - /* Is query selective enough to use the ordered index ? */ - /* TODO: Test if this heuristic works in practice */ - /*if ((ORDERfnd(b, th) - ORDERfnd(b, tl)) < ((BUN)100
MonetDB: default - Merge with Aug2024 branch.
Changeset: 577b502bb38a for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/577b502bb38a Modified Files: gdk/gdk_bat.c gdk/gdk_select.c monetdb5/modules/kernel/algebra.c sql/test/2024/Tests/nextafter.test sql/test/BugTracker-2019/Tests/duplicates-not-eliminated-long-CASE-stmt.Bug-6697.test sql/test/miscellaneous/Tests/simple_plans.test sql/test/rel-optimizers/Tests/merge-ors-base.test sql/test/rel-optimizers/Tests/merge-ors-multi-col-eq-to-cmp_in.test sql/test/rel-optimizers/Tests/merge-ors-single-col-eq-to-cmp_in.test sql/test/rel-optimizers/Tests/merge-unions.test testing/Mtest.py.in Branch: default Log Message: Merge with Aug2024 branch. diffs (truncated from 3372 to 300 lines): diff --git a/gdk/gdk_bat.c b/gdk/gdk_bat.c --- a/gdk/gdk_bat.c +++ b/gdk/gdk_bat.c @@ -1203,6 +1203,9 @@ BUNappendmulti(BAT *b, const void *value maxvalp = t; } } + } else { + b->tnil = true; + b->tnonil = false; } p++; } @@ -1222,6 +1225,8 @@ BUNappendmulti(BAT *b, const void *value } else if (ATOMstorage(b->ttype) == TYPE_msk) { bi.minpos = bi.maxpos = BUN_NONE; minvalp = maxvalp = NULL; + b->tnil = false; + b->tnonil = true; for (BUN i = 0; i < count; i++) { t = (void *) ((char *) values + (i << b->tshift)); mskSetVal(b, p, *(msk *) t); @@ -1258,12 +1263,16 @@ BUNappendmulti(BAT *b, const void *value maxvalp = t; } } + } else { + b->tnil = true; + b->tnonil = false; } p++; } nunique = b->thash ? b->thash->nunique : 0; } } else { + /* inserting nils, unless it's msk */ for (BUN i = 0; i < count; i++) { gdk_return rc = tfastins_nocheck(b, p, t); if (rc != GDK_SUCCEED) { @@ -1276,6 +1285,8 @@ BUNappendmulti(BAT *b, const void *value p++; } nunique = b->thash ? b->thash->nunique : 0; + b->tnil = b->ttype != TYPE_msk; + b->tnonil = false; } MT_lock_set(&b->theaplock); b->tminpos = bi.minpos; @@ -1286,8 +1297,6 @@ BUNappendmulti(BAT *b, const void *value if (b->ttype == TYPE_oid) { /* spend extra effort on oid (possible candidate list) */ if (values == NULL || is_oid_nil(((oid *) values)[0])) { - b->tnil = true; - b->tnonil = false; b->tsorted = false; b->trevsorted = false; b->tkey = false; @@ -1298,8 +1307,6 @@ BUNappendmulti(BAT *b, const void *value b->trevsorted = true; b->tkey = true; b->tseqbase = count == 1 ? ((oid *) values)[0] : oid_nil; - b->tnil = false; - b->tnonil = true; } else { if (!is_oid_nil(b->tseqbase) && (count > 1 || @@ -1328,8 +1335,6 @@ BUNappendmulti(BAT *b, const void *value } for (BUN i = 1; i < count; i++) { if (is_oid_nil(((oid *) values)[i])) { - b->tnil = true; - b->tnonil = false; b->tsorted = false; b->trevsorted = false; b->tkey = false; @@ -1360,18 +1365,14 @@ BUNappendmulti(BAT *b, const void *value } } } else if (!ATOMlinear(b->ttype)) { - b->tnil = b->tnonil = false; b->tsorted = b->trevsorted = b->tkey = false; } else if (b->batCount == 0) { if (values == NULL) { b->tsorted = b->trevsorted = true; b->tkey = count == 1; - b->tnil = true; - b->tnonil = fal
MonetDB: Aug2024 - Typo.
Changeset: 6d9aefb21f3f for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/6d9aefb21f3f Modified Files: monetdb5/mal/mal.h Branch: Aug2024 Log Message: Typo. diffs (12 lines): diff --git a/monetdb5/mal/mal.h b/monetdb5/mal/mal.h --- a/monetdb5/mal/mal.h +++ b/monetdb5/mal/mal.h @@ -216,7 +216,7 @@ typedef struct MALSTK { * for use in profiling instructions. */ struct timeval clock; /* time this stack was created */ - char status;/* srunning 'R' suspended 'S', quitting 'Q' */ + char status;/* running 'R' suspended 'S', quitting 'Q' */ int pcup; /* saved pc upon a recursive all */ oid tag;/* unique invocation call tag */ lng memory; /* Actual memory claims for highwater mark */ ___ checkin-list mailing list -- checkin-list@monetdb.org To unsubscribe send an email to checkin-list-le...@monetdb.org
MonetDB: ordered-set-aggregates - Place group_concat functions i...
Changeset: f1cc14193489 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/f1cc14193489 Modified Files: sql/scripts/10_sys_schema_extension.sql sql/scripts/39_analytics.sql sql/scripts/49_strings.sql Branch: ordered-set-aggregates Log Message: Place group_concat functions in proper SQL script files diffs (45 lines): diff --git a/sql/scripts/10_sys_schema_extension.sql b/sql/scripts/10_sys_schema_extension.sql --- a/sql/scripts/10_sys_schema_extension.sql +++ b/sql/scripts/10_sys_schema_extension.sql @@ -526,13 +526,3 @@ SELECT 'optimizer', optimizer UNION ALL SELECT 'pi', pi() UNION ALL SELECT 'rowcnt', rowcnt; GRANT SELECT ON sys.var_values TO PUBLIC; - -CREATE AGGREGATE sys.group_concat(str string) RETURNS string WITH ORDER EXTERNAL NAME "aggr"."str_group_concat"; -GRANT EXECUTE ON AGGREGATE sys.group_concat(string) TO PUBLIC; -CREATE AGGREGATE sys.group_concat(str string, sep string) RETURNS string WITH ORDER EXTERNAL NAME "aggr"."str_group_concat"; -GRANT EXECUTE ON AGGREGATE sys.group_concat(string, string) TO PUBLIC; - -CREATE WINDOW sys.group_concat(str string) RETURNS string EXTERNAL NAME "sql"."str_group_concat"; -GRANT EXECUTE ON WINDOW sys.group_concat(string) TO PUBLIC; -CREATE WINDOW sys.group_concat(str string, sep string) RETURNS string EXTERNAL NAME "sql"."str_group_concat"; -GRANT EXECUTE ON WINDOW sys.group_concat(string, string) TO PUBLIC; diff --git a/sql/scripts/39_analytics.sql b/sql/scripts/39_analytics.sql --- a/sql/scripts/39_analytics.sql +++ b/sql/scripts/39_analytics.sql @@ -445,3 +445,10 @@ GRANT EXECUTE ON WINDOW corr(REAL, REAL) create window corr(e1 DOUBLE, e2 DOUBLE) returns DOUBLE external name "sql"."corr"; GRANT EXECUTE ON WINDOW corr(DOUBLE, DOUBLE) TO PUBLIC; + +create window sys.group_concat(str string) returns string + external name "sql"."str_group_concat"; +GRANT EXECUTE ON WINDOW sys.group_concat(string) TO PUBLIC; +create window sys.group_concat(str string, sep string) returns string + external name "sql"."str_group_concat"; +GRANT EXECUTE ON WINDOW sys.group_concat(string, string) TO PUBLIC; diff --git a/sql/scripts/49_strings.sql b/sql/scripts/49_strings.sql --- a/sql/scripts/49_strings.sql +++ b/sql/scripts/49_strings.sql @@ -59,3 +59,10 @@ grant execute on filter function contain create filter function sys.contains(x string, y string, icase boolean) external name str.contains; grant execute on filter function contains(string, string, boolean) to public; + +create aggregate sys.group_concat(str string) returns string with order + with order external name "aggr"."str_group_concat"; +GRANT EXECUTE ON AGGREGATE sys.group_concat(string) TO PUBLIC; +create aggregate sys.group_concat(str string, sep string) returns string with order + with order external name "aggr"."str_group_concat"; +GRANT EXECUTE ON AGGREGATE sys.group_concat(string, string) TO PUBLIC; ___ checkin-list mailing list -- checkin-list@monetdb.org To unsubscribe send an email to checkin-list-le...@monetdb.org