MonetDB: default - Add missing minus in path name.

2024-05-14 Thread Sjoerd Mullender via checkin-list
Changeset: 6e1d39ce866c for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/6e1d39ce866c
Modified Files:
tools/mserver/mserver5.c
Branch: default
Log Message:

Add missing minus in path name.


diffs (12 lines):

diff --git a/tools/mserver/mserver5.c b/tools/mserver/mserver5.c
--- a/tools/mserver/mserver5.c
+++ b/tools/mserver/mserver5.c
@@ -681,7 +681,7 @@ main(int argc, char **av)
*p = '\0';
for (int i = 0; libdirs[i] != NULL; i++) {
int len = snprintf(prmodpath, 
sizeof(prmodpath),
-  
"%s%c%s%cmonetdb5%s",
+  
"%s%c%s%cmonetdb5-%s",
   
binpath, DIR_SEP, libdirs[i], DIR_SEP,
   
MONETDB_VERSION);
if (len == -1 || len >= FILENAME_MAX)
___
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org


MonetDB: default - Add a minus to the module search path.

2024-05-14 Thread Sjoerd Mullender via checkin-list
Changeset: 65d4616042ef for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/65d4616042ef
Modified Files:
monetdb5/extras/rapi/rapi.R
Branch: default
Log Message:

Add a minus to the module search path.


diffs (12 lines):

diff --git a/monetdb5/extras/rapi/rapi.R b/monetdb5/extras/rapi/rapi.R
--- a/monetdb5/extras/rapi/rapi.R
+++ b/monetdb5/extras/rapi/rapi.R
@@ -57,7 +57,7 @@ rewireFunc("q", quit, "base")
 rm(rewireFunc)
 
 loopback_query <- function(query) {
-   dyn.load(file.path(MONETDB_LIBDIR, paste0("monetdb5", MONETDB_VERSION), 
"lib_rapi.so"))
+   dyn.load(file.path(MONETDB_LIBDIR, paste0("monetdb5-", 
MONETDB_VERSION), "lib_rapi.so"))
res <- .Call("RAPIloopback", paste0(query, "\n;"), package="lib_rapi")
if (is.character(res)) {
stop(res)
___
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org


MonetDB: Dec2023 - enable partitioning on rangejoins

2024-05-14 Thread Niels Nes via checkin-list
Changeset: eed3d16b33f6 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/eed3d16b33f6
Modified Files:
monetdb5/optimizer/opt_mergetable.c
Branch: Dec2023
Log Message:

enable partitioning on rangejoins


diffs (88 lines):

diff --git a/monetdb5/optimizer/opt_mergetable.c 
b/monetdb5/optimizer/opt_mergetable.c
--- a/monetdb5/optimizer/opt_mergetable.c
+++ b/monetdb5/optimizer/opt_mergetable.c
@@ -945,6 +945,68 @@ mat_join2(MalBlkPtr mb, InstrPtr p, matl
 }
 
 static int
+mat_rangejoin(MalBlkPtr mb, InstrPtr p, matlist_t *ml, int m, int n)
+{
+   int tpe1 = getArgType(mb, p, 0), tpe2 = getArgType(mb, p, 1), k, nr = 1;
+   mat_t *mat = ml->v;
+   InstrPtr l;
+   InstrPtr r;
+
+   //printf("# %s.%s(%d,%d)", getModuleId(p), getFunctionId(p), m, n);
+
+   assert(m >= 0 && n >= 0 && mat[m].mi->argc == mat[n].mi->argc);
+   l = newInstructionArgs(mb, matRef, packRef, mat[m].mi->argc * 
mat[n].mi->argc);
+   r = newInstructionArgs(mb, matRef, packRef, mat[m].mi->argc * 
mat[n].mi->argc);
+   if (!l || !r) {
+   freeInstruction(l);
+   freeInstruction(r);
+   return -1;
+   }
+
+   getArg(l, 0) = getArg(p, 0);
+   getArg(r, 0) = getArg(p, 1);
+
+   for (k = 1; k < mat[m].mi->argc; k++) {
+   InstrPtr q = copyInstruction(p);
+
+   if (!q) {
+   freeInstruction(l);
+   freeInstruction(r);
+   return -1;
+   }
+
+   getArg(q, 0) = newTmpVariable(mb, tpe1);
+   getArg(q, 1) = newTmpVariable(mb, tpe2);
+
+   getArg(q, 3) = getArg(mat[m].mi, k);
+   getArg(q, 4) = getArg(mat[n].mi, k);
+   pushInstruction(mb, q);
+
+   if (mb->errors || propagatePartnr(ml, getArg(mat[m].mi, k), 
getArg(q, 0), nr)
+  || propagatePartnr(ml, getArg(mat[n].mi, 
k), getArg(q, 1), nr)) {
+   freeInstruction(r);
+   freeInstruction(l);
+   return -1;
+   }
+
+   /* add result to mat */
+   l = pushArgument(mb, l, getArg(q, 0));
+   r = pushArgument(mb, r, getArg(q, 1));
+   nr++;
+   }
+   if (mb->errors || mat_add(ml, l, mat_none, getFunctionId(p))) {
+   freeInstruction(l);
+   freeInstruction(r);
+   return -1;
+   }
+   if (mat_add(ml, r, mat_none, getFunctionId(p))) {
+   freeInstruction(r);
+   return -1;
+   }
+   return 0;
+}
+
+static int
 join_split(Client cntxt, InstrPtr p, int args)
 {
char *name = NULL;
@@ -2420,6 +2482,15 @@ OPTmergetableImplementation(Client cntxt
goto cleanup;
}
} else {
+   if (bats + nilbats == 5 && !is_a_mat(getArg(p, 
p->retc), &ml) && match == 2) {
+   n = is_a_mat(getArg(p, p->retc + 1), 
&ml);
+   o = is_a_mat(getArg(p, p->retc + 2), 
&ml);
+   if (mat_rangejoin(mb, p, &ml, n, o)) {
+   msg = createException(MAL, 
"optimizer.mergetable",
+   
  SQLSTATE(HY013) MAL_MALLOC_FAIL);
+   goto cleanup;
+   }
+   } else
if (mat_joinNxM(cntxt, mb, p, &ml, bats)) {
msg = createException(MAL, 
"optimizer.mergetable",

  SQLSTATE(HY013) MAL_MALLOC_FAIL);
___
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org


MonetDB: Dec2023 - merged

2024-05-14 Thread Niels Nes via checkin-list
Changeset: 626a06b4c450 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/626a06b4c450
Branch: Dec2023
Log Message:

merged


diffs (truncated from 388 to 300 lines):

diff --git a/.hgtags b/.hgtags
--- a/.hgtags
+++ b/.hgtags
@@ -826,3 +826,4 @@ dcc8c702e685a4faf21ccf663028d1bc3d1165d1
 d656785f49ee62c19705722aa6b7c171904c64d5 Dec2023_7
 d656785f49ee62c19705722aa6b7c171904c64d5 Dec2023_SP2_release
 9a694c41042503a22d6c92aeab5bc4ca1912b62e Dec2023_9
+9a694c41042503a22d6c92aeab5bc4ca1912b62e Dec2023_SP3_release
diff --git a/gdk/gdk_calc_convert.c b/gdk/gdk_calc_convert.c
--- a/gdk/gdk_calc_convert.c
+++ b/gdk/gdk_calc_convert.c
@@ -865,6 +865,7 @@ convert_str_fix(BATiter *bi, int tp, voi
return 0;
}
 
+   int (*atomcmp)(const void *, const void *) = ATOMcompare(tp);
TIMEOUT_LOOP(ci->ncand, timeoffset) {
oid x = canditer_next(ci) - candoff;
const char *s = BUNtvar(*bi, x);
@@ -878,7 +879,7 @@ convert_str_fix(BATiter *bi, int tp, voi
goto conversion_failed;
}
assert(len == ATOMsize(tp));
-   if (ATOMcmp(tp, dst, nil) == 0)
+   if (atomcmp(dst, nil) == 0)
nils++;
}
dst = (void *) ((char *) dst + len);
diff --git a/gdk/gdk_hash.c b/gdk/gdk_hash.c
--- a/gdk/gdk_hash.c
+++ b/gdk/gdk_hash.c
@@ -899,7 +899,8 @@ BAThash_impl(BAT *restrict b, struct can
case TYPE_uuid:
starthash(uuid);
break;
-   default:
+   default: {
+   int (*atomcmp)(const void *, const void *) = 
ATOMcompare(h->type);
TIMEOUT_LOOP(p, timeoffset) {
const void *restrict v = BUNtail(bi, o - 
b->hseqbase);
c = hash_any(h, v);
@@ -913,8 +914,7 @@ BAThash_impl(BAT *restrict b, struct can
for (hb = hget;
 hb != BUN_NONE;
 hb = HASHgetlink(h, hb)) {
-   if (ATOMcmp(h->type,
-   v,
+   if (atomcmp(v,
BUNtail(bi, hb)) == 
0)
break;
}
@@ -928,6 +928,7 @@ BAThash_impl(BAT *restrict b, struct can
  GOTO_LABEL_TIMEOUT_HANDLER(bailout));
break;
}
+   }
TRC_DEBUG_IF(ACCELERATOR) if (p < cnt1)
TRC_DEBUG_ENDIF(ACCELERATOR,
"%s: abort starthash with "
@@ -975,7 +976,8 @@ BAThash_impl(BAT *restrict b, struct can
case TYPE_uuid:
finishhash(uuid);
break;
-   default:
+   default: {
+   int (*atomcmp)(const void *, const void *) = 
ATOMcompare(h->type);
TIMEOUT_LOOP(ci->ncand - p, timeoffset) {
const void *restrict v = BUNtail(bi, o - b->hseqbase);
c = hash_any(h, v);
@@ -985,7 +987,7 @@ BAThash_impl(BAT *restrict b, struct can
for (hb = hget;
 hb != BUN_NONE;
 hb = HASHgetlink(h, hb)) {
-   if (ATOMcmp(h->type, v, BUNtail(bi, 
hb)) == 0)
+   if (atomcmp(v, BUNtail(bi, hb)) == 0)
break;
}
h->nunique += hb == BUN_NONE;
@@ -999,6 +1001,7 @@ BAThash_impl(BAT *restrict b, struct can
  GOTO_LABEL_TIMEOUT_HANDLER(bailout));
break;
}
+   }
bat_iterator_end(&bi);
/* if the number of unique values is equal to the bat count,
 * all values are necessarily distinct */
diff --git a/sql/backends/monet5/sql_upgrades.c 
b/sql/backends/monet5/sql_upgrades.c
--- a/sql/backends/monet5/sql_upgrades.c
+++ b/sql/backends/monet5/sql_upgrades.c
@@ -6594,6 +6594,46 @@ sql_update_dec2023_sp1(Client c, mvc *sq
return err;
 }
 
+static str
+sql_update_dec2023_sp4(Client c, mvc *sql, sql_schema *s)
+{
+   char *err;
+   res_table *output;
+   BAT *b;
+
+   (void) sql;
+   (void) s;
+
+   /* SQL optimizer fixes make that some "dependencies" are no longer
+* dependencies (functions that depend on all columns of a table
+* when it only actually uses a subset of the columns); while we're
+* at it, also fix some ancient dependency ch

MonetDB: default - Upgrade: add new generate_series functions.

2024-05-14 Thread Sjoerd Mullender via checkin-list
Changeset: 9a60c2693323 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/9a60c2693323
Modified Files:
sql/backends/monet5/sql_upgrades.c

sql/test/emptydb-previous-upgrade-chain-hge/Tests/upgrade.stable.out.int128
sql/test/emptydb-previous-upgrade-chain/Tests/upgrade.stable.out
sql/test/emptydb-previous-upgrade-chain/Tests/upgrade.stable.out.int128
sql/test/emptydb-previous-upgrade-hge/Tests/upgrade.stable.out.int128
sql/test/emptydb-previous-upgrade/Tests/upgrade.stable.out
sql/test/emptydb-previous-upgrade/Tests/upgrade.stable.out.int128
sql/test/emptydb-upgrade-chain-hge/Tests/upgrade.stable.out.int128
sql/test/emptydb-upgrade-chain/Tests/upgrade.stable.out
sql/test/emptydb-upgrade-chain/Tests/upgrade.stable.out.int128
sql/test/emptydb-upgrade-hge/Tests/upgrade.stable.out.int128
sql/test/emptydb-upgrade/Tests/upgrade.stable.out
sql/test/emptydb-upgrade/Tests/upgrade.stable.out.int128
sql/test/emptydb/Tests/check.stable.out.int128

sql/test/testdb-previous-upgrade-chain-hge/Tests/upgrade.stable.out.int128
sql/test/testdb-previous-upgrade-chain/Tests/upgrade.stable.out
sql/test/testdb-previous-upgrade-chain/Tests/upgrade.stable.out.int128
sql/test/testdb-previous-upgrade-hge/Tests/upgrade.stable.out.int128
sql/test/testdb-previous-upgrade/Tests/upgrade.stable.out
sql/test/testdb-previous-upgrade/Tests/upgrade.stable.out.int128
sql/test/testdb-upgrade-chain-hge/Tests/upgrade.stable.out.int128
sql/test/testdb-upgrade-chain/Tests/upgrade.stable.out
sql/test/testdb-upgrade-chain/Tests/upgrade.stable.out.int128
sql/test/testdb-upgrade-hge/Tests/upgrade.stable.out.int128
sql/test/testdb-upgrade/Tests/upgrade.stable.out
sql/test/testdb-upgrade/Tests/upgrade.stable.out.int128
Branch: default
Log Message:

Upgrade: add new generate_series functions.


diffs (truncated from 610 to 300 lines):

diff --git a/sql/backends/monet5/sql_upgrades.c 
b/sql/backends/monet5/sql_upgrades.c
--- a/sql/backends/monet5/sql_upgrades.c
+++ b/sql/backends/monet5/sql_upgrades.c
@@ -327,7 +327,7 @@ static str
 sql_create_shp(Client c)
 {
//Create the new SHPload procedures
-   const char *query = "create procedure SHPLoad(fname string, schemaname 
string, tablename string) external name shp.load;\n"
+   const char query[] = "create procedure SHPLoad(fname string, schemaname 
string, tablename string) external name shp.load;\n"
"create procedure SHPLoad(fname string, tablename string) 
external name shp.load;\n"
"update sys.functions set system = true where schema_id = 2000 
and name in ('shpload');";
printf("Running database upgrade commands:\n%s\n", query);
@@ -340,7 +340,7 @@ static str
 sql_drop_shp(Client c)
 {
//Drop the old SHP procedures (upgrade from version before shpload 
upgrade)
-   const char *query = "drop procedure if exists SHPattach(string) 
cascade;\n"
+   const char query[] = "drop procedure if exists SHPattach(string) 
cascade;\n"
"drop procedure if exists SHPload(integer) cascade;\n"
"drop procedure if exists SHPload(integer, geometry) 
cascade;\n";
printf("Running database upgrade commands:\n%s\n", query);
@@ -351,7 +351,7 @@ sql_drop_shp(Client c)
 static str
 sql_update_generator(Client c)
 {
-   const char *query = "update sys.args set name = 'limit' where name = 
'last' and func_id in (select id from sys.functions where schema_id = 2000 and 
name = 'generate_series' and func like '% last %');\n"
+   const char query[] = "update sys.args set name = 'limit' where name = 
'last' and func_id in (select id from sys.functions where schema_id = 2000 and 
name = 'generate_series' and func like '% last %');\n"
"update sys.functions set func = replace(func, ' last ', ' 
\"limit\" ') where schema_id = 2000 and name = 'generate_series' and func like 
'% last %';\n";
return SQLstatementIntern(c, query, "update", true, false, NULL);
 }
@@ -3287,7 +3287,7 @@ sql_update_jan2022(Client c, mvc *sql)
list_append(l, &tp);
if (sql_bind_func_(sql, s->base.name, "strimp_create", 
l, F_PROC, true, true)) {
/* do the upgrade by removing the two functions 
*/
-   const char *query =
+   const char query[] =
"drop filter function 
sys.strimp_filter(string, string) cascade;\n"
"drop procedure 
sys.strimp_create(string, string, string) cascade;\n";
printf("Running database upgrade 
commands:\n%s\n", query);
@@ -5198,7 +5198,7 @@ sql_update_jun2023(Client c, mvc *sql, s
if (wr)
wr->system 

MonetDB: default - Turn constant pointers to constant string int...

2024-05-14 Thread Sjoerd Mullender via checkin-list
Changeset: dc85db7d9402 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/dc85db7d9402
Modified Files:
clients/mapiclient/dump.c
clients/odbc/winsetup/install.c
common/stream/stdio_stream.c
geom/monetdb5/geom.c
monetdb5/mal/mal_session.c
sql/backends/monet5/UDF/capi/capi.c
sql/backends/monet5/sql.c
sql/backends/monet5/sql_bincopy.c
sql/backends/monet5/sql_bincopyconvert.c
sql/backends/monet5/sql_scenario.c
sql/backends/monet5/vaults/csv/csv.c
sql/server/sql_semantic.c
sql/storage/store.c
tools/monetdbe/monetdbe.c
Branch: default
Log Message:

Turn constant pointers to constant string into constant arrays.


diffs (truncated from 519 to 300 lines):

diff --git a/clients/mapiclient/dump.c b/clients/mapiclient/dump.c
--- a/clients/mapiclient/dump.c
+++ b/clients/mapiclient/dump.c
@@ -2654,9 +2654,9 @@ bailout:
 int
 dump_database(Mapi mid, stream *sqlf, const char *ddir, const char *ext, bool 
describe, bool useInserts, bool noescape)
 {
-   const char *start_trx = "START TRANSACTION";
-   const char *end = "ROLLBACK";
-   const char *types =
+   const char start_trx[] = "START TRANSACTION";
+   const char end[] = "ROLLBACK";
+   const char types[] =
"SELECT s.name, "
   "t.systemname, "
   "t.sqlname "
@@ -2708,13 +2708,13 @@ dump_database(Mapi mid, stream *sqlf, co
  "AND ui.name <> 'monetdb' "
  "AND ui.name <> '.snapshot' "
"ORDER BY ui.name";
-   const char *roles =
+   const char roles[] =
"SELECT name "
"FROM sys.auths "
"WHERE name NOT IN (SELECT name FROM sys.db_user_info) "
  "AND grantor <> 0 "
"ORDER BY name";
-   const char *grants =
+   const char grants[] =
/* all grants granting roles to users excepting the default 
role */
"SELECT a1.name, "
   "a2.name "
@@ -2727,7 +2727,7 @@ dump_database(Mapi mid, stream *sqlf, co
  "AND a1.name = ui.name "
  "AND a2.id <> ui.default_role "
"ORDER BY a1.name, a2.name";
-   const char *table_grants =
+   const char table_grants[] =
"SELECT s.name, t.name, "
   "a.name, "
   "sum(p.privileges), "
@@ -2744,7 +2744,7 @@ dump_database(Mapi mid, stream *sqlf, co
  "AND p.grantable = go.id "
"GROUP BY s.name, t.name, a.name, g.name, go.opt "
"ORDER BY s.name, t.name, a.name, g.name, go.opt";
-   const char *column_grants =
+   const char column_grants[] =
"SELECT s.name, t.name, "
   "c.name, a.name, "
   "pc.privilege_code_name, "
@@ -2766,7 +2766,7 @@ dump_database(Mapi mid, stream *sqlf, co
  "AND p.privileges = pc.privilege_code_id "
  "AND p.grantable = go.id "
"ORDER BY s.name, t.name, c.name, a.name, g.name, p.grantable";
-   const char *function_grants =
+   const char function_grants[] =
"SELECT f.id, "
   "s.name, "
   "f.name, "
@@ -2803,7 +2803,7 @@ dump_database(Mapi mid, stream *sqlf, co
 "f.id, "
 "a.inout DESC, "
 "a.number";
-   const char *global_grants =
+   const char global_grants[] =
"SELECT a.name, pc.grnt, g.name, go.opt "
"FROM sys.privileges p, "
 "sys.auths a, "
@@ -2816,22 +2816,22 @@ dump_database(Mapi mid, stream *sqlf, co
  "AND p.privileges = pc.id "
  "AND p.grantable = go.id "
"ORDER BY a.name, g.name, go.opt";
-   const char *schemas =
+   const char schemas[] =
"SELECT s.name, a.name, rem.remark "
"FROM sys.schemas s LEFT OUTER JOIN sys.comments rem ON s.id = 
rem.id, "
 "sys.auths a "
"WHERE s.\"authorization\" = a.id "
  "AND s.system = FALSE "
"ORDER BY s.name";
-   const char *sequences1 =
+   const char sequences1[] =
"SELECT sch.name, seq.name, rem.remark "
"FROM sys.schemas sch, "
 "sys.sequences seq LEFT OUTER JOIN sys.comments rem ON 
seq.id = rem.id "
"WHERE sch.id = seq.schema_id "
"ORDER BY sch.name, seq.name";
-   const char *sequences2 =
+   const char sequences2[] =
"SELECT * FROM sys.describe_sequences ORDER BY sch, seq";
-   const char *tables =
+   const char tables[] =
"SELECT t.id AS id, "
   "s.name AS sname, "
 

MonetDB: balanced_union - Implements push_join_down_munion optim...

2024-05-14 Thread stefanos mavros via checkin-list
Changeset: 3391fa2b099f for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/3391fa2b099f
Modified Files:
sql/server/rel_optimize_proj.c
Branch: balanced_union
Log Message:

Implements push_join_down_munion optimizer WIP 2


diffs (63 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
@@ -3726,10 +3726,14 @@ rel_push_join_down_munion(visitor *v, sq
!(je = rel_is_join_on_pkey(rel, aligned_pk_fk
return rel;
 
-   // TODO: why? bailout for no semijoin without pkey joins
+   // TODO: why? bailout for union semijoin without pkey joins 
expressions
if (is_semi(rel->op) && is_munion(l->op) && !je)
return rel;
 
+   /* if both sides are munions we assume that they will have the 
same number of children */
+   if (is_munion(l->op) && is_munion(r->op) && list_length(l->l) 
!= list_length(r->l))
+   return rel;
+
if (is_munion(l->op) && !need_distinct(l) && !is_single(l) &&
   !is_munion(r->op)){
/* join(munion(a,b,c), d) -> munion(join(a,d), 
join(b,d), join(c,d)) */
@@ -3756,8 +3760,41 @@ rel_push_join_down_munion(visitor *v, sq
} else if (is_munion(l->op) && !need_distinct(l) && 
!is_single(l) &&
   is_munion(r->op) && !need_distinct(r) && 
!is_single(r) &&
   je) {
-   /* join(munion(a,b,c), union(d,e,f)) -> 
munion(join(a,d), join(b,e), join(c,f)) */
-   // TODO
+   /* join(munion(a,b,c), munion(d,e,f)) -> 
munion(join(a,d), join(b,e), join(c,f)) */
+   list *cps = sa_list(v->sql->sa);
+   /* create pairwise joins between left and right parts. 
assume eq num of parts (see earlier bailout) */
+   for (node *n = ((list*)l->l)->h, *m=((list*)r->l)->h; n 
&& m; n = n->next, m = m->next) {
+   /* left part */
+   sql_rel *lp = rel_dup(n->data);
+   if (!is_project(lp->op))
+   lp = rel_project(v->sql->sa, lp, 
rel_projections(v->sql, lp, NULL, 1, 1));
+   rel_rename_exps(v->sql, l->exps, lp->exps);
+   if (l != ol) {
+   lp = rel_project(v->sql->sa, lp, NULL);
+   lp->exps = exps_copy(v->sql, ol->exps);
+   set_processed(lp);
+   }
+   /* right part */
+   sql_rel *rp = rel_dup(m->data);
+   if (!is_project(rp->op))
+   rp = rel_project(v->sql->sa, rp, 
rel_projections(v->sql, rp, NULL, 1, 1));
+   rel_rename_exps(v->sql, l->exps, rp->exps);
+   if (l != ol) {
+   rp = rel_project(v->sql->sa, rp, NULL);
+   rp->exps = exps_copy(v->sql, ol->exps);
+   set_processed(rp);
+   }
+   /* combine them */
+   sql_rel *cp = rel_crossproduct(v->sql->sa, lp, 
rp, rel->op);
+   cp->exps = exps_copy(v->sql, exps);
+   cp->attr = exps_copy(v->sql, attr);
+   set_processed(cp);
+   cp = rel_project(v->sql->sa, cp, 
rel_projections(v->sql, cp, NULL, 1, 1));
+   cps = append(cps, cp);
+   }
+   v->changes++;
+   return rel_inplace_setop_n_ary(v->sql, rel, cps, 
op_munion,
+   
   rel_projections(v->sql, rel, NULL, 1, 1));
} else if (!is_munion(l->op) &&
is_munion(r->op) && !need_distinct(r) && 
!is_single(r) &&
   !is_semi(rel->op)) {
___
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org


MonetDB: Dec2023 - Fix an old upgrade error where triggers were ...

2024-05-14 Thread Sjoerd Mullender via checkin-list
Changeset: ad9b188058a3 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/ad9b188058a3
Modified Files:
sql/backends/monet5/sql_upgrades.c
sql/test/emptydb-previous-upgrade-chain-hge/Tests/All

sql/test/emptydb-previous-upgrade-chain-hge/Tests/upgrade.stable.out.int128
sql/test/emptydb-previous-upgrade-chain/Tests/All
sql/test/emptydb-previous-upgrade-chain/Tests/upgrade.stable.out
sql/test/emptydb-previous-upgrade-chain/Tests/upgrade.stable.out.int128
sql/test/emptydb-previous-upgrade-hge/Tests/upgrade.stable.out.int128
sql/test/emptydb-previous-upgrade/Tests/upgrade.stable.out
sql/test/emptydb-previous-upgrade/Tests/upgrade.stable.out.int128
sql/test/emptydb-upgrade-chain-hge/Tests/All
sql/test/emptydb-upgrade-chain-hge/Tests/upgrade.stable.out.int128
sql/test/emptydb-upgrade-chain/Tests/All
sql/test/emptydb-upgrade-chain/Tests/upgrade.stable.out
sql/test/emptydb-upgrade-chain/Tests/upgrade.stable.out.int128
sql/test/emptydb-upgrade-hge/Tests/upgrade.stable.out.int128
sql/test/emptydb-upgrade/Tests/upgrade.stable.out
sql/test/emptydb-upgrade/Tests/upgrade.stable.out.int128
sql/test/emptydb/Tests/check.SQL.py

sql/test/testdb-previous-upgrade-chain-hge/Tests/upgrade.stable.out.int128
sql/test/testdb-previous-upgrade-chain/Tests/upgrade.stable.out
sql/test/testdb-previous-upgrade-chain/Tests/upgrade.stable.out.int128
sql/test/testdb-previous-upgrade-hge/Tests/upgrade.stable.out.int128
sql/test/testdb-previous-upgrade/Tests/upgrade.stable.out
sql/test/testdb-previous-upgrade/Tests/upgrade.stable.out.int128
sql/test/testdb-upgrade-chain-hge/Tests/upgrade.stable.out.int128
sql/test/testdb-upgrade-chain/Tests/upgrade.stable.out
sql/test/testdb-upgrade-chain/Tests/upgrade.stable.out.int128
sql/test/testdb-upgrade-hge/Tests/upgrade.stable.out.int128
sql/test/testdb-upgrade/Tests/upgrade.stable.out
sql/test/testdb-upgrade/Tests/upgrade.stable.out.int128
Branch: Dec2023
Log Message:

Fix an old upgrade error where triggers were left with bad table_id values.


diffs (truncated from 436 to 300 lines):

diff --git a/sql/backends/monet5/sql_upgrades.c 
b/sql/backends/monet5/sql_upgrades.c
--- a/sql/backends/monet5/sql_upgrades.c
+++ b/sql/backends/monet5/sql_upgrades.c
@@ -6616,17 +6616,24 @@ sql_update_dec2023_sp4(Client c, mvc *sq
b = BATdescriptor(output->cols[0].b);
if (b) {
if (BATcount(b) > 0) {
-   const char query[] = "delete from sys.dependencies 
where (id, depend_id) in (select c.id, f.id from sys.functions f, sys._tables 
t, sys._columns c, sys.dependencies d where c.table_id = t.id and f.id = 
d.depend_id and c.id = d.id and f.schema_id = 2000 and t.schema_id = 2000 and 
(f.name, t.name, c.name) in (values ('describe_columns', '_columns', 
'storage'), ('describe_function', 'function_languages', 'language_name'), 
('describe_function', 'function_types', 'function_type_name'), 
('describe_function', 'functions', 'func'), ('describe_function', 'functions', 
'mod'), ('describe_function', 'functions', 'semantics'), ('describe_function', 
'functions', 'side_effect'), ('describe_function', 'functions', 'system'), 
('describe_function', 'functions', 'vararg'), ('describe_function', 
'functions', 'varres'), ('describe_function', 'schemas', 'authorization'), 
('describe_function', 'schemas', 'owner'), ('describe_function', 'schemas', 
'system'), ('describe_table', '_tables', 'access'), ('de
 scribe_table', '_tables', 'commit_action'), ('describe_table', '_tables', 
'system')));\n"
+   const char query[] =
+   "delete from sys.dependencies where (id, 
depend_id) in (select c.id, f.id from sys.functions f, sys._tables t, 
sys._columns c, sys.dependencies d where c.table_id = t.id and f.id = 
d.depend_id and c.id = d.id and f.schema_id = 2000 and t.schema_id = 2000 and 
(f.name, t.name, c.name) in (values ('describe_columns', '_columns', 
'storage'), ('describe_function', 'function_languages', 'language_name'), 
('describe_function', 'function_types', 'function_type_name'), 
('describe_function', 'functions', 'func'), ('describe_function', 'functions', 
'mod'), ('describe_function', 'functions', 'semantics'), ('describe_function', 
'functions', 'side_effect'), ('describe_function', 'functions', 'system'), 
('describe_function', 'functions', 'vararg'), ('describe_function', 
'functions', 'varres'), ('describe_function', 'schemas', 'authorization'), 
('describe_function', 'schemas', 'owner'), ('describe_function', 'schemas', 
'system'), ('describe_table', '_tables', 'access'), ('describe_table', '_tab
 les', 'commit_action'), ('describe_table', '_tables', 'system')));\n"
"delete from sys.dependencies where (id, 
depend_id) in (select c.id, v.id from

MonetDB: balanced_union - Implements push_join_down_munion optim...

2024-05-14 Thread stefanos mavros via checkin-list
Changeset: 7f4298bc94c6 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/7f4298bc94c6
Modified Files:
sql/server/rel_optimize_proj.c
Branch: balanced_union
Log Message:

Implements push_join_down_munion optimizer WIP 3


diffs (31 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
@@ -3799,7 +3799,26 @@ rel_push_join_down_munion(visitor *v, sq
is_munion(r->op) && !need_distinct(r) && 
!is_single(r) &&
   !is_semi(rel->op)) {
/* join(a, munion(b,c,d)) -> munion(join(a,b), 
join(a,c), join(a,d)) */
-   // TODO
+   for (node *n = ((list*)r->l)->h; n; n = n->next) {
+   sql_rel *pc = rel_dup(n->data);
+   if (!is_project(pc->op))
+   pc = rel_project(v->sql->sa, pc, 
rel_projections(v->sql, pc, NULL, 1, 1));
+   rel_rename_exps(v->sql, l->exps, pc->exps);
+   if (l != ol) {
+   pc = rel_project(v->sql->sa, pc, NULL);
+   pc->exps = exps_copy(v->sql, ol->exps);
+   set_processed(pc);
+   }
+   pc = rel_crossproduct(v->sql->sa, pc, 
rel_dup(or), rel->op);
+   pc->exps = exps_copy(v->sql, exps);
+   pc->attr = exps_copy(v->sql, attr);
+   set_processed(pc);
+   pc = rel_project(v->sql->sa, pc, 
rel_projections(v->sql, pc, NULL, 1, 1));
+   n->data = pc;
+   }
+   v->changes++;
+   return rel_inplace_setop_n_ary(v->sql, rel, r->l, 
op_munion,
+  
rel_projections(v->sql, rel, NULL, 1, 1));
} else if (!is_munion(l->op) &&
is_munion(r->op) && !need_distinct(r) && 
!is_single(r) &&
is_semi(rel->op) && je) {
___
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org


MonetDB: default - Remove assert. Fixes #7516.

2024-05-14 Thread Sjoerd Mullender via checkin-list
Changeset: 4316a7af79b3 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/4316a7af79b3
Modified Files:
sql/server/sql_semantic.c
Branch: default
Log Message:

Remove assert.  Fixes #7516.


diffs (11 lines):

diff --git a/sql/server/sql_semantic.c b/sql/server/sql_semantic.c
--- a/sql/server/sql_semantic.c
+++ b/sql/server/sql_semantic.c
@@ -121,7 +121,6 @@ tmp_schema(mvc *sql)
do { \
sql_schema *next = NULL; \
  \
-   assert(objstr); \
if (sname) { /* user has explicitly typed the schema, so either 
the object is there or we return error */ \
if (!(next = mvc_bind_schema(sql, sname))) \
return sql_error(sql, ERR_NOTFOUND, 
SQLSTATE(3F000) "%s: no such schema '%s'", error, sname); \
___
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.

2024-05-14 Thread Sjoerd Mullender via checkin-list
Changeset: 1c9d7fbe4bc0 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/1c9d7fbe4bc0
Modified Files:
gdk/gdk_calc_convert.c
gdk/gdk_hash.c
monetdb5/optimizer/opt_mergetable.c
sql/backends/monet5/sql_upgrades.c

sql/test/emptydb-previous-upgrade-chain-hge/Tests/upgrade.stable.out.int128
sql/test/emptydb-previous-upgrade-chain/Tests/upgrade.stable.out
sql/test/emptydb-previous-upgrade-chain/Tests/upgrade.stable.out.int128
sql/test/emptydb-previous-upgrade-hge/Tests/upgrade.stable.out.int128
sql/test/emptydb-previous-upgrade/Tests/upgrade.stable.out
sql/test/emptydb-previous-upgrade/Tests/upgrade.stable.out.int128
sql/test/emptydb-upgrade-chain-hge/Tests/upgrade.stable.out.int128
sql/test/emptydb-upgrade-chain/Tests/upgrade.stable.out
sql/test/emptydb-upgrade-chain/Tests/upgrade.stable.out.int128
sql/test/emptydb-upgrade-hge/Tests/upgrade.stable.out.int128
sql/test/emptydb-upgrade/Tests/upgrade.stable.out
sql/test/emptydb-upgrade/Tests/upgrade.stable.out.int128
sql/test/emptydb/Tests/check.SQL.py

sql/test/testdb-previous-upgrade-chain-hge/Tests/upgrade.stable.out.int128
sql/test/testdb-previous-upgrade-chain/Tests/upgrade.stable.out
sql/test/testdb-previous-upgrade-chain/Tests/upgrade.stable.out.int128
sql/test/testdb-previous-upgrade-hge/Tests/upgrade.stable.out.int128
sql/test/testdb-previous-upgrade/Tests/upgrade.stable.out
sql/test/testdb-previous-upgrade/Tests/upgrade.stable.out.int128
sql/test/testdb-upgrade-chain-hge/Tests/upgrade.stable.out.int128
sql/test/testdb-upgrade-chain/Tests/upgrade.stable.out
sql/test/testdb-upgrade-chain/Tests/upgrade.stable.out.int128
sql/test/testdb-upgrade-hge/Tests/upgrade.stable.out.int128
sql/test/testdb-upgrade/Tests/upgrade.stable.out
sql/test/testdb-upgrade/Tests/upgrade.stable.out.int128
Branch: default
Log Message:

Merge with Dec2023 branch.


diffs (truncated from 650 to 300 lines):

diff --git a/gdk/gdk_calc_convert.c b/gdk/gdk_calc_convert.c
--- a/gdk/gdk_calc_convert.c
+++ b/gdk/gdk_calc_convert.c
@@ -821,6 +821,7 @@ convert_str_fix(BATiter *bi, int tp, voi
return 0;
}
 
+   int (*atomcmp)(const void *, const void *) = ATOMcompare(tp);
TIMEOUT_LOOP(ci->ncand, qry_ctx) {
oid x = canditer_next(ci) - candoff;
const char *s = BUNtvar(*bi, x);
@@ -834,7 +835,7 @@ convert_str_fix(BATiter *bi, int tp, voi
goto conversion_failed;
}
assert(len == ATOMsize(tp));
-   if (ATOMcmp(tp, dst, nil) == 0)
+   if (atomcmp(dst, nil) == 0)
nils++;
}
dst = (void *) ((char *) dst + len);
diff --git a/gdk/gdk_hash.c b/gdk/gdk_hash.c
--- a/gdk/gdk_hash.c
+++ b/gdk/gdk_hash.c
@@ -873,7 +873,8 @@ BAThash_impl(BAT *restrict b, struct can
case TYPE_uuid:
starthash(uuid);
break;
-   default:
+   default: {
+   int (*atomcmp)(const void *, const void *) = 
ATOMcompare(h->type);
TIMEOUT_LOOP(p, qry_ctx) {
const void *restrict v = BUNtail(bi, o - 
b->hseqbase);
c = hash_any(h, v);
@@ -887,8 +888,7 @@ BAThash_impl(BAT *restrict b, struct can
for (hb = hget;
 hb != BUN_NONE;
 hb = HASHgetlink(h, hb)) {
-   if (ATOMcmp(h->type,
-   v,
+   if (atomcmp(v,
BUNtail(bi, hb)) == 
0)
break;
}
@@ -902,6 +902,7 @@ BAThash_impl(BAT *restrict b, struct can
  GOTO_LABEL_TIMEOUT_HANDLER(bailout, 
qry_ctx));
break;
}
+   }
TRC_DEBUG_IF(ACCELERATOR) if (p < cnt1)
TRC_DEBUG_ENDIF(ACCELERATOR,
"%s: abort starthash with "
@@ -949,7 +950,8 @@ BAThash_impl(BAT *restrict b, struct can
case TYPE_uuid:
finishhash(uuid);
break;
-   default:
+   default: {
+   int (*atomcmp)(const void *, const void *) = 
ATOMcompare(h->type);
TIMEOUT_LOOP(ci->ncand - p, qry_ctx) {
const void *restrict v = BUNtail(bi, o - b->hseqbase);
c = hash_any(h, v)