MonetDB: label - add v1 of merge_unions

2024-06-02 Thread Niels Nes via checkin-list
Changeset: 5070ec27cf06 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/5070ec27cf06
Modified Files:
sql/server/rel_optimize_proj.c
Branch: label
Log Message:

add v1 of merge_unions


diffs (43 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
@@ -3461,6 +3461,31 @@ rel_push_project_down_union(visitor *v, 
return rel;
 }
 
+static inline sql_rel *
+rel_merge_unions(visitor *v, sql_rel *rel)
+{
+   (void)v;
+   if (rel && is_munion(rel->op)) {
+   list *l = rel->l;
+   for(node *n = l->h; n; ) {
+   node *next = n->next;
+   sql_rel *i = n->data;
+   if (is_munion(i->op)) {
+   i = rel_dup(i);
+   list_remove_node(l, NULL, n);
+   l = list_merge(l, i->l, (fdup)NULL);
+   i->l = NULL;
+   rel_destroy(i);
+   if (!next)
+   next = l->h;
+   }
+   n = next;
+   }
+   rel->l = l;
+   }
+   return rel;
+}
+
 /*
  * Push (semi)joins down unions, this is basically for merge tables, where
  * we know that the fk-indices are split over two clustered merge tables.
@@ -3879,6 +3904,7 @@ static sql_rel *
 rel_optimize_unions_topdown_(visitor *v, sql_rel *rel)
 {
rel = rel_push_project_down_union(v, rel);
+   rel = rel_merge_unions(v, rel);
rel = rel_push_join_down_munion(v, rel);
return rel;
 }
___
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org


MonetDB: label - add upgade code and approved output

2024-06-02 Thread Niels Nes via checkin-list
Changeset: 680e570f7804 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/680e570f7804
Modified Files:
sql/backends/monet5/sql_upgrades.c
sql/test/emptydb/Tests/check.stable.out
sql/test/emptydb/Tests/check.stable.out.32bit
sql/test/emptydb/Tests/check.stable.out.int128
Branch: label
Log Message:

add upgade code and approved output


diffs (71 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
@@ -7041,6 +7041,10 @@ sql_update_default(Client c, mvc *sql, s
"GRANT SELECT ON sys.fully_qualified_functions 
TO PUBLIC;\n"
"GRANT SELECT ON sys.describe_privileges TO 
PUBLIC;\n"
"GRANT SELECT ON sys.describe_functions TO 
PUBLIC;\n"
+   "\n"
+   "CREATE FUNCTION check_constraint(sname STRING, 
cname STRING) RETURNS STRING EXTERNAL NAME sql.\"check\";\n"
+   "grant execute on function check_constraint to 
public;\n"
+   "\n"
"update sys.functions set system = true where 
not system and schema_id = 2000 and name in ('dump_database', 
'describe_columns', 'describe_type');\n"
"update sys._tables set system = true where not 
system and schema_id = 2000 and name in ('dump_comments', 'dump_tables', 
'dump_functions', 'dump_function_grants', 'describe_functions', 
'describe_privileges', 'describe_comments', 'fully_qualified_functions', 
'describe_tables');\n";
if ((t = mvc_bind_table(sql, s, "dump_comments")) != 
NULL)
diff --git a/sql/test/emptydb/Tests/check.stable.out 
b/sql/test/emptydb/Tests/check.stable.out
--- a/sql/test/emptydb/Tests/check.stable.out
+++ b/sql/test/emptydb/Tests/check.stable.out
@@ -1836,6 +1836,7 @@ select 'null in fkeys.delete_action', de
 [ "sys.functions", "sys",  "character_length", "SYSTEM",   
"length",   "str",  "Internal C",   "Scalar function",  false,  false,  
false,  false,  NULL,   "res_0","int",  31, 0,  "out",  
"arg_1","varchar",  0,  0,  "in",   NULL,   NULL,   NULL,   
NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   
NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   
NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   
NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   
NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   
NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   
NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL]
 [ "sys.functions", "sys",  "charindex","SYSTEM",   "locate",   
"str",  "Internal C",   "Scalar function",  false,  false,  false,  false,  
NULL,   "res_0","int",  31, 0,  "out",  "arg_1",
"varchar",  0,  0,  "in",   "arg_2","varchar",  0,  
0,  "in",   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   
NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   
NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   
NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   
NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   
NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   
NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL]
 [ "sys.functions", "sys",  "charindex","SYSTEM",   "locate3",  
"str",  "Internal C",   "Scalar function",  false,  false,  false,  false,  
NULL,   "res_0","int",  31, 0,  "out",  "arg_1",
"varchar",  0,  0,  "in",   "arg_2","varchar",  0,  
0,  "in",   "arg_3","int",  31, 0,  "in",   NULL,   NULL,   
NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   
NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   
NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   
NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   
NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   
NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL]
+[ "sys.functions", "sys",  "check_constraint", "SYSTEM",   "create 
function check_constraint(sname string, cname string) returns string external 
name sql.\"check\";", "sql",  "MAL",  "Scalar function",  false,  
false,  false,  true,   NULL,   "result",   "varchar",  0,  0,  
"out",  "sname","varchar",  0,  0,  "in",   "

MonetDB: label - approved output

2024-06-02 Thread Niels Nes via checkin-list
Changeset: 689d24cbb6d9 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/689d24cbb6d9
Modified Files:
sql/test/sql_dump/Tests/dump.test
Branch: label
Log Message:

approved output


diffs (17 lines):

diff --git a/sql/test/sql_dump/Tests/dump.test 
b/sql/test/sql_dump/Tests/dump.test
--- a/sql/test/sql_dump/Tests/dump.test
+++ b/sql/test/sql_dump/Tests/dump.test
@@ -369,10 +369,10 @@ ALTER TABLE "sys"."splitted" ADD TABLE "
 ALTER TABLE "sys"."splitted" ADD TABLE "sys"."second_decade" AS PARTITION FROM 
'2010-01-01 00:00:00.00' TO '2020-01-01 00:00:00.00';
 ALTER TABLE "sys"."m1" ADD TABLE "sys"."p1";
 SET SCHEMA "sfoo"; create trigger extra_insert after insert on "sfoo"."tfoo1" 
referencing new row as new_row for each statement insert into tfoo2(i) values 
(new_row.i)@;
-COMMENT ON SCHEMA "sbar" IS 'This is a comment on a schema';
+COMMENT ON SEQUENCE "sys"."seq1" IS 'This is a comment on a sequence.';
+COMMENT ON INDEX "sys"."ind3" IS 'This is a comment on an index.';
 COMMENT ON COLUMN "sfoo"."tfoo1"."i" IS 'This is a comment on a column.';
-COMMENT ON INDEX "sys"."ind3" IS 'This is a comment on an index.';
-COMMENT ON SEQUENCE "sys"."seq1" IS 'This is a comment on a sequence.';
+COMMENT ON SCHEMA "sbar" IS 'This is a comment on a schema';
 COMMENT ON WINDOW "sys"."stddev"(DOUBLE PRECISION,BIGINT) IS 'This is a 
comment on a window function.';
 GRANT SELECT ON TABLE "sys"."foo" TO "voc";
 GRANT UPDATE("i") ON "sys"."foo" TO "voc";
___
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org


MonetDB: label - small fix on getting the attribute names of the...

2024-06-02 Thread Niels Nes via checkin-list
Changeset: c2f0edcc5edd for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/c2f0edcc5edd
Modified Files:
sql/backends/monet5/vaults/csv/csv.c
Branch: label
Log Message:

small fix on getting the attribute names of the csv header line


diffs (12 lines):

diff --git a/sql/backends/monet5/vaults/csv/csv.c 
b/sql/backends/monet5/vaults/csv/csv.c
--- a/sql/backends/monet5/vaults/csv/csv.c
+++ b/sql/backends/monet5/vaults/csv/csv.c
@@ -44,7 +44,7 @@ next_delim(const char *s, const char *e,
else if (!inquote && *s == delim)
return s;
}
-   if (s < e)
+   if (s <= e)
return s;
return NULL;
 }
___
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org


MonetDB: label - more removal of string looks

2024-06-02 Thread Niels Nes via checkin-list
Changeset: 4d0b13c0faec for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/4d0b13c0faec
Modified Files:
sql/server/rel_optimize_exps.c
sql/server/rel_optimize_others.c
sql/server/rel_optimize_proj.c
sql/server/rel_optimize_sel.c
sql/server/rel_unnest.c
sql/test/rel-optimizers/Tests/groupjoin.test
Branch: label
Log Message:

more removal of string looks


diffs (276 lines):

diff --git a/sql/server/rel_optimize_exps.c b/sql/server/rel_optimize_exps.c
--- a/sql/server/rel_optimize_exps.c
+++ b/sql/server/rel_optimize_exps.c
@@ -755,15 +755,12 @@ rel_remove_alias(visitor *v, sql_rel *re
if (l->op == op_project) {
sql_exp *ne = rel_find_exp(l, e);
if (ne && ne->type == e_column && is_selfref(ne)) {
-   sql_exp *nne = NULL;
/* found ne in projection, try to find 
reference in the same list */
-   if (ne->l)
-   nne = exps_bind_column2(l->exps, ne->l, 
ne->r, NULL);
-   else
-   nne = exps_bind_column(l->exps, ne->r, 
NULL, NULL, 1);
+   sql_exp *nne = exps_bind_nid(l->exps, ne->nid);
if (nne && nne != ne && list_position(l->exps, 
nne) < list_position(l->exps, ne)) {
e->l = (char*)exp_relname(nne);
e->r = (char*)exp_name(nne);
+   e->nid = nne->alias.label;
v->changes++;
}
}
@@ -777,14 +774,11 @@ rel_remove_alias(visitor *v, sql_rel *re
sql_exp *ne = rel_find_exp(l, e);
found = true;
if (ne && ne->type == e_column && 
is_selfref(ne)) {
-   sql_exp *nne = NULL;
-   if (ne->l)
-   nne = 
exps_bind_column2(l->exps, ne->l, ne->r, NULL);
-   else
-   nne = exps_bind_column(l->exps, 
ne->r, NULL, NULL, 1);
+   sql_exp *nne = exps_bind_nid(l->exps, 
ne->nid);
if (nne && nne != ne && 
list_position(l->exps, nne) < list_position(l->exps, ne)) {
e->l = (char*)exp_relname(nne);
e->r = (char*)exp_name(nne);
+   e->nid = nne->alias.label;
v->changes++;
}
}
@@ -796,14 +790,11 @@ rel_remove_alias(visitor *v, sql_rel *re
sql_exp *ne = rel_find_exp(l, e);
found = true;
if (ne && ne->type == e_column && 
is_selfref(ne)) {
-   sql_exp *nne = NULL;
-   if (ne->l)
-   nne = 
exps_bind_column2(l->exps, ne->l, ne->r, NULL);
-   else
-   nne = exps_bind_column(l->exps, 
ne->r, NULL, NULL, 1);
+   sql_exp *nne = exps_bind_nid(l->exps, 
ne->nid);
if (nne && nne != ne && 
list_position(l->exps, nne) < list_position(l->exps, ne)) {
e->l = (char*)exp_relname(nne);
e->r = (char*)exp_name(nne);
+   e->nid = nne->alias.label;
v->changes++;
}
}
diff --git a/sql/server/rel_optimize_others.c b/sql/server/rel_optimize_others.c
--- a/sql/server/rel_optimize_others.c
+++ b/sql/server/rel_optimize_others.c
@@ -101,10 +101,8 @@ exp_push_down_prj(mvc *sql, sql_exp *e, 
 
e = ne;
ne = NULL;
-   if (e->l)
-   ne = exps_bind_column2(f->exps, e->l, e->r, 
NULL);
-   if (!ne && !e->l)
-   ne = exps_bind_column(f->exps, e->r, NULL, 
NULL, 1);
+   if (e->nid)
+   ne = exps_bind_nid(f->exps, e->nid);
if (ne && ne != one && list_position(f->exps, ne) >= 
list_position(f->exps, one))
ne = NULL;
if