MonetDB: default - add AND OR infixes for dump

2024-06-06 Thread Yunus Koning via checkin-list
Changeset: 7c980a7d1c64 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/7c980a7d1c64
Modified Files:
sql/server/rel_dump.c
Branch: default
Log Message:

add AND OR infixes for dump


diffs (15 lines):

diff --git a/sql/server/rel_dump.c b/sql/server/rel_dump.c
--- a/sql/server/rel_dump.c
+++ b/sql/server/rel_dump.c
@@ -2521,6 +2521,11 @@ is_infix(sql_func *f)
return true;
if (f->base.name[0] == '|' && f->base.name[1] == '|')
return true;
+   if (f->base.name[0] == 'o' && f->base.name[1] == 'r')
+   return true;
+   } else if (strlen(f->base.name) == 3) {
+   if (f->base.name[0] == 'a' && f->base.name[1] == 'n' && 
f->base.name[2] == 'd')
+   return true;
}
return false;
 }
___
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org


MonetDB: default - return null if check constraint not found

2024-06-06 Thread Yunus Koning via checkin-list
Changeset: dcc52208263a for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/dcc52208263a
Modified Files:
sql/backends/monet5/sql.c
Branch: default
Log Message:

return null if check constraint not found


diffs (23 lines):

diff --git a/sql/backends/monet5/sql.c b/sql/backends/monet5/sql.c
--- a/sql/backends/monet5/sql.c
+++ b/sql/backends/monet5/sql.c
@@ -5260,13 +5260,17 @@ SQLcheck(Client cntxt, MalBlkPtr mb, Mal
sql_schema *s = mvc_bind_schema(m, sname);
if (s) {
sql_key *k = mvc_bind_key(m, s, cname);
-   if (k->check) {
+   if (k && k->check) {
int pos = 0;
sql_rel *rel = rel_basetable(m, k->t, k->t->base.name);
sql_exp *exp = exp_read(m, rel, NULL, NULL, 
sa_strdup(m->sa, k->check), , 0);
-   *r = GDKstrdup(exp2sql(m, exp));
+   if (!(*r = GDKstrdup(exp2sql(m, exp
+   throw(SQL, "SQLcheck", SQLSTATE(HY013) 
MAL_MALLOC_FAIL);
+   return MAL_SUCCEED;
}
}
+   if (!(*r = GDKstrdup(str_nil)))
+   throw(SQL, "SQLcheck", SQLSTATE(HY013) MAL_MALLOC_FAIL);
return MAL_SUCCEED;
 }
 
___
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org


MonetDB: default - fixes #7527

2024-06-03 Thread Yunus Koning via checkin-list
Changeset: c720b5a862df for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/c720b5a862df
Modified Files:
sql/server/rel_select.c
sql/test/2024/Tests/distinct_from.test
Branch: default
Log Message:

fixes #7527


diffs (95 lines):

diff --git a/sql/server/rel_select.c b/sql/server/rel_select.c
--- a/sql/server/rel_select.c
+++ b/sql/server/rel_select.c
@@ -2804,15 +2804,42 @@ rel_logical_exp(sql_query *query, sql_re
char *compare_op = n->next->data.sval;
int quantifier = 0;
int is_semantics = 0;
+   bool is_distinct_from = false;
 
if (n->next->next->next)
quantifier = n->next->next->next->data.i_val + 1;
assert(quantifier == 0 || quantifier == 1 || quantifier == 2 || 
quantifier == 3 || quantifier == 4);
 
if (quantifier >= 3) {
+   if (quantifier == 4)
+   is_distinct_from = true;
quantifier = 0;
is_semantics = 1;
}
+   if (is_distinct_from) {
+   sql_exp* ls = rel_value_exp(query, , lo, 
f|sql_farg, ek);
+   if (!ls)
+   return NULL;
+   sql_exp* rs = rel_value_exp(query, , ro, 
f|sql_farg, ek);
+   if (!rs)
+   return NULL;
+
+   bool ls_is_non_null_atom = exp_is_atom(ls) && 
exp_is_not_null(ls);
+   bool rs_is_non_null_atom = exp_is_atom(rs) && 
exp_is_not_null(rs);
+
+   if (ls_is_non_null_atom || rs_is_non_null_atom) {
+   sql_rel* l = rel_compare(query, rel, sc, lo, 
ro, compare_op, f | sql_or, ek, quantifier, 0);
+   sql_subtype *t;
+   if (!(t = 
exp_subtype(rs_is_non_null_atom?ls:rs)))
+   return sql_error(sql, 01, 
SQLSTATE(42000) "Cannot have a parameter for IS NULL operator");
+   sql_exp* e = exp_compare(sql->sa, 
rs_is_non_null_atom?ls:rs, exp_atom(sql->sa, atom_general(sql->sa, t, NULL, 
0)), cmp_equal);
+   set_has_no_nil(e);
+   set_semantics(e);
+   sql_rel* r = 
rel_select_push_compare_exp_down(sql, rel, e, e->l, e->r, NULL, f | sql_or);
+
+   return rel_or(sql, rel_dup(rel), l, r, NULL, 
NULL, NULL);
+   }
+   }
 
/* [NOT] DISTINCT FROM */
return rel_compare(query, rel, sc, lo, ro, compare_op, f, ek, 
quantifier, is_semantics);
diff --git a/sql/test/2024/Tests/distinct_from.test 
b/sql/test/2024/Tests/distinct_from.test
--- a/sql/test/2024/Tests/distinct_from.test
+++ b/sql/test/2024/Tests/distinct_from.test
@@ -107,6 +107,28 @@ 1
 1
 0
 
+query I nosort
+select s FROM foo WHERE s IS DISTINCT FROM 20;
+
+10
+NULL
+
+query I nosort
+select s FROM foo WHERE s IS NOT DISTINCT FROM 20;
+
+20
+
+query I nosort
+select s FROM foo WHERE s + 10 IS DISTINCT FROM s;
+
+10
+20
+
+query I nosort
+select s FROM foo WHERE s + 10 IS NOT DISTINCT FROM s;
+
+NULL
+
 statement ok
 create table bar(s) as values (20), (30), (NULL)
 
@@ -176,3 +198,16 @@ 20
 20
 NULL
 NULL
+
+statement ok
+create table baz(s int)
+
+query II rowsort
+SELECT * FROM baz RIGHT JOIN foo ON true WHERE (1 IS DISTINCT FROM baz.s);
+
+NULL
+10
+NULL
+20
+NULL
+NULL
___
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org


MonetDB: default - fix merge conflict in 0a8d1af0c436

2024-05-31 Thread Yunus Koning via checkin-list
Changeset: 3f4c730fed75 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/3f4c730fed75
Modified Files:
sql/backends/monet5/sql_upgrades.c
Branch: default
Log Message:

fix merge conflict in 0a8d1af0c436


diffs (135 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
@@ -7066,32 +7066,110 @@ sql_update_default(Client c, mvc *sql, s
err = SQLstatementIntern(c, query, "update", true, 
false, NULL);
 
list *l;
-   if ((l = sa_list(sql->sa)) != NULL) {
-   sql_subtype tp1, tp2;
-   sql_find_subtype(, "date", 0, 0);
-   list_append(l, );
-   list_append(l, );
-   sql_find_subtype(, "day_interval", 0, 0);
-   list_append(l, );
-   if (!sql_bind_func_(sql, s->base.name, 
"generate_series", l, F_UNION, true, true)) {
-   const char query[] = "create function 
sys.generate_series(first date, \"limit\" date, stepsize interval month)\n"
-   "returns table (value date)\n"
-   "external name 
generator.series;\n"
-   "create function 
sys.generate_series(first date, \"limit\" date, stepsize interval day)\n"
-   "returns table (value date)\n"
-   "external name 
generator.series;\n"
-   "update sys.functions set 
system = true where system <> true and name = 'generate_series' and schema_id = 
2000;\n";
-   sql->session->status = 0;
-   sql->errstr[0] = '\0';
-   printf("Running database upgrade 
commands:\n%s\n", query);
-   fflush(stdout);
-   err = SQLstatementIntern(c, query, 
"update", true, false, NULL);
-   }
+   if (!(l = sa_list(sql->sa)))
+   return  "allocation failed";
+   sql_subtype tp1, tp2;
+   sql_find_subtype(, "date", 0, 0);
+   list_append(l, );
+   list_append(l, );
+   sql_find_subtype(, "day_interval", 0, 0);
+   list_append(l, );
+   if (!sql_bind_func_(sql, s->base.name, 
"generate_series", l, F_UNION, true, true)) {
+   const char query[] = "create function 
sys.generate_series(first date, \"limit\" date, stepsize interval month)\n"
+   "returns table (value date)\n"
+   "external name generator.series;\n"
+   "create function 
sys.generate_series(first date, \"limit\" date, stepsize interval day)\n"
+   "returns table (value date)\n"
+   "external name generator.series;\n"
+   "update sys.functions set system = true 
where system <> true and name = 'generate_series' and schema_id = 2000;\n";
+   sql->session->status = 0;
+   sql->errstr[0] = '\0';
+   printf("Running database upgrade 
commands:\n%s\n", query);
+   fflush(stdout);
+   err = SQLstatementIntern(c, query, "update", 
true, false, NULL);
}
}
BBPunfix(b->batCacheid);
}
res_table_destroy(output);
+
+   const char *query = "select id from args where func_id = (select id 
from functions where schema_id = 2000 and name = 'sessions');\n";
+   err = SQLstatementIntern(c, query, "update", true, false, );
+   if (err)
+   goto end;
+   b = BATdescriptor(output->cols[0].b);
+   if (b && BATcount(b) < 15) {
+   query =
+   "drop view sys.sessions;\n"
+   "drop function sys.sessions();\n"
+   "create function sys.sessions()\n"
+   " returns table(\n"
+   "  \"sessionid\" int,\n"
+   "  \"username\" string,\n"
+   "  \"login\" timestamp,\n"
+   "  \"idle\" timestamp,\n"
+   "  \"optimizer\" string,\n"
+   "  \"sessiontimeout\" int,\n"
+   "  \"querytimeout\" 

MonetDB: default - place upgrade code in proper scope

2024-05-31 Thread Yunus Koning via checkin-list
Changeset: 0a8d1af0c436 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/0a8d1af0c436
Modified Files:
sql/backends/monet5/sql_upgrades.c
Branch: default
Log Message:

place upgrade code in proper scope


diffs (163 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
@@ -6645,19 +6645,13 @@ sql_update_dec2023_sp4(Client c, mvc *sq
 static str
 sql_update_default(Client c, mvc *sql, sql_schema *s)
 {
-   allocator *old_sa = sql->sa;
char *err;
res_table *output;
BAT *b;
 
-   if ((sql->sa = sa_create(sql->pa)) == NULL) {
-   sql->sa = old_sa;
-   return "sa_create failed";
-   }
-
err = SQLstatementIntern(c, "SELECT id FROM sys.functions WHERE 
schema_id = 2000 AND name = 'describe_type' AND func LIKE '%sql_datatype%';\n", 
"update", true, false, );
if (err)
-   goto end;
+   return err;
b = BATdescriptor(output->cols[0].b);
if (b) {
if (BATcount(b) == 0) {
@@ -7070,114 +7064,34 @@ sql_update_default(Client c, mvc *sql, s
printf("Running database upgrade commands:\n%s\n", 
query);
fflush(stdout);
err = SQLstatementIntern(c, query, "update", true, 
false, NULL);
+
+   list *l;
+   if ((l = sa_list(sql->sa)) != NULL) {
+   sql_subtype tp1, tp2;
+   sql_find_subtype(, "date", 0, 0);
+   list_append(l, );
+   list_append(l, );
+   sql_find_subtype(, "day_interval", 0, 0);
+   list_append(l, );
+   if (!sql_bind_func_(sql, s->base.name, 
"generate_series", l, F_UNION, true, true)) {
+   const char query[] = "create function 
sys.generate_series(first date, \"limit\" date, stepsize interval month)\n"
+   "returns table (value date)\n"
+   "external name 
generator.series;\n"
+   "create function 
sys.generate_series(first date, \"limit\" date, stepsize interval day)\n"
+   "returns table (value date)\n"
+   "external name 
generator.series;\n"
+   "update sys.functions set 
system = true where system <> true and name = 'generate_series' and schema_id = 
2000;\n";
+   sql->session->status = 0;
+   sql->errstr[0] = '\0';
+   printf("Running database upgrade 
commands:\n%s\n", query);
+   fflush(stdout);
+   err = SQLstatementIntern(c, query, 
"update", true, false, NULL);
+   }
+   }
}
BBPunfix(b->batCacheid);
}
res_table_destroy(output);
-   list *l;
-   if ((l = sa_list(sql->sa)) != NULL) {
-   sql_subtype tp1, tp2;
-   sql_find_subtype(, "date", 0, 0);
-   list_append(l, );
-   list_append(l, );
-   sql_find_subtype(, "day_interval", 0, 0);
-   list_append(l, );
-   if (!sql_bind_func_(sql, s->base.name, "generate_series", l, 
F_UNION, true, true)) {
-   const char query[] = "create function 
sys.generate_series(first date, \"limit\" date, stepsize interval month)\n"
-   "returns table (value date)\n"
-   "external name generator.series;\n"
-   "create function sys.generate_series(first 
date, \"limit\" date, stepsize interval day)\n"
-   "returns table (value date)\n"
-   "external name generator.series;\n"
-   "update sys.functions set system = true where 
system <> true and name = 'generate_series' and schema_id = 2000;\n";
-   sql->session->status = 0;
-   sql->errstr[0] = '\0';
-   printf("Running database upgrade commands:\n%s\n", 
query);
-   fflush(stdout);
-   err = SQLstatementIntern(c, query, "update", true, 
false, NULL);
-   }
-   }
-   if (err)
-   goto end;
-
-   const char *query = "select id from args where func_id = (select id 
from functions where schema_id = 2000 and name = 'sessions');\n";
-   err = SQLstatementIntern(c, query, "update", true, 

MonetDB: default - remove white space

2024-05-30 Thread Yunus Koning via checkin-list
Changeset: 5c1fa247355f for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/5c1fa247355f
Modified Files:
sql/server/rel_schema.c
sql/storage/store.c
Branch: default
Log Message:

remove white space


diffs (24 lines):

diff --git a/sql/server/rel_schema.c b/sql/server/rel_schema.c
--- a/sql/server/rel_schema.c
+++ b/sql/server/rel_schema.c
@@ -390,7 +390,7 @@ sql_rel* create_check_plan(sql_query *qu
exp_kind ek = {type_value, card_value, FALSE};
sql_rel* rel = rel_basetable(sql, t, t->base.name);
sql_exp *e = rel_logical_value_exp(query, , s->data.sym, sql_sel | 
sql_no_subquery, ek);
-   rel->exps = rel_base_projection(sql, rel, 0);   
+   rel->exps = rel_base_projection(sql, rel, 0);
list *pexps = sa_list(sql->sa);
pexps = append(pexps, e);
rel = rel_project(sql->sa, rel, pexps);
diff --git a/sql/storage/store.c b/sql/storage/store.c
--- a/sql/storage/store.c
+++ b/sql/storage/store.c
@@ -3037,7 +3037,7 @@ key_dup(sql_trans *tr, sql_key *k, sql_t
 
if (nk->type == pkey)
t->pkey = tk;
-   
+
if (nk->type == ckey)
nk->check = _STRDUP(k->check);
} else {
___
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org


MonetDB: default - merge with check

2024-05-30 Thread Yunus Koning via checkin-list
Changeset: 9db08f0c28ec for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/9db08f0c28ec
Branch: default
Log Message:

merge with check


diffs (truncated from 1717 to 300 lines):

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
@@ -16,6 +16,7 @@
 #include "rel_rel.h"
 #include "rel_basetable.h"
 #include "rel_exp.h"
+#include "rel_dump.h"
 #include "rel_psm.h"
 #include "rel_prop.h"
 #include "rel_select.h"
@@ -4988,6 +4989,35 @@ sql_insert_triggers(backend *be, sql_tab
return res;
 }
 
+static void
+sql_insert_check(backend *be, sql_key *key, sql_rel *inserts, list *refs)
+{
+   mvc *sql = be->mvc;
+   node *m, *n;
+
+   inserts = rel_copy(sql, inserts, 1);
+   list* exps = inserts->exps;
+
+   for (n = ol_first_node(key->t->columns), m = exps->h; n && m;
+   n = n->next, m = m->next) {
+   sql_exp *i = m->data;
+   sql_column *c = n->data;
+   i->alias.rname= sa_strdup(sql->sa, c->t->base.name);
+   i->alias.name= sa_strdup(sql->sa, c->base.name);
+   }
+
+   int pos = 0;
+   sql_rel* rel = rel_read(sql, sa_strdup(sql->sa, key->check), , 
sa_list(sql->sa));
+   rel->l = inserts;
+   stmt* s = subrel_bin(be, rel, refs);
+   sql_subtype *bt = sql_bind_localtype("bit");
+   s = stmt_uselect(be, column(be, s), stmt_atom(be, 
atom_zero_value(sql->sa, bt)), cmp_equal, NULL, 0, 1);
+   sql_subfunc *cnt = sql_bind_func(sql, "sys", "count", 
sql_bind_localtype("void"), NULL, F_AGGR, true, true);
+   s = stmt_aggr(be, s, NULL, NULL, cnt, 1, 0, 1);
+   char *msg = sa_message(sql->sa, SQLSTATE(40002) "INSERT INTO: CHECK 
constraint violated: %s", key->base.name);
+   (void)stmt_exception(be, s, msg, 1);
+}
+
 static sql_table *
 sql_insert_check_null(backend *be, sql_table *t, list *inserts)
 {
@@ -5066,6 +5096,12 @@ rel2bin_insert(backend *be, sql_rel *rel
if (idx_ins)
pin = refs_find_rel(refs, prel);
 
+   for (n = ol_first_node(t->keys); n; n = n->next) {
+   sql_key * key = n->data;
+   if (key->type == ckey)
+   sql_insert_check(be, key, rel->r, refs);
+   }
+
if (!sql_insert_check_null(be, t, inserts->op4.lval))
return NULL;
 
@@ -5948,6 +5984,61 @@ sql_update_triggers(backend *be, sql_tab
 }
 
 static void
+sql_update_check(backend *be, sql_key * key, sql_rel *updates, list *refs)
+{
+   mvc *sql = be->mvc;
+   int pos = 0;
+
+
+   stack_push_frame(be->mvc, "ALTER TABLE ADD CONSTRAINT CHECK");
+   sql_schema* ss = key->t->s;
+   frame_push_table(sql, key->t);
+   key->t->s = ss; // recover the schema because frame_push_table removes 
it
+
+   sql_rel* rel = rel_read(sql, sa_strdup(sql->sa, key->check), , 
sa_list(sql->sa));
+   stack_pop_frame(sql);
+
+   if (!key->base.new) {
+   sql_rel* base = rel->l;
+   assert(strcmp(((sql_exp*) updates->exps->h->data)->alias.name, 
TID) == 0);
+   list_append(base->exps, exp_copy(sql, updates->exps->h->data));
+
+   bool need_join = 0;
+   list* pexps = sa_list(sql->sa);
+   sql_exp* tid_exp = exp_copy(sql, updates->exps->h->data);
+   unsigned label = ++sql->label;
+   exp_setrelname(sql->sa, tid_exp, label);
+   list_append(pexps, tid_exp);
+   for (node* m = base->exps->h; m; m = m->next) {
+   if (exps_find_exp( updates->exps, m->data) == NULL) {
+   pexps = list_append(pexps, exp_copy(sql, 
m->data));
+   need_join = 1;
+   }
+   }
+
+   if (need_join) {
+   base = rel_project(sql->sa, base, pexps);
+   sql_rel* join = rel_crossproduct(sql->sa, base, 
updates, op_join);
+   sql_exp* join_cond = exp_compare(sql->sa, exp_ref(sql, 
base->exps->h->data), exp_ref(sql, updates->exps->h->data), cmp_equal);
+   join->exps = sa_list(sql->sa);
+   join->exps = list_append(join->exps, join_cond);
+   rel->l = join;
+   }
+   else {
+   rel->l = updates;
+   }
+   }
+
+   sql_subfunc *cnt = sql_bind_func(sql, "sys", "count", 
sql_bind_localtype("void"), NULL, F_AGGR, true, true);
+   sql_subtype *bt = sql_bind_localtype("bit");
+   stmt* s = subrel_bin(be, rel, refs);
+   s = stmt_uselect(be, column(be, s), stmt_atom(be, 
atom_zero_value(sql->sa, bt)), cmp_equal, NULL, 0, 1);
+   s = stmt_aggr(be, s, NULL, NULL, cnt, 1, 0, 1);
+   char *msg = sa_message(sql->sa, SQLSTATE(40002) "UPDATE: CHECK 
constraint violated: %s", key->base.name);
+   (void)stmt_exception(be, s, 

MonetDB: check - implement '!=' COMPARISON token

2024-05-30 Thread Yunus Koning via checkin-list
Changeset: 34974cde3236 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/34974cde3236
Modified Files:
sql/server/sql_scan.c
sql/test/sys-schema/Tests/webExamplesComparisonFunctionsOperators.test
Branch: check
Log Message:

implement '!=' COMPARISON token


diffs (39 lines):

diff --git a/sql/server/sql_scan.c b/sql/server/sql_scan.c
--- a/sql/server/sql_scan.c
+++ b/sql/server/sql_scan.c
@@ -1247,6 +1247,20 @@ int scanner_symbol(mvc * c, int cur)
case ';':
lc->started = 0;
return scanner_token(lc, SCOLON);
+   case '!':
+   lc->started = 1;
+   cur = scanner_getc(lc);
+   if (cur < 0)
+   return EOF;
+   else if (cur == '=') {
+   lc->rs->buf[lc->rs->pos + lc->yycur - 2] = '<';
+   lc->rs->buf[lc->rs->pos + lc->yycur - 1] = '>';
+   return scanner_token( lc, COMPARISON);
+   }
+   else
+   lc->yycur--;
+   cur = '!';
+   break;
case '<':
lc->started = 1;
cur = scanner_getc(lc);
diff --git 
a/sql/test/sys-schema/Tests/webExamplesComparisonFunctionsOperators.test 
b/sql/test/sys-schema/Tests/webExamplesComparisonFunctionsOperators.test
--- a/sql/test/sys-schema/Tests/webExamplesComparisonFunctionsOperators.test
+++ b/sql/test/sys-schema/Tests/webExamplesComparisonFunctionsOperators.test
@@ -56,8 +56,10 @@ select 2 = 5 as f1, 2 <> 5 as t1
 0
 1
 
-statement error
+query I rowsort
 select 2 != 5 as t1
+
+1
 
 query I rowsort
 select "<"('aa', 'ab') as tru
___
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org


MonetDB: default - Fixes #7522

2024-05-28 Thread Yunus Koning via checkin-list
Changeset: e9925b686b29 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/e9925b686b29
Modified Files:
sql/server/rel_select.c
Branch: default
Log Message:

Fixes #7522


diffs (12 lines):

diff --git a/sql/server/rel_select.c b/sql/server/rel_select.c
--- a/sql/server/rel_select.c
+++ b/sql/server/rel_select.c
@@ -1303,7 +1303,7 @@ bool group_by_pk_project_uk_cond(mvc* sq
continue;
}
}
-   if (pki && pki->columns->cnt == 1 &&  ((list*) inner->r)->cnt 
== 1) {
+   if (pki && pki->columns->cnt == 1 && inner->r && ((list*) 
inner->r)->cnt == 1) {
/* for now only check simple case where primary key and 
group by expression is a single column*/
sql_exp* gbe = ((list*) inner->r)->h->data;
assert(gbe->type == e_column);
___
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org


MonetDB: default - fix and test bug #7521

2024-05-28 Thread Yunus Koning via checkin-list
Changeset: 3a51d8edf6af for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/3a51d8edf6af
Modified Files:
sql/server/rel_select.c
sql/test/2024/Tests/distinct_from.test
Branch: default
Log Message:

fix and test bug #7521


diffs (54 lines):

diff --git a/sql/server/rel_select.c b/sql/server/rel_select.c
--- a/sql/server/rel_select.c
+++ b/sql/server/rel_select.c
@@ -2318,9 +2318,24 @@ negate_symbol_tree(mvc *sql, symbol *sc)
case SQL_COMPARE: {
dnode *cmp_n = sc->data.lval->h;
comp_type neg_cmp_type = 
negate_compare(compare_str2type(cmp_n->next->data.sval)); /* negate the 
comparator */
+   if (cmp_n->next->next->next) {
+   switch(cmp_n->next->next->next->data.i_val)
+   {
+   case 0: /* negating ANY/ALL */
+   cmp_n->next->next->next->data.i_val = 1;
+   break;
+   case 1: /* negating ANY/ALL */
+   cmp_n->next->next->next->data.i_val = 0;
+   break;
+   case 2: /* negating IS [NOY] DINSTINCT FROM */
+   cmp_n->next->next->next->data.i_val = 3;
+   break;
+   case 3: /* negating IS [NOY] DINSTINCT FROM */
+   cmp_n->next->next->next->data.i_val = 2;
+   break;
+   }
+   }
cmp_n->next->data.sval = sa_strdup(sql->sa, 
compare_func(neg_cmp_type, 0));
-   if (cmp_n->next->next->next) /* negating ANY/ALL */
-   cmp_n->next->next->next->data.i_val = 
cmp_n->next->next->next->data.i_val == 0 ? 1 : 0;
} break;
case SQL_AND:
case SQL_OR: {
diff --git a/sql/test/2024/Tests/distinct_from.test 
b/sql/test/2024/Tests/distinct_from.test
--- a/sql/test/2024/Tests/distinct_from.test
+++ b/sql/test/2024/Tests/distinct_from.test
@@ -34,10 +34,20 @@ SELECT NULL IS DISTINCT FROM NULL
 0
 
 query I nosort
+SELECT NOT (NULL IS DISTINCT FROM NULL)
+
+1
+
+query I nosort
 SELECT NULL IS NOT DISTINCT FROM NULL
 
 1
 
+query I nosort
+SELECT NOT (NULL IS NOT DISTINCT FROM NULL)
+
+0
+
 statement ok
 create table foo(s) as values (10), (20), (NULL)
 
___
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org


MonetDB: check - fix upgrade record

2024-05-28 Thread Yunus Koning via checkin-list
Changeset: 73731f1bd24f for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/73731f1bd24f
Modified Files:
sql/storage/bat/bat_logger.c
Branch: check
Log Message:

fix upgrade record


diffs (38 lines):

diff --git a/sql/storage/bat/bat_logger.c b/sql/storage/bat/bat_logger.c
--- a/sql/storage/bat/bat_logger.c
+++ b/sql/storage/bat/bat_logger.c
@@ -3304,20 +3304,20 @@ bl_postversion(void *Store, void *Lg)
return GDK_FAIL;
tabins_first = false;
if (tabins(lg, old_lg, tabins_first, -1, 0,
-   2076, &(msk) {false},   /* sys._columns 
*/
-   /* 2166 is tmp.keys.check */
-   2077, &(int) {2166},/* 
sys._columns.id */
-   2078, "sub",
/* sys._columns.name */
-   2079, "int",
/* sys._columns.type */
-   2080, &(int) {32},  /* 
sys._columns.type_digits */
-   2081, &(int) {0},   /* 
sys._columns.type_scale */
-   /* 2135 is tmp.keys */
-   2082, &(int) {2135},/* 
sys._columns.table_id */
-   2083, str_nil,  /* 
sys._columns.default */
-   2084, &(bit) {TRUE},/* 
sys._columns.null */
-   2085, &(int) {3},   /* 
sys._columns.number */
-   2086, str_nil,  /* 
sys._columns.storage */
-  0) != GDK_SUCCEED)
+  2076, &(msk) {false},/* 
sys._columns */
+  /* 2165 is tmp.keys.check */
+  2077, &(int) {2166}, /* 
sys._columns.id */
+  2078, "check",   
/* sys._columns.name */
+  2079, "varchar", 
/* sys._columns.type */
+  2080, &(int) {2048}, /* 
sys._columns.type_digits */
+  2081, &(int) {0},/* 
sys._columns.type_scale */
+  /* 2135 is tmp.keys */
+  2082, &(int) {2135}, /* 
sys._columns.table_id */
+  2083, str_nil,   
/* sys._columns.default */
+  2084, &(bit) {TRUE}, /* 
sys._columns.null */
+  2085, &(int) {6},/* 
sys._columns.number */
+  2086, str_nil,   
/* sys._columns.storage */
+  0) != GDK_SUCCEED)
return GDK_FAIL;
}
 #endif
___
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org


MonetDB: check - missing/wrong column record

2024-05-28 Thread Yunus Koning via checkin-list
Changeset: 3e1e1f22c6b4 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/3e1e1f22c6b4
Modified Files:
sql/storage/bat/bat_logger.c
Branch: check
Log Message:

missing/wrong column record


diffs (37 lines):

diff --git a/sql/storage/bat/bat_logger.c b/sql/storage/bat/bat_logger.c
--- a/sql/storage/bat/bat_logger.c
+++ b/sql/storage/bat/bat_logger.c
@@ -3294,8 +3294,8 @@ bl_postversion(void *Store, void *Lg)
   2079, "varchar", 
/* sys._columns.type */
   2080, &(int) {2048}, /* 
sys._columns.type_digits */
   2081, &(int) {0},/* 
sys._columns.type_scale */
-  /* 2016 is sys.functions */
-  2082, &(int) {2016}, /* 
sys._columns.table_id */
+  /* 2087 is sys.keys */
+  2082, &(int) {2087}, /* 
sys._columns.table_id */
   2083, str_nil,   
/* sys._columns.default */
   2084, &(bit) {TRUE}, /* 
sys._columns.null */
   2085, &(int) {6},/* 
sys._columns.number */
@@ -3303,6 +3303,22 @@ bl_postversion(void *Store, void *Lg)
   0) != GDK_SUCCEED)
return GDK_FAIL;
tabins_first = false;
+   if (tabins(lg, old_lg, tabins_first, -1, 0,
+   2076, &(msk) {false},   /* sys._columns 
*/
+   /* 2166 is tmp.keys.check */
+   2077, &(int) {2166},/* 
sys._columns.id */
+   2078, "sub",
/* sys._columns.name */
+   2079, "int",
/* sys._columns.type */
+   2080, &(int) {32},  /* 
sys._columns.type_digits */
+   2081, &(int) {0},   /* 
sys._columns.type_scale */
+   /* 2135 is tmp.keys */
+   2082, &(int) {2135},/* 
sys._columns.table_id */
+   2083, str_nil,  /* 
sys._columns.default */
+   2084, &(bit) {TRUE},/* 
sys._columns.null */
+   2085, &(int) {3},   /* 
sys._columns.number */
+   2086, str_nil,  /* 
sys._columns.storage */
+  0) != GDK_SUCCEED)
+   return GDK_FAIL;
}
 #endif
 
___
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org


MonetDB: check - missing internal store administration for check...

2024-05-28 Thread Yunus Koning via checkin-list
Changeset: d7f5e38b6ed7 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/d7f5e38b6ed7
Modified Files:
sql/storage/bat/bat_logger.c
Branch: check
Log Message:

missing internal store administration for check column


diffs (31 lines):

diff --git a/sql/storage/bat/bat_logger.c b/sql/storage/bat/bat_logger.c
--- a/sql/storage/bat/bat_logger.c
+++ b/sql/storage/bat/bat_logger.c
@@ -902,6 +902,13 @@ const struct table {
},
{
.schema = "sys",
+   .table = "keys",
+   .column = "check",
+   .fullname = "sys_keys_check",
+   .newid = 2165,
+   },
+   {
+   .schema = "sys",
.table = "idxs",
.fullname = "D_sys_idxs",
.newid = 2094,
@@ -1240,6 +1247,13 @@ const struct table {
},
{
.schema = "tmp",
+   .table = "keys",
+   .column = "check",
+   .fullname = "tmp_keys_action",
+   .newid = 2166,
+   },
+   {
+   .schema = "tmp",
.table = "idxs",
.fullname = "D_tmp_idxs",
.newid = 2142,
___
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org


MonetDB: check - approve test output

2024-05-28 Thread Yunus Koning via checkin-list
Changeset: 10ea7d33c679 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/10ea7d33c679
Modified Files:
sql/test/emptydb/Tests/check.stable.out
sql/test/emptydb/Tests/check.stable.out.32bit
sql/test/emptydb/Tests/check.stable.out.int128
Branch: check
Log Message:

approve test output


diffs (33 lines):

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
@@ -1359,6 +1359,7 @@ select 'null in fkeys.delete_action', de
 [ "sys._columns",  "sys",  "keys", "name", "varchar",  1024,   0,  
NULL,   true,   3,  NULL,   NULL]
 [ "sys._columns",  "sys",  "keys", "rkey", "int",  31, 0,  NULL,   
true,   4,  NULL,   NULL]
 [ "sys._columns",  "sys",  "keys", "action",   "int",  31, 0,  
NULL,   true,   5,  NULL,   NULL]
+[ "sys._columns",  "sys",  "keys", "check","varchar",  2048,   
0,  NULL,   true,   6,  NULL,   NULL]
 [ "sys._columns",  "sys",  "keywords", "keyword",  "varchar",  
40, 0,  NULL,   false,  0,  NULL,   NULL]
 [ "sys._columns",  "sys",  "malfunctions", "module",   "varchar",  
0,  0,  NULL,   true,   0,  NULL,   NULL]
 [ "sys._columns",  "sys",  "malfunctions", "function", "varchar",  
0,  0,  NULL,   true,   1,  NULL,   NULL]
diff --git a/sql/test/emptydb/Tests/check.stable.out.32bit 
b/sql/test/emptydb/Tests/check.stable.out.32bit
--- a/sql/test/emptydb/Tests/check.stable.out.32bit
+++ b/sql/test/emptydb/Tests/check.stable.out.32bit
@@ -1359,6 +1359,7 @@ select 'null in fkeys.delete_action', de
 [ "sys._columns",  "sys",  "keys", "name", "varchar",  1024,   0,  
NULL,   true,   3,  NULL,   NULL]
 [ "sys._columns",  "sys",  "keys", "rkey", "int",  31, 0,  NULL,   
true,   4,  NULL,   NULL]
 [ "sys._columns",  "sys",  "keys", "action",   "int",  31, 0,  
NULL,   true,   5,  NULL,   NULL]
+[ "sys._columns",  "sys",  "keys", "check","varchar",  2048,   
0,  NULL,   true,   6,  NULL,   NULL]
 [ "sys._columns",  "sys",  "keywords", "keyword",  "varchar",  
40, 0,  NULL,   false,  0,  NULL,   NULL]
 [ "sys._columns",  "sys",  "malfunctions", "module",   "varchar",  
0,  0,  NULL,   true,   0,  NULL,   NULL]
 [ "sys._columns",  "sys",  "malfunctions", "function", "varchar",  
0,  0,  NULL,   true,   1,  NULL,   NULL]
diff --git a/sql/test/emptydb/Tests/check.stable.out.int128 
b/sql/test/emptydb/Tests/check.stable.out.int128
--- a/sql/test/emptydb/Tests/check.stable.out.int128
+++ b/sql/test/emptydb/Tests/check.stable.out.int128
@@ -1359,6 +1359,7 @@ select 'null in fkeys.delete_action', de
 [ "sys._columns",  "sys",  "keys", "name", "varchar",  1024,   0,  
NULL,   true,   3,  NULL,   NULL]
 [ "sys._columns",  "sys",  "keys", "rkey", "int",  31, 0,  NULL,   
true,   4,  NULL,   NULL]
 [ "sys._columns",  "sys",  "keys", "action",   "int",  31, 0,  
NULL,   true,   5,  NULL,   NULL]
+[ "sys._columns",  "sys",  "keys", "check","varchar",  2048,   
0,  NULL,   true,   6,  NULL,   NULL]
 [ "sys._columns",  "sys",  "keywords", "keyword",  "varchar",  
40, 0,  NULL,   false,  0,  NULL,   NULL]
 [ "sys._columns",  "sys",  "malfunctions", "module",   "varchar",  
0,  0,  NULL,   true,   0,  NULL,   NULL]
 [ "sys._columns",  "sys",  "malfunctions", "function", "varchar",  
0,  0,  NULL,   true,   1,  NULL,   NULL]
___
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org


MonetDB: check - fix memory leak

2024-05-28 Thread Yunus Koning via checkin-list
Changeset: 5f415056d946 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/5f415056d946
Modified Files:
sql/storage/store.c
Branch: check
Log Message:

fix memory leak


diffs (11 lines):

diff --git a/sql/storage/store.c b/sql/storage/store.c
--- a/sql/storage/store.c
+++ b/sql/storage/store.c
@@ -160,6 +160,7 @@ key_destroy(sqlstore *store, sql_key *k)
if (ATOMIC_DEC(>base.refcnt) > 0)
return;
list_destroy2(k->columns, store);
+   _DELETE(k->check);
k->columns = NULL;
_DELETE(k->base.name);
_DELETE(k);
___
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org


MonetDB: check - approve new upgrade test output

2024-05-27 Thread Yunus Koning via checkin-list
Changeset: 03c22628f0d1 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/03c22628f0d1
Modified Files:
sql/test/emptydb/Tests/check.stable.out
sql/test/emptydb/Tests/check.stable.out.32bit
sql/test/emptydb/Tests/check.stable.out.int128
Branch: check
Log Message:

approve new upgrade test output


diffs (96 lines):

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
@@ -1352,7 +1352,7 @@ select 'null in fkeys.delete_action', de
 [ "sys._columns",  "sys",  "index_types",  "index_type_id",
"smallint", 15, 0,  NULL,   false,  0,  NULL,   NULL]
 [ "sys._columns",  "sys",  "index_types",  "index_type_name",  
"varchar",  25, 0,  NULL,   false,  1,  NULL,   NULL]
 [ "sys._columns",  "sys",  "key_types","key_type_id",  "smallint", 
15, 0,  NULL,   false,  0,  NULL,   NULL]
-[ "sys._columns",  "sys",  "key_types","key_type_name",
"varchar",  15, 0,  NULL,   false,  1,  NULL,   NULL]
+[ "sys._columns",  "sys",  "key_types","key_type_name",
"varchar",  35, 0,  NULL,   false,  1,  NULL,   NULL]
 [ "sys._columns",  "sys",  "keys", "id",   "int",  31, 0,  NULL,   
true,   0,  NULL,   NULL]
 [ "sys._columns",  "sys",  "keys", "table_id", "int",  31, 0,  
NULL,   true,   1,  NULL,   NULL]
 [ "sys._columns",  "sys",  "keys", "type", "int",  31, 0,  NULL,   
true,   2,  NULL,   NULL]
@@ -1660,6 +1660,7 @@ select 'null in fkeys.delete_action', de
 [ "sys._columns",  "tmp",  "keys", "name", "varchar",  1024,   0,  
NULL,   true,   3,  NULL,   NULL]
 [ "sys._columns",  "tmp",  "keys", "rkey", "int",  31, 0,  NULL,   
true,   4,  NULL,   NULL]
 [ "sys._columns",  "tmp",  "keys", "action",   "int",  31, 0,  
NULL,   true,   5,  NULL,   NULL]
+[ "sys._columns",  "tmp",  "keys", "check","varchar",  2048,   
0,  NULL,   true,   6,  NULL,   NULL]
 [ "sys._columns",  "tmp",  "objects",  "id",   "int",  31, 0,  
NULL,   true,   0,  NULL,   NULL]
 [ "sys._columns",  "tmp",  "objects",  "name", "varchar",  1024,   
0,  NULL,   true,   1,  NULL,   NULL]
 [ "sys._columns",  "tmp",  "objects",  "nr",   "int",  31, 0,  
NULL,   true,   2,  NULL,   NULL]
@@ -5444,9 +5445,11 @@ select 'null in fkeys.delete_action', de
 % %1,  key_type_name # name
 % varchar, varchar # type
 % 13,  11 # length
+[ "sys.key_types", "Check Constraint"  ]
 [ "sys.key_types", "Foreign Key"   ]
 [ "sys.key_types", "Primary Key"   ]
 [ "sys.key_types", "Unique Key"]
+[ "sys.key_types", "Unique Key With Nulls Not Distinct"]
 % .%1, .index_types # table_name
 % %1,  index_type_name # name
 % varchar, varchar # type
diff --git a/sql/test/emptydb/Tests/check.stable.out.32bit 
b/sql/test/emptydb/Tests/check.stable.out.32bit
--- a/sql/test/emptydb/Tests/check.stable.out.32bit
+++ b/sql/test/emptydb/Tests/check.stable.out.32bit
@@ -1352,7 +1352,7 @@ select 'null in fkeys.delete_action', de
 [ "sys._columns",  "sys",  "index_types",  "index_type_id",
"smallint", 15, 0,  NULL,   false,  0,  NULL,   NULL]
 [ "sys._columns",  "sys",  "index_types",  "index_type_name",  
"varchar",  25, 0,  NULL,   false,  1,  NULL,   NULL]
 [ "sys._columns",  "sys",  "key_types","key_type_id",  "smallint", 
15, 0,  NULL,   false,  0,  NULL,   NULL]
-[ "sys._columns",  "sys",  "key_types","key_type_name",
"varchar",  15, 0,  NULL,   false,  1,  NULL,   NULL]
+[ "sys._columns",  "sys",  "key_types","key_type_name",
"varchar",  35, 0,  NULL,   false,  1,  NULL,   NULL]
 [ "sys._columns",  "sys",  "keys", "id",   "int",  31, 0,  NULL,   
true,   0,  NULL,   NULL]
 [ "sys._columns",  "sys",  "keys", "table_id", "int",  31, 0,  
NULL,   true,   1,  NULL,   NULL]
 [ "sys._columns",  "sys",  "keys", "type", "int",  31, 0,  NULL,   
true,   2,  NULL,   NULL]
@@ -1660,6 +1660,7 @@ select 'null in fkeys.delete_action', de
 [ "sys._columns",  "tmp",  "keys", "name", "varchar",  1024,   0,  
NULL,   true,   3,  NULL,   NULL]
 [ "sys._columns",  "tmp",  "keys", "rkey", "int",  31, 0,  NULL,   
true,   4,  NULL,   NULL]
 [ "sys._columns",  "tmp",  "keys", "action",   "int",  31, 0,  
NULL,   true,   5,  NULL,   NULL]
+[ "sys._columns",  "tmp",  "keys", "check","varchar",  2048,   
0,  NULL,   true,   6,  NULL,   NULL   

MonetDB: check - add upgrade code for additional key types

2024-05-27 Thread Yunus Koning via checkin-list
Changeset: 102f4929b4fd for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/102f4929b4fd
Modified Files:
sql/backends/monet5/sql_upgrades.c
Branch: check
Log Message:

add upgrade code for additional key types


diffs (31 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
@@ -7096,6 +7096,27 @@ sql_update_default(Client c, mvc *sql, s
sa_destroy(sql->sa);
}
sql->sa = old_sa;
+
+   if (err)
+   return err;
+   sql_table *t;
+   if ((t = mvc_bind_table(sql, s, "key_types")) != NULL)
+   t->system = 0;
+   err = SQLstatementIntern(c,
+   "DROP TABLE sys.key_types;\n"
+   "CREATE TABLE sys.key_types (\n"
+   "   key_type_id   SMALLINT NOT NULL PRIMARY KEY,\n"
+   "   key_type_name VARCHAR(35) NOT NULL UNIQUE);\n"
+   "INSERT INTO sys.key_types VALUES\n"
+   "(0, 'Primary Key'),\n"
+   "(1, 'Unique Key'),\n"
+   "(2, 'Foreign Key'),\n"
+   "(3, 'Unique Key With Nulls Not Distinct'),\n"
+   "(4, 'Check Constraint');\n"
+   "ALTER TABLE sys.key_types SET READ ONLY;\n"
+   "GRANT SELECT ON sys.key_types TO PUBLIC;\n"
+   "UPDATE sys._tables SET system = true WHERE schema_id = 2000 
AND name = 'key_types';\n"
+   , "update", true, false, NULL);
return err;
 }
 
___
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org


MonetDB: check - clean up memory management

2024-05-27 Thread Yunus Koning via checkin-list
Changeset: 5291548294ef for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/5291548294ef
Modified Files:
sql/backends/monet5/sql_gencode.c
sql/server/rel_dump.c
Branch: check
Log Message:

clean up memory management


diffs (53 lines):

diff --git a/sql/backends/monet5/sql_gencode.c 
b/sql/backends/monet5/sql_gencode.c
--- a/sql/backends/monet5/sql_gencode.c
+++ b/sql/backends/monet5/sql_gencode.c
@@ -330,7 +330,7 @@ static int
node *n;
int i, q, v, res = -1, added_to_cache = 0, *lret, *rret;
size_t len = 1024, nr, pwlen = 0;
-   char *lname = NULL, *buf = NULL, *mal_session_uuid, *err = NULL, 
*pwhash = NULL;
+   char *lname = NULL, *rel_str, *buf = NULL, *mal_session_uuid, *err = 
NULL, *pwhash = NULL;
str username = NULL, password = NULL, msg = NULL;
sql_rel *r = rel;
 
@@ -487,23 +487,21 @@ static int
pushInstruction(curBlk, o);
p = pushArgument(curBlk, p, getArg(o,0));
 
-   if (!(buf = rel2str(m, rel))) {
+   if (!(rel_str = rel2str(m, rel))) {
freeInstruction(p);
sql_error(m, 10, SQLSTATE(HY013) MAL_MALLOC_FAIL);
goto cleanup;
}
o = newFcnCall(curBlk, remoteRef, putRef);
if (o == NULL) {
-   free(buf);
freeInstruction(p);
sql_error(m, 10, SQLSTATE(HY013) MAL_MALLOC_FAIL);
goto cleanup;
}
o = pushArgument(curBlk, o, q);
-   o = pushStr(curBlk, o, buf);/* relational plan */
+   o = pushStr(curBlk, o, rel_str);/* relational plan */
pushInstruction(curBlk, o);
p = pushArgument(curBlk, p, getArg(o,0));
-   free(buf);
 
if (!(buf = sa_alloc(m->ta, len))) {
freeInstruction(p);
diff --git a/sql/server/rel_dump.c b/sql/server/rel_dump.c
--- a/sql/server/rel_dump.c
+++ b/sql/server/rel_dump.c
@@ -377,7 +377,10 @@ cleanup:
buffer_destroy(b);
if(s)
close_stream(s);
-   return res;
+
+   char* fres = SA_STRDUP(sql->sa, res);
+   free (res);
+   return fres;
 }
 
 static void
___
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org


MonetDB: check - get rid of duplicate definition

2024-05-27 Thread Yunus Koning via checkin-list
Changeset: 1b16c69fc345 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/1b16c69fc345
Modified Files:
sql/backends/monet5/sql_gencode.c
sql/server/rel_dump.c
sql/server/rel_dump.h
sql/server/rel_schema.c
Branch: check
Log Message:

get rid of duplicate definition


diffs (133 lines):

diff --git a/sql/backends/monet5/sql_gencode.c 
b/sql/backends/monet5/sql_gencode.c
--- a/sql/backends/monet5/sql_gencode.c
+++ b/sql/backends/monet5/sql_gencode.c
@@ -316,36 +316,6 @@ static int
return -1;
 }
 
-static str
-rel2str( mvc *sql, sql_rel *rel)
-{
-   buffer *b = NULL;
-   stream *s = NULL;
-   list *refs = NULL;
-   char *res = NULL;
-
-   b = buffer_create(1024);
-   if(b == NULL)
-   goto cleanup;
-   s = buffer_wastream(b, "rel_dump");
-   if(s == NULL)
-   goto cleanup;
-   refs = sa_list(sql->sa);
-   if (!refs)
-   goto cleanup;
-
-   rel_print_refs(sql, s, rel, 0, refs, 0);
-   rel_print_(sql, s, rel, 0, refs, 0);
-   mnstr_printf(s, "\n");
-   res = buffer_get_buf(b);
-
-cleanup:
-   if(b)
-   buffer_destroy(b);
-   if(s)
-   close_stream(s);
-   return res;
-}
 
 /* stub and remote function */
 static int
diff --git a/sql/server/rel_dump.c b/sql/server/rel_dump.c
--- a/sql/server/rel_dump.c
+++ b/sql/server/rel_dump.c
@@ -348,6 +348,38 @@ exp_print(mvc *sql, stream *fout, sql_ex
mnstr_printf(fout, ", ");
 }
 
+
+str
+rel2str( mvc *sql, sql_rel *rel)
+{
+   buffer *b = NULL;
+   stream *s = NULL;
+   list *refs = NULL;
+   char *res = NULL;
+
+   b = buffer_create(1024);
+   if(b == NULL)
+   goto cleanup;
+   s = buffer_wastream(b, "rel_dump");
+   if(s == NULL)
+   goto cleanup;
+   refs = sa_list(sql->sa);
+   if (!refs)
+   goto cleanup;
+
+   rel_print_refs(sql, s, rel, 0, refs, 0);
+   rel_print_(sql, s, rel, 0, refs, 0);
+   mnstr_printf(s, "\n");
+   res = buffer_get_buf(b);
+
+cleanup:
+   if(b)
+   buffer_destroy(b);
+   if(s)
+   close_stream(s);
+   return res;
+}
+
 static void
 exps_print(mvc *sql, stream *fout, list *exps, int depth, list *refs, int 
alias, int brackets, int decorate)
 {
diff --git a/sql/server/rel_dump.h b/sql/server/rel_dump.h
--- a/sql/server/rel_dump.h
+++ b/sql/server/rel_dump.h
@@ -19,6 +19,7 @@
 extern void rel_print_(mvc *sql, stream  *fout, sql_rel *rel, int depth, list 
*refs, int decorate);
 extern void rel_print_refs(mvc *sql, stream* fout, sql_rel *rel, int depth, 
list *refs, int decorate);
 
+extern str rel2str( mvc *sql, sql_rel *rel);
 extern sql_rel *rel_read(mvc *sql, char *ra, int *pos, list *refs);
 extern void exp_print(mvc *sql, stream *fout, sql_exp *e, int depth, list 
*refs, int comma, int alias, int decorate);
 
diff --git a/sql/server/rel_schema.c b/sql/server/rel_schema.c
--- a/sql/server/rel_schema.c
+++ b/sql/server/rel_schema.c
@@ -370,36 +370,6 @@ foreign_key_check_types(sql_subtype *lt,
return lt->type->localtype == rt->type->localtype;
return lt->type->eclass == rt->type->eclass || 
(EC_VARCHAR(lt->type->eclass) && EC_VARCHAR(rt->type->eclass));
 }
-static str
-rel2str( mvc *sql, sql_rel *rel)
-{
-   buffer *b = NULL;
-   stream *s = NULL;
-   list *refs = NULL;
-   char *res = NULL;
-
-   b = buffer_create(1024);
-   if(b == NULL)
-   goto cleanup;
-   s = buffer_wastream(b, "rel_dump");
-   if(s == NULL)
-   goto cleanup;
-   refs = sa_list(sql->sa);
-   if (!refs)
-   goto cleanup;
-
-   rel_print_refs(sql, s, rel, 0, refs, 0);
-   rel_print_(sql, s, rel, 0, refs, 0);
-   mnstr_printf(s, "\n");
-   res = buffer_get_buf(b);
-
-cleanup:
-   if(b)
-   buffer_destroy(b);
-   if(s)
-   close_stream(s);
-   return res;
-}
 
 static
 key_type token2key_type(int token) {
___
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org


MonetDB: check - merge with default

2024-05-27 Thread Yunus Koning via checkin-list
Changeset: 9d1fac6dfbb4 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/9d1fac6dfbb4
Branch: check
Log Message:

merge with default


diffs (118 lines):

diff --git a/monetdb5/modules/atoms/str.c b/monetdb5/modules/atoms/str.c
--- a/monetdb5/modules/atoms/str.c
+++ b/monetdb5/modules/atoms/str.c
@@ -1910,60 +1910,62 @@ STRselect(MalStkPtr stk, InstrPtr pci,
throw(MAL, fname, SQLSTATE(HY013) MAL_MALLOC_FAIL);
}
 
-   BATiter bi = bat_iterator(b);
-   QryCtx *qry_ctx = MT_thread_get_qry_ctx();
-   if (icase)
-   str_cmp = str_icmp;
-   oid *vals = Tloc(bn, 0);
-   const int klen = str_strlen(key);
-   if (ci.tpe == cand_dense) {
-   if (with_strimps_anti)
-   scanloop(strNil(v) || str_cmp(v, key, klen) == 0, 
canditer_next_dense);
-   else if (anti)
-   scanloop(!strNil(v) && str_cmp(v, key, klen) != 0, 
canditer_next_dense);
-   else
-   scanloop(!strNil(v) && str_cmp(v, key, klen) == 0, 
canditer_next_dense);
-   } else {
-   if (with_strimps_anti)
-   scanloop(strNil(v) || str_cmp(v, key, klen) == 0, 
canditer_next);
-   else if (anti)
-   scanloop(!strNil(v) && str_cmp(v, key, klen) != 0, 
canditer_next);
-   else
-   scanloop(!strNil(v) && str_cmp(v, key, klen) == 0, 
canditer_next);
-   }
-   bat_iterator_end();
-   TIMEOUT_CHECK(qry_ctx, HANDLE_TIMEOUT(qry_ctx));
-
-   if (!msg) {
-   BATsetcount(bn, rcnt);
-   bn->tsorted = true;
-   bn->trevsorted = bn->batCount <= 1;
-   bn->tkey = true;
-   bn->tnil = false;
-   bn->tnonil = true;
-   bn->tseqbase = rcnt == 0 ?
-   0 : rcnt == 1 ?
-   *(const oid *) Tloc(bn, 0) : rcnt == ci.ncand && ci.tpe 
== cand_dense ? ci.hseq : oid_nil;
-
-   if (with_strimps_anti) {
-   BAT *rev;
-   if (old_s) {
-   rev = BATdiffcand(old_s, bn);
+   if (!strNil(key)) {
+   BATiter bi = bat_iterator(b);
+   QryCtx *qry_ctx = MT_thread_get_qry_ctx();
+   if (icase)
+   str_cmp = str_icmp;
+   oid *vals = Tloc(bn, 0);
+   const int klen = str_strlen(key);
+   if (ci.tpe == cand_dense) {
+   if (with_strimps_anti)
+   scanloop(strNil(v) || str_cmp(v, key, klen) == 
0, canditer_next_dense);
+   else if (anti)
+   scanloop(!strNil(v) && str_cmp(v, key, klen) != 
0, canditer_next_dense);
+   else
+   scanloop(!strNil(v) && str_cmp(v, key, klen) == 
0, canditer_next_dense);
+   } else {
+   if (with_strimps_anti)
+   scanloop(strNil(v) || str_cmp(v, key, klen) == 
0, canditer_next);
+   else if (anti)
+   scanloop(!strNil(v) && str_cmp(v, key, klen) != 
0, canditer_next);
+   else
+   scanloop(!strNil(v) && str_cmp(v, key, klen) == 
0, canditer_next);
+   }
+   bat_iterator_end();
+   TIMEOUT_CHECK(qry_ctx, HANDLE_TIMEOUT(qry_ctx));
+
+   if (!msg) {
+   BATsetcount(bn, rcnt);
+   bn->tsorted = true;
+   bn->trevsorted = bn->batCount <= 1;
+   bn->tkey = true;
+   bn->tnil = false;
+   bn->tnonil = true;
+   bn->tseqbase = rcnt == 0 ?
+   0 : rcnt == 1 ?
+   *(const oid *) Tloc(bn, 0) : rcnt == ci.ncand 
&& ci.tpe == cand_dense ? ci.hseq : oid_nil;
+
+   if (with_strimps_anti) {
+   BAT *rev;
+   if (old_s) {
+   rev = BATdiffcand(old_s, bn);
 #ifndef NDEBUG
-   BAT *is = BATintersectcand(old_s, bn);
-   if (is) {
-   assert(is->batCount == bn->batCount);
-   BBPreclaim(is);
-   }
-   assert(rev->batCount == old_s->batCount - 
bn->batCount);
+   BAT *is = BATintersectcand(old_s, bn);
+   if (is) {
+   assert(is->batCount == 
bn->batCount);
+   BBPreclaim(is);
+   }
+   

MonetDB: check - enable ALTER TABLE ... ADD CONSTRAINT ... CHECK...

2024-05-27 Thread Yunus Koning via checkin-list
Changeset: 51333b32e0a1 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/51333b32e0a1
Modified Files:
sql/backends/monet5/rel_bin.c
sql/test/pg_regress/Tests/alter_table.test
Branch: check
Log Message:

enable ALTER TABLE ... ADD CONSTRAINT ... CHECK ... statements


diffs (97 lines):

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
@@ -5997,33 +5997,36 @@ sql_update_check(backend *be, sql_key * 
 
sql_rel* rel = rel_read(sql, sa_strdup(sql->sa, key->check), , 
sa_list(sql->sa));
stack_pop_frame(sql);
-   sql_rel* base = rel->l;
-   assert(strcmp(((sql_exp*) updates->exps->h->data)->alias.name, TID) == 
0);
-   list_append(base->exps, exp_copy(sql, updates->exps->h->data));
-
-   bool need_join = 0;
-   list* pexps = sa_list(sql->sa);
-   sql_exp* tid_exp = exp_copy(sql, updates->exps->h->data);
-   unsigned label = ++sql->label;
-   exp_setrelname(sql->sa, tid_exp, label);
-   list_append(pexps, tid_exp);
-   for (node* m = base->exps->h; m; m = m->next) {
-   if (exps_find_exp( updates->exps, m->data) == NULL) {
-   pexps = list_append(pexps, exp_copy(sql, m->data));
-   need_join = 1;
-   }
-   }
-
-   if (need_join) {
-   base = rel_project(sql->sa, base, pexps);
-   sql_rel* join = rel_crossproduct(sql->sa, base, updates, 
op_join);
-   sql_exp* join_cond = exp_compare(sql->sa, exp_ref(sql, 
base->exps->h->data), exp_ref(sql, updates->exps->h->data), cmp_equal);
-   join->exps = sa_list(sql->sa);
-   join->exps = list_append(join->exps, join_cond);
-   rel->l = join;
-   }
-   else {
-   rel->l = updates;
+
+   if (!key->base.new) {
+   sql_rel* base = rel->l;
+   assert(strcmp(((sql_exp*) updates->exps->h->data)->alias.name, 
TID) == 0);
+   list_append(base->exps, exp_copy(sql, updates->exps->h->data));
+
+   bool need_join = 0;
+   list* pexps = sa_list(sql->sa);
+   sql_exp* tid_exp = exp_copy(sql, updates->exps->h->data);
+   unsigned label = ++sql->label;
+   exp_setrelname(sql->sa, tid_exp, label);
+   list_append(pexps, tid_exp);
+   for (node* m = base->exps->h; m; m = m->next) {
+   if (exps_find_exp( updates->exps, m->data) == NULL) {
+   pexps = list_append(pexps, exp_copy(sql, 
m->data));
+   need_join = 1;
+   }
+   }
+
+   if (need_join) {
+   base = rel_project(sql->sa, base, pexps);
+   sql_rel* join = rel_crossproduct(sql->sa, base, 
updates, op_join);
+   sql_exp* join_cond = exp_compare(sql->sa, exp_ref(sql, 
base->exps->h->data), exp_ref(sql, updates->exps->h->data), cmp_equal);
+   join->exps = sa_list(sql->sa);
+   join->exps = list_append(join->exps, join_cond);
+   rel->l = join;
+   }
+   else {
+   rel->l = updates;
+   }
}
 
sql_subfunc *cnt = sql_bind_func(sql, "sys", "count", 
sql_bind_localtype("void"), NULL, F_AGGR, true, true);
@@ -6138,9 +6141,15 @@ rel2bin_update(backend *be, sql_rel *rel
return NULL;
t = rel_ddl_table_get(tr);
 
-   /* no columns to update (probably an new pkey!) */
-   if (!rel->exps)
+   /* no columns to update (probably an new pkey or ckey!) */
+   if (!rel->exps) {
+   for (m = ol_first_node(t->keys); m; m = m->next) {
+   sql_key * key = m->data;
+   if (key->type == ckey && key->base.new)
+   sql_update_check(be, key, rel->r, refs);
+   }
return ddl;
+   }
}
 
if (rel->r) /* first construct the update relation */
diff --git a/sql/test/pg_regress/Tests/alter_table.test 
b/sql/test/pg_regress/Tests/alter_table.test
--- a/sql/test/pg_regress/Tests/alter_table.test
+++ b/sql/test/pg_regress/Tests/alter_table.test
@@ -469,7 +469,7 @@ create table atacc1 ( test int )
 statement ok
 insert into atacc1 (test) values (2)
 
-statement ok
+statement error
 alter table atacc1 add constraint atacc_test1 check (test>3)
 
 statement ok
___
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org


MonetDB: check - merge with default

2024-05-23 Thread Yunus Koning via checkin-list
Changeset: b1dfe5e93d80 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/b1dfe5e93d80
Branch: check
Log Message:

merge with default


diffs (truncated from 4449 to 300 lines):

diff --git a/gdk/gdk_string.c b/gdk/gdk_string.c
--- a/gdk/gdk_string.c
+++ b/gdk/gdk_string.c
@@ -7211,421 +7211,421 @@ static const char *const valtab[] = {
[102] = "~",
[103] = "''",
[104] = "",
-   [105] = ";",
-   [106] = "AMD",
-   [107] = "M",
-   [108] = "ue",
-   [109] = "X",
-   [110] = "SS",
-   [111] = "LL",
-   [112] = "ll",
-   [113] = "--",
-   [114] = "\"",
-   [115] = ",,",
-   [116] = "+",
-   [117] = "..",
-   [118] = "...",
-   [119] = "``",
-   [120] = "```",
-   [121] = "<",
-   [122] = ">",
-   [123] = "!!",
-   [124] = "??",
-   [125] = "?!",
-   [126] = "!?",
-   [127] = "&",
-   [128] = "0",
-   [129] = "4",
-   [130] = "5",
-   [131] = "6",
-   [132] = "7",
-   [133] = "8",
-   [134] = "9",
-   [135] = "=",
-   [136] = "(",
-   [137] = ")",
-   [138] = "CE",
-   [139] = "C=",
-   [140] = "Cr",
-   [141] = "Fr.",
-   [142] = "L.",
-   [143] = "Pts",
-   [144] = "Rs",
-   [145] = "KRW",
-   [146] = "ILS",
-   [147] = "Dong",
-   [148] = "EUR",
-   [149] = "GRD",
-   [150] = "PHP",
-   [151] = "UAH",
-   [152] = "KZT",
-   [153] = "INR",
-   [154] = "TL",
-   [155] = "RUB",
-   [156] = "GEL",
-   [157] = "a/c",
-   [158] = "a/s",
-   [159] = "c/o",
-   [160] = "c/u",
-   [161] = "No",
-   [162] = "Q",
-   [163] = "Rx",
-   [164] = "SM",
-   [165] = "TEL",
-   [166] = "(TM)",
-   [167] = "FAX",
-   [168] = " 1/7 ",
-   [169] = " 1/9 ",
-   [170] = " 1/10 ",
-   [171] = " 1/3 ",
-   [172] = " 2/3 ",
-   [173] = " 1/5 ",
-   [174] = " 2/5 ",
-   [175] = " 3/5 ",
-   [176] = " 4/5 ",
-   [177] = " 1/6 ",
-   [178] = " 5/6 ",
-   [179] = " 1/8 ",
-   [180] = " 3/8 ",
-   [181] = " 5/8 ",
-   [182] = " 7/8 ",
-   [183] = " 1/ ",
-   [184] = "II",
-   [185] = "III",
-   [186] = "IV",
-   [187] = "VI",
-   [188] = "VII",
-   [189] = "VIII",
-   [190] = "IX",
-   [191] = "XI",
-   [192] = "XII",
-   [193] = "ii",
-   [194] = "iii",
-   [195] = "iv",
-   [196] = "vi",
-   [197] = "vii",
-   [198] = "viii",
-   [199] = "ix",
-   [200] = "xi",
-   [201] = "xii",
-   [202] = " 0/3 ",
-   [203] = "<-",
-   [204] = "->",
-   [205] = "<->",
-   [206] = "!<->",
-   [207] = "!<=",
-   [208] = "!<=>",
-   [209] = "!=>",
-   [210] = "<=",
-   [211] = "=>",
-   [212] = "<=>",
-   [213] = "\\",
-   [214] = "*",
-   [215] = "||",
-   [216] = "!~",
-   [217] = "!~-",
-   [218] = "!~=",
-   [219] = "!~~",
-   [220] = "!=",
-   [221] = "!==",
-   [222] = ">=",
-   [223] = "!<",
-   [224] = "!>",
-   [225] = "!>=",
-   [226] = "!<~",
-   [227] = "!>~",
-   [228] = "!<>",
-   [229] = "!><",
-   [230] = "<<<",
-   [231] = ">>>",
-   [232] = "NUL",
-   [233] = "SOH",
-   [234] = "STX",
-   [235] = "ETX",
-   [236] = "EOT",
-   [237] = "ENQ",
-   [238] = "ACK",
-   [239] = "BEL",
-   [240] = "BS",
-   [241] = "HT",
-   [242] = "LF",
-   [243] = "VT",
-   [244] = "FF",
-   [245] = "CR",
-   [246] = "SO",
-   [247] = "SI",
-   [248] = "DLE",
-   [249] = "DC1",
-   [250] = "DC2",
-   [251] = "DC3",
-   [252] = "DC4",
-   [253] = "NAK",
-   [254] = "SYN",
-   [255] = "ETB",
-   [256] = "CAN",
-   [257] = "EM",
-   [258] = "SUB",
-   [259] = "ESC",
-   [260] = "FS",
-   [261] = "GS",
-   [262] = "RS",
-   [263] = "US",
-   [264] = "SP",
-   [265] = "DEL",
-   [266] = "NL",
-   [267] = "(1)",
-   [268] = "(2)",
-   [269] = "(3)",
-   [270] = "(4)",
-   [271] = "(5)",
-   [272] = "(6)",
-   [273] = "(7)",
-   [274] = "(8)",
-   [275] = "(9)",
-   [276] = "(10)",
-   [277] = "(11)",
-   [278] = "(12)",
-   [279] = "(13)",
-   [280] = "(14)",
-   [281] = "(15)",
-   [282] = "(16)",
-   [283] = "(17)",
-   [284] = "(18)",
-   [285] = "(19)",
-   [286] = "(20)",
-   [287] = "1.",
-   [288] = "2.",
-   [289] = "3.",
-   [290] = "4.",
-   [291] = "5.",
-   [292] = "6.",
-   [293] = "7.",
-   [294] = "8.",
-   [295] = "9.",
-   [296] = "10.",
-   [297] = "11.",
-   [298] = "12.",
-   [299] = "13.",
-   [300] = "14.",
-   [301] = "15.",
-   [302] = "16.",
-   [303] = "17.",
-   [304] = "18.",
-   [305] = "19.",
-   [306] = "20.",

MonetDB: check - allow ALTER TABLE ... ADD COLUMN ... CHECK stat...

2024-05-23 Thread Yunus Koning via checkin-list
Changeset: 19cddbd0ab54 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/19cddbd0ab54
Modified Files:
sql/backends/monet5/rel_bin.c
sql/server/rel_dump.c
sql/test/pg_regress/Tests/alter_table.test
Branch: check
Log Message:

allow ALTER TABLE ... ADD COLUMN ... CHECK statements


diffs (148 lines):

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
@@ -5988,7 +5988,15 @@ sql_update_check(backend *be, sql_key * 
 {
mvc *sql = be->mvc;
int pos = 0;
+
+
+   stack_push_frame(be->mvc, "ALTER TABLE ADD CONSTRAINT CHECK");
+   sql_schema* ss = key->t->s;
+   frame_push_table(sql, key->t);
+   key->t->s = ss; // recover the schema because frame_push_table removes 
it
+
sql_rel* rel = rel_read(sql, sa_strdup(sql->sa, key->check), , 
sa_list(sql->sa));
+   stack_pop_frame(sql);
sql_rel* base = rel->l;
assert(strcmp(((sql_exp*) updates->exps->h->data)->alias.name, TID) == 
0);
list_append(base->exps, exp_copy(sql, updates->exps->h->data));
diff --git a/sql/server/rel_dump.c b/sql/server/rel_dump.c
--- a/sql/server/rel_dump.c
+++ b/sql/server/rel_dump.c
@@ -2030,7 +2030,9 @@ rel_read(mvc *sql, char *r, int *pos, li
skipWS(r, pos);
if (!(s = mvc_bind_schema(sql, sname)))
return sql_error(sql, ERR_NOTFOUND, 
SQLSTATE(3F000) "No such schema '%s'\n", sname);
-   if (!(t = mvc_bind_table(sql, s, tname)))
+   if (stack_has_frame(sql, "ALTER TABLE ADD 
CONSTRAINT CHECK") && !(t = frame_find_table(sql, tname)))
+   return sql_error(sql, ERR_NOTFOUND, 
SQLSTATE(42S02) "Table missing '%s.%s'\n", sname, tname);
+   if (!t && !(t = mvc_bind_table(sql, s, tname)))
return sql_error(sql, ERR_NOTFOUND, 
SQLSTATE(42S02) "Table missing '%s.%s'\n", sname, tname);
if (isMergeTable(t))
return sql_error(sql, -1, 
SQLSTATE(42000) "Merge tables not supported under remote connections\n");
diff --git a/sql/test/pg_regress/Tests/alter_table.test 
b/sql/test/pg_regress/Tests/alter_table.test
--- a/sql/test/pg_regress/Tests/alter_table.test
+++ b/sql/test/pg_regress/Tests/alter_table.test
@@ -1618,13 +1618,13 @@ create table p1 (f1 int)
 statement ok
 create table c1 (f1 int, f2 text, f3 int)
 
-statement error
+statement ok
 alter table p1 add column a1 int check (a1 > 0)
 
 statement ok
 alter table p1 add column f2 text
 
-statement error
+statement ok
 insert into p1 values (1,2,'abc')
 
 statement error
@@ -1633,16 +1633,22 @@ insert into c1 values(11,'xyz',33,0)
 statement error
 insert into c1 values(11,'xyz',33,22)
 
-query IT rowsort
+query IIT rowsort
 select * from p1
 
+1
+2
+abc
 
-statement error
+statement ok
 update p1 set a1 = a1 + 1, f2 = upper(f2)
 
-query IT rowsort
+query IIT rowsort
 select * from p1
 
+1
+3
+ABC
 
 statement ok
 drop table c1 cascade
@@ -1723,10 +1729,10 @@ alter table foo alter f1 TYPE varchar(10
 statement ok
 drop table foo
 
-statement error
+statement ok
 create table anothertab (atcol1 bigint GENERATED ALWAYS AS IDENTITY check 
(atcol1 <= 3), atcol2 boolean)
 
-statement error
+statement ok
 insert into anothertab (atcol1, atcol2) values (default, true)
 
 statement error
@@ -1738,7 +1744,7 @@ insert into anothertab (atcol2) values (
 statement error
 insert into anothertab (atcol2) values (false)
 
-statement error
+statement ok
 select * from anothertab
 
 statement error
@@ -1747,7 +1753,7 @@ alter table anothertab alter column atco
 statement error
 alter table anothertab alter column atcol1 type integer
 
-statement error
+statement ok
 select * from anothertab
 
 statement error
@@ -1759,7 +1765,7 @@ insert into anothertab (atcol1, atcol2) 
 statement error
 insert into anothertab (atcol2) values (null)
 
-statement error
+statement ok
 select * from anothertab
 
 statement error
@@ -1768,14 +1774,14 @@ alter table anothertab alter column atco
  when atcol2 is false then 'IT WAS FALSE'
  else 'IT WAS NULL!' COMMIT
 
-statement error
+statement ok
 select * from anothertab
 
 statement error
 alter table anothertab alter column atcol1 type boolean
 using case when atcol1 % 2 = 0 then true else false COMMIT
 
-statement error
+statement ok
 alter table anothertab alter column atcol1 drop default
 
 statement error
@@ -1789,10 +1795,10 @@ statement error
 alter table anothertab alter column atcol1 type boolean
 using case when atcol1 % 2 = 0 then true else false COMMIT
 
-statement error
+statement ok
 select * from anothertab
 
-statement error
+statement ok
 drop table anothertab
 
 statement ok

MonetDB: check - merge with default

2024-05-22 Thread Yunus Koning via checkin-list
Changeset: 1c112b6b273c for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/1c112b6b273c
Branch: check
Log Message:

merge with default


diffs (truncated from 619 to 300 lines):

diff --git a/gdk/gdk_logger.c b/gdk/gdk_logger.c
--- a/gdk/gdk_logger.c
+++ b/gdk/gdk_logger.c
@@ -1038,6 +1038,7 @@ log_read_types_file(logger *lg, FILE *fp
 {
int id = 0;
char atom_name[IDLENGTH];
+   bool seen_geom = false;
 
/* scanf should use IDLENGTH somehow */
while (fscanf(fp, "%d,%63s\n", , atom_name) == 2) {
@@ -1049,9 +1050,17 @@ log_read_types_file(logger *lg, FILE *fp
GDKerror("unknown type in log file '%s'\n", atom_name);
return GDK_FAIL;
}
+   seen_geom |= strcmp(atom_name, "mbr") == 0 || strcmp(atom_name, 
"wkb") == 0;
lg->type_id[i] = (int8_t) id;
lg->type_nr[id < 0 ? 256 + id : id] = i;
}
+#ifdef HAVE_GEOM
+   if (!seen_geom && ATOMindex("mbr") > 0) {
+   GDKerror("incompatible database: server supports GEOM, but 
database does not\n");
+   return GDK_FAIL;
+   }
+#endif
+   (void) seen_geom;
return GDK_SUCCEED;
 }
 
@@ -1802,7 +1811,8 @@ bm_subcommit(logger *lg, logged_range *p
cleanup++;
if (lids[p] == -1)
continue;
-   if (BUNappend(dcatalog, &(oid){p}, true) != 
GDK_SUCCEED) {
+   if (BUNfnd(dcatalog, &(oid){p}) == BUN_NONE &&
+   BUNappend(dcatalog, &(oid){p}, true) != 
GDK_SUCCEED) {
while (BATcount(dcatalog) > dcnt) {
if (BUNdelete(dcatalog, 
BATcount(dcatalog) - 1) != GDK_SUCCEED) {
TRC_CRITICAL(WAL, "delete after 
failed append failed\n");
diff --git a/gdk/gdk_string.c b/gdk/gdk_string.c
--- a/gdk/gdk_string.c
+++ b/gdk/gdk_string.c
@@ -1477,153 +1477,155 @@ GDKanalytical_str_group_concat(BAT *r, B
  * Only for the casefold table, if the converted codepoint is negative,
  * it is actually an escape into the specialcase table.  The absolute
  * value is the index. */
+
+/* These tables were created using the code in unicaseconvtabs.py */
 static const char *const specialcase[] = {
NULL,
-   "ss",
-   "i\xCC\x87",
-   "\xCA\xBCn",
-   "j\xCC\x8C",
-   "\xCE\xB9\xCC\x88\xCC\x81",
-   "\xCF\x85\xCC\x88\xCC\x81",
-   "\xD5\xA5\xD6\x82",
-   "h\xCC\xB1",
-   "t\xCC\x88",
-   "w\xCC\x8A",
-   "y\xCC\x8A",
-   "a\xCA\xBE",
-   "\xCF\x85\xCC\x93",
-   "\xCF\x85\xCC\x93\xCC\x80",
-   "\xCF\x85\xCC\x93\xCC\x81",
-   "\xCF\x85\xCC\x93\xCD\x82",
-   "\xE1\xBC\x80\xCE\xB9",
-   "\xE1\xBC\x81\xCE\xB9",
-   "\xE1\xBC\x82\xCE\xB9",
-   "\xE1\xBC\x83\xCE\xB9",
-   "\xE1\xBC\x84\xCE\xB9",
-   "\xE1\xBC\x85\xCE\xB9",
-   "\xE1\xBC\x86\xCE\xB9",
-   "\xE1\xBC\x87\xCE\xB9",
-   "\xE1\xBC\xA0\xCE\xB9",
-   "\xE1\xBC\xA1\xCE\xB9",
-   "\xE1\xBC\xA2\xCE\xB9",
-   "\xE1\xBC\xA3\xCE\xB9",
-   "\xE1\xBC\xA4\xCE\xB9",
-   "\xE1\xBC\xA5\xCE\xB9",
-   "\xE1\xBC\xA6\xCE\xB9",
-   "\xE1\xBC\xA7\xCE\xB9",
-   "\xE1\xBD\xA0\xCE\xB9",
-   "\xE1\xBD\xA1\xCE\xB9",
-   "\xE1\xBD\xA2\xCE\xB9",
-   "\xE1\xBD\xA3\xCE\xB9",
-   "\xE1\xBD\xA4\xCE\xB9",
-   "\xE1\xBD\xA5\xCE\xB9",
-   "\xE1\xBD\xA6\xCE\xB9",
-   "\xE1\xBD\xA7\xCE\xB9",
-   "\xE1\xBD\xB0\xCE\xB9",
-   "\xCE\xB1\xCE\xB9",
-   "\xCE\xAC\xCE\xB9",
-   "\xCE\xB1\xCD\x82",
-   "\xCE\xB1\xCD\x82\xCE\xB9",
-   "\xE1\xBD\xB4\xCE\xB9",
-   "\xCE\xB7\xCE\xB9",
-   "\xCE\xAE\xCE\xB9",
-   "\xCE\xB7\xCD\x82",
-   "\xCE\xB7\xCD\x82\xCE\xB9",
-   "\xCE\xB9\xCC\x88\xCC\x80",
-   "\xCE\xB9\xCD\x82",
-   "\xCE\xB9\xCC\x88\xCD\x82",
-   "\xCF\x85\xCC\x88\xCC\x80",
-   "\xCF\x81\xCC\x93",
-   "\xCF\x85\xCD\x82",
-   "\xCF\x85\xCC\x88\xCD\x82",
-   "\xE1\xBD\xBC\xCE\xB9",
-   "\xCF\x89\xCE\xB9",
-   "\xCF\x8E\xCE\xB9",
-   "\xCF\x89\xCD\x82",
-   "\xCF\x89\xCD\x82\xCE\xB9",
-   "ff",
-   "fi",
-   "fl",
-   "ffi",
-   "ffl",
-   "st",
-   "\xD5\xB4\xD5\xB6",
-   "\xD5\xB4\xD5\xA5",
-   "\xD5\xB4\xD5\xAB",
-   "\xD5\xBE\xD5\xB6",
-   "\xD5\xB4\xD5\xAD",
-   "SS",
-   "FF",
-   "FI",
-   "FL",
-   "FFI",
-   "FFL",
-   "ST",
-   "\xD4\xB5\xD5\x92",
-   "\xD5\x84\xD5\x86",
-   "\xD5\x84\xD4\xB5",
-   "\xD5\x84\xD4\xBB",
-   "\xD5\x8E\xD5\x86",
-   "\xD5\x84\xD4\xBD",
-   "\xCA\xBCN",
-   "\xCE\x99\xCC\x88\xCC\x81",
-   "\xCE\xA5\xCC\x88\xCC\x81",
-   "J\xCC\x8C",
-   "H\xCC\xB1",
-   "T\xCC\x88",
-   "W\xCC\x8A",
-   "Y\xCC\x8A",
-   "A\xCA\xBE",
-   

MonetDB: check - approve new test output

2024-05-22 Thread Yunus Koning via checkin-list
Changeset: 8f41e6d99b7e for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/8f41e6d99b7e
Modified Files:

sql/test/BugTracker-2018/Tests/groupby_having_orderby_count.Bug-6624.test
sql/test/BugTracker-2019/Tests/alter_table_set_schema.Bug-6701.test
sql/test/bugs/Tests/groupby_having-bug-sf-947600.test
sql/test/bugs/Tests/innerjoin_multiple-bug-sf-943661.test
sql/test/bugs/Tests/select_orderby_alias-bug-sf-1024615.test
sql/test/pg_regress/Tests/alter_table.test
sql/test/sys-schema/Tests/check_ForeignKey_referential_integrity.test
sql/test/sys-schema/Tests/check_Not_Nullable_columns.test
Branch: check
Log Message:

approve new test output


diffs (277 lines):

diff --git 
a/sql/test/BugTracker-2018/Tests/groupby_having_orderby_count.Bug-6624.test 
b/sql/test/BugTracker-2018/Tests/groupby_having_orderby_count.Bug-6624.test
--- a/sql/test/BugTracker-2018/Tests/groupby_having_orderby_count.Bug-6624.test
+++ b/sql/test/BugTracker-2018/Tests/groupby_having_orderby_count.Bug-6624.test
@@ -10,7 +10,7 @@ 20
 smallint
 6
 varchar
-14
+15
 
 query TI rowsort
 SELECT type,COUNT(id) FROM cols_6624 GROUP BY type HAVING COUNT(id)>5 ORDER BY 
2 DESC
@@ -20,7 +20,7 @@ 20
 smallint
 6
 varchar
-14
+15
 
 query TI rowsort
 SELECT type,COUNT(id) as cnt FROM cols_6624 GROUP BY type HAVING COUNT(id)>5 
ORDER BY cnt DESC
@@ -30,7 +30,7 @@ 20
 smallint
 6
 varchar
-14
+15
 
 statement ok
 DROP TABLE cols_6624
diff --git 
a/sql/test/BugTracker-2019/Tests/alter_table_set_schema.Bug-6701.test 
b/sql/test/BugTracker-2019/Tests/alter_table_set_schema.Bug-6701.test
--- a/sql/test/BugTracker-2019/Tests/alter_table_set_schema.Bug-6701.test
+++ b/sql/test/BugTracker-2019/Tests/alter_table_set_schema.Bug-6701.test
@@ -6,7 +6,7 @@ query ITTIIITIIT rowsort
 SELECT * FROM sys._columns WHERE table_id NOT IN (SELECT id FROM sys._tables)
 
 
-query IIITII rowsort
+query IIITIIT rowsort
 SELECT * FROM sys.keys WHERE table_id NOT IN (SELECT id FROM sys.tables)
 
 
@@ -106,7 +106,7 @@ query ITTIIITIIT rowsort
 SELECT * FROM sys._columns WHERE table_id NOT IN (SELECT id FROM sys._tables)
 
 
-query IIITII rowsort
+query IIITIIT rowsort
 SELECT * FROM sys.keys WHERE table_id NOT IN (SELECT id FROM sys.tables)
 
 
@@ -137,7 +137,7 @@ query ITTIIITIIT rowsort
 SELECT * FROM sys._columns WHERE table_id NOT IN (SELECT id FROM sys._tables)
 
 
-query IIITII rowsort
+query IIITIIT rowsort
 SELECT * FROM sys.keys WHERE table_id NOT IN (SELECT id FROM sys.tables)
 
 
diff --git a/sql/test/bugs/Tests/groupby_having-bug-sf-947600.test 
b/sql/test/bugs/Tests/groupby_having-bug-sf-947600.test
--- a/sql/test/bugs/Tests/groupby_having-bug-sf-947600.test
+++ b/sql/test/bugs/Tests/groupby_having-bug-sf-947600.test
@@ -75,7 +75,7 @@ idxs
 12
 keys
 keys
-6
+7
 keys
 objects
 6
diff --git a/sql/test/bugs/Tests/innerjoin_multiple-bug-sf-943661.test 
b/sql/test/bugs/Tests/innerjoin_multiple-bug-sf-943661.test
--- a/sql/test/bugs/Tests/innerjoin_multiple-bug-sf-943661.test
+++ b/sql/test/bugs/Tests/innerjoin_multiple-bug-sf-943661.test
@@ -11,7 +11,7 @@ select schemas.name, tables.name, column
'objects', 'keys', 'modules', 'sequences')
  order by schemas.name, tables.name, columns.name
 
-429 values hashing to 6d7dbf36ca46001022af9219632baa04
+435 values hashing to bb81bada51b1bbe50f43e6f3cc184250
 
 query TTT rowsort
 select s.name, t.name, c.name from
@@ -26,5 +26,5 @@ select s.name, t.name, c.name from
'objects', 'keys', 'modules', 'sequences')
  order by s.name, t.name, c.name
 
-429 values hashing to 6d7dbf36ca46001022af9219632baa04
+435 values hashing to bb81bada51b1bbe50f43e6f3cc184250
 
diff --git a/sql/test/bugs/Tests/select_orderby_alias-bug-sf-1024615.test 
b/sql/test/bugs/Tests/select_orderby_alias-bug-sf-1024615.test
--- a/sql/test/bugs/Tests/select_orderby_alias-bug-sf-1024615.test
+++ b/sql/test/bugs/Tests/select_orderby_alias-bug-sf-1024615.test
@@ -1,4 +1,4 @@
-query IIITIIITIIITITIITIII rowsort
+query IIITIITITIIITITIITIII rowsort
 SELECT * FROM "sys"."keys" AS "keys", "sys"."objects" AS
 "objects", "sys"."tables" AS "tables",
 "sys"."schemas" AS "schemas" WHERE "keys"."id" =
@@ -8,7 +8,7 @@ AND "tables"."schema_id" = "schemas"."id
 "tables"."name" LIKE 'x'
 
 
-query IIITIIITIIITITIITIII rowsort
+query IIITIITITIIITITIITIII rowsort
 SELECT * FROM "sys"."keys" AS "keys", "sys"."objects" AS
 "objects", "sys"."tables" AS "tables",
 "sys"."schemas" AS "schemas" WHERE "keys"."id" =
diff --git a/sql/test/pg_regress/Tests/alter_table.test 
b/sql/test/pg_regress/Tests/alter_table.test
--- a/sql/test/pg_regress/Tests/alter_table.test
+++ b/sql/test/pg_regress/Tests/alter_table.test
@@ -451,10 +451,10 @@ DROP TABLE PKTABLE cascade
 statement ok
 create table atacc1 ( test int )
 
-statement error
+statement ok
 alter table atacc1 add constraint atacc_test1 check (test>3)
 
-statement ok
+statement 

MonetDB: check - remove obsolet missing feature test

2024-05-22 Thread Yunus Koning via checkin-list
Changeset: 93c8186a6fc9 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/93c8186a6fc9
Removed Files:
sql/test/BugTracker-2013/Tests/check-constraint.Bug-3335.test
Modified Files:
sql/test/2024/Tests/check.test
sql/test/BugTracker-2013/Tests/All
Branch: check
Log Message:

remove obsolet missing feature test


diffs (67 lines):

diff --git a/sql/test/2024/Tests/check.test b/sql/test/2024/Tests/check.test
--- a/sql/test/2024/Tests/check.test
+++ b/sql/test/2024/Tests/check.test
@@ -39,3 +39,23 @@ create table baz(j int check (j > (selec
 
 statement error
 create table baz(j int check (j in (select i from foo)))
+
+-- exported from check-constraint.Bug-3335
+
+statement ok
+create table t3335(x integer check(x > 0 and x < 2))
+
+statement ok
+insert into t3335 values(1)
+
+statement error
+insert into t3335 values(0)
+
+statement error
+insert into t3335 values(2)
+
+statement error
+insert into t3335 values(-1)
+
+statement error
+insert into t3335 values(3)
diff --git a/sql/test/BugTracker-2013/Tests/All 
b/sql/test/BugTracker-2013/Tests/All
--- a/sql/test/BugTracker-2013/Tests/All
+++ b/sql/test/BugTracker-2013/Tests/All
@@ -47,7 +47,6 @@ copy-into-compressed.Bug-3351
 HAVE_LIBZ?copy-into-compressed-gz.Bug-3351
 HAVE_LIBBZ2?copy-into-compressed-bz2.Bug-3351
 median.Bug-3352
-check-constraint.Bug-3335
 crash_after_creation_of_unique_key.Bug-3363
 alter_resets_readonly.Bug-3362
 env_errors.Bug-3370
diff --git a/sql/test/BugTracker-2013/Tests/check-constraint.Bug-3335.test 
b/sql/test/BugTracker-2013/Tests/check-constraint.Bug-3335.test
deleted file mode 100644
--- a/sql/test/BugTracker-2013/Tests/check-constraint.Bug-3335.test
+++ /dev/null
@@ -1,24 +0,0 @@
-statement ok
-start transaction
-
-statement error
-create table t3335(x integer check(x > 0 and x < 2))
-
-statement error
-insert into t3335 values(1)
-
-statement error
-insert into t3335 values(0)
-
-statement error
-insert into t3335 values(2)
-
-statement error
-insert into t3335 values(-1)
-
-statement error
-insert into t3335 values(3)
-
-statement ok
-rollback
-
___
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org


MonetDB: check - fix copy/paste bug

2024-05-22 Thread Yunus Koning via checkin-list
Changeset: fcb13a521f48 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/fcb13a521f48
Modified Files:
sql/storage/store.c
Branch: check
Log Message:

fix copy/paste bug


diffs (12 lines):

diff --git a/sql/storage/store.c b/sql/storage/store.c
--- a/sql/storage/store.c
+++ b/sql/storage/store.c
@@ -1687,8 +1687,6 @@ dup_sql_column(allocator *sa, sql_table 
col->storage_type = SA_STRDUP(sa, c->storage_type);
if (ol_add(t->columns, >base))
return NULL;
-   if (ol_add(t->columns, >base))
-   return NULL;
return col;
 }
 
___
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org


MonetDB: check - aprove tests

2024-05-22 Thread Yunus Koning via checkin-list
Changeset: fcbb5a7377e1 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/fcbb5a7377e1
Modified Files:

sql/test/BugDay_2005-10-06_2.9.3/Tests/CrashMe_SQL_server_crash-2.SF-921673.test

sql/test/BugDay_2005-11-09_2.8/Tests/ORDER_BY_evaluation_error.SF-1023658.test
Branch: check
Log Message:

aprove tests


diffs (28 lines):

diff --git 
a/sql/test/BugDay_2005-10-06_2.9.3/Tests/CrashMe_SQL_server_crash-2.SF-921673.test
 
b/sql/test/BugDay_2005-10-06_2.9.3/Tests/CrashMe_SQL_server_crash-2.SF-921673.test
--- 
a/sql/test/BugDay_2005-10-06_2.9.3/Tests/CrashMe_SQL_server_crash-2.SF-921673.test
+++ 
b/sql/test/BugDay_2005-10-06_2.9.3/Tests/CrashMe_SQL_server_crash-2.SF-921673.test
@@ -27,5 +27,5 @@ WHERE columns.table_id = tables.id
 'objects', 'keys', 'modules', 'sequences')
 ORDER BY TABLE_SCHEM, TABLE_NAME, ORDINAL_POSITION
 
-1121 values hashing to bb4b4edafb89bbfcb29b757e953cd0ce
+1159 values hashing to 3c2bbe6a5854a6cce3e3b47236e91c82
 
diff --git 
a/sql/test/BugDay_2005-11-09_2.8/Tests/ORDER_BY_evaluation_error.SF-1023658.test
 
b/sql/test/BugDay_2005-11-09_2.8/Tests/ORDER_BY_evaluation_error.SF-1023658.test
--- 
a/sql/test/BugDay_2005-11-09_2.8/Tests/ORDER_BY_evaluation_error.SF-1023658.test
+++ 
b/sql/test/BugDay_2005-11-09_2.8/Tests/ORDER_BY_evaluation_error.SF-1023658.test
@@ -1,4 +1,4 @@
-query IIITIIITIIITITIITIII rowsort
+query IIITIITITIIITITIITIII rowsort
 SELECT *
 FROM "keys", "objects", "tables", "schemas"
 WHERE "keys"."id" = "objects"."id"
@@ -8,7 +8,7 @@ WHERE "keys"."id" = "objects"."id"
   AND "keys"."type" = 0
 
 
-query IIITIIITIIITITIITIII rowsort
+query IIITIITITIIITITIITIII rowsort
 SELECT *
 FROM "keys", "objects", "tables", "schemas"
 WHERE "keys"."id" = "objects"."id"
___
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org


MonetDB: check - bat_logger upgrade code: add _columns.check column

2024-05-21 Thread Yunus Koning via checkin-list
Changeset: 401c9bf21e6d for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/401c9bf21e6d
Modified Files:
sql/storage/bat/bat_logger.c
Branch: check
Log Message:

bat_logger upgrade code: add _columns.check column


diffs (69 lines):

diff --git a/sql/storage/bat/bat_logger.c b/sql/storage/bat/bat_logger.c
--- a/sql/storage/bat/bat_logger.c
+++ b/sql/storage/bat/bat_logger.c
@@ -93,6 +93,14 @@ bl_preversion(sqlstore *store, int oldve
}
 #endif
 
+#ifdef CATALOG_FIRST_AFTER_DEC2023
+   if (oldversion == CATALOG_FIRST_AFTER_DEC2023) {
+   /* upgrade to default releases */
+   store->catalog_version = oldversion;
+   return GDK_SUCCEED;
+   }
+#endif
+
return GDK_FAIL;
 }
 
@@ -3240,6 +3248,50 @@ bl_postversion(void *Store, void *Lg)
}
 #endif
 
+
+#ifdef CATALOG_FIRST_AFTER_DEC2023
+   if (store->catalog_version <= CATALOG_FIRST_AFTER_DEC2023) {
+   /* new STRING column sys.keys.check */
+   BAT *b = log_temp_descriptor(log_find_bat(lg, 2088)); 
/* sys.keys.id */
+   if (b == NULL)
+   return GDK_FAIL;
+   BAT *check = BATconstant(b->hseqbase, TYPE_str, 
ATOMnilptr(TYPE_str), BATcount(b), PERSISTENT);
+   bat_destroy(b);
+   if (check == NULL)
+   return GDK_FAIL;
+   if ((check = BATsetaccess(check, BAT_READ)) == NULL ||
+   /* 2165 is sys.keys.check */
+   BUNappend(lg->catalog_id, &(int) {2165}, true) 
!= GDK_SUCCEED ||
+   BUNappend(lg->catalog_bid, >batCacheid, 
true) != GDK_SUCCEED ||
+   BUNappend(lg->catalog_lid, _nil, false) != 
GDK_SUCCEED ||
+   BUNappend(lg->catalog_cnt, 
&(lng){BATcount(check)}, false) != GDK_SUCCEED
+   ) {
+   bat_destroy(check);
+   return GDK_FAIL;
+   }
+   BBPretain(check->batCacheid);
+   bat_destroy(check);
+
+   if (tabins(lg, old_lg, tabins_first, -1, 0,
+  2076, &(msk) {false},/* 
sys._columns */
+  /* 2165 is sys.keys.check */
+  2077, &(int) {2165}, /* 
sys._columns.id */
+  2078, "check",   
/* sys._columns.name */
+  2079, "varchar", 
/* sys._columns.type */
+  2080, &(int) {2048}, /* 
sys._columns.type_digits */
+  2081, &(int) {0},/* 
sys._columns.type_scale */
+  /* 2016 is sys.functions */
+  2082, &(int) {2016}, /* 
sys._columns.table_id */
+  2083, str_nil,   
/* sys._columns.default */
+  2084, &(bit) {TRUE}, /* 
sys._columns.null */
+  2085, &(int) {6},/* 
sys._columns.number */
+  2086, str_nil,   
/* sys._columns.storage */
+  0) != GDK_SUCCEED)
+   return GDK_FAIL;
+   tabins_first = false;
+   }
+#endif
+
return GDK_SUCCEED;
 }
 
___
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org


MonetDB: check - add new catalog version

2024-05-21 Thread Yunus Koning via checkin-list
Changeset: f2f8f97a8e28 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/f2f8f97a8e28
Modified Files:
sql/storage/bat/bat_logger.c
sql/storage/store.c
Branch: check
Log Message:

add new catalog version


diffs (25 lines):

diff --git a/sql/storage/bat/bat_logger.c b/sql/storage/bat/bat_logger.c
--- a/sql/storage/bat/bat_logger.c
+++ b/sql/storage/bat/bat_logger.c
@@ -24,6 +24,7 @@
 #define CATALOG_JUL2021 52300  /* first in Jul2021 */
 #define CATALOG_JAN2022 52301  /* first in Jan2022 */
 #define CATALOG_SEP2022 52302  /* first in Sep2022 */
+#define CATALOG_FIRST_AFTER_DEC2023 52303  /* first after Dec2023 */
 
 /* Note, CATALOG version 52300 is the first one where the basic system
  * tables (the ones created in store.c) have fixed and unchangeable
diff --git a/sql/storage/store.c b/sql/storage/store.c
--- a/sql/storage/store.c
+++ b/sql/storage/store.c
@@ -22,8 +22,8 @@
 #include "bat/bat_table.h"
 #include "bat/bat_logger.h"
 
-/* version 05.23.02 of catalog */
-#define CATALOG_VERSION 52303  /* first after Dec2023 */
+/* version 05.23.03 of catalog */
+#define CATALOG_VERSION 52304  /* second after Dec2023 */
 
 ulng
 store_function_counter(sqlstore *store)
___
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org


MonetDB: check - merge with default

2024-05-21 Thread Yunus Koning via checkin-list
Changeset: 2e2b4a44301c for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/2e2b4a44301c
Branch: check
Log Message:

merge with default


diffs (truncated from 309 to 300 lines):

diff --git a/monetdb5/modules/mal/pcre.c b/monetdb5/modules/mal/pcre.c
--- a/monetdb5/modules/mal/pcre.c
+++ b/monetdb5/modules/mal/pcre.c
@@ -63,7 +63,7 @@ struct RE {
  * byte and don't deal with multibyte encodings (such as UTF-8). */
 
 static inline bool
-re_is_pattern_properly_escaped(const char *pat, unsigned char esc)
+mnre_is_pattern_properly_escaped(const char *pat, unsigned char esc)
 {
bool escaped = false;
 
@@ -94,7 +94,7 @@ is_strcmpable(const char *pat, const cha
 /* Match regular expression by comparing bytes.
  */
 static inline bool
-re_match(const char *restrict s, const struct RE *restrict pattern)
+mnre_match(const char *restrict s, const struct RE *restrict pattern)
 {
const struct RE *r;
 
@@ -142,14 +142,14 @@ re_match(const char *restrict s, const s
 * we need to backtrack, so use recursion; here we know 
we
 * have the %, look for an _ in the rest of the pattern
 * (note %_ and _% are equivalent and is taken care of 
by
-* the pattern construction in re_create) */
+* the pattern construction in mnre_create) */
for (const struct RE *p = r->n; p; p = p->n) {
if (p->skip != 0) {
struct RE pat = *r;
pat.search = false;
pat.skip = 0;
do {
-   if (re_match(s, ))
+   if (mnre_match(s, ))
return true;
do
s++;
@@ -213,7 +213,7 @@ re_match(const char *restrict s, const s
 }
 
 static void
-re_destroy(struct RE *p)
+mnre_destroy(struct RE *p)
 {
if (p) {
GDKfree(p->k);
@@ -235,7 +235,7 @@ re_destroy(struct RE *p)
  * the first.
  */
 static struct RE *
-re_create(const char *pat, bool caseignore, uint32_t esc)
+mnre_create(const char *pat, bool caseignore, uint32_t esc)
 {
struct RE *r = GDKmalloc(sizeof(struct RE)), *n = r;
bool escaped = false;
@@ -312,7 +312,7 @@ re_create(const char *pat, bool caseigno
*q = 0;
return r;
   bailout:
-   re_destroy(r);
+   mnre_destroy(r);
return NULL;
 }
 
@@ -1131,7 +1131,7 @@ choose_like_path(bool *use_re, bool *use
if (strNil(pat) || strNil(esc)) {
*empty = true;
} else {
-   if (!re_is_pattern_properly_escaped(pat, (unsigned char) *esc))
+   if (!mnre_is_pattern_properly_escaped(pat, (unsigned char) 
*esc))
throw(MAL, "pcre.sql2pcre",
  SQLSTATE(22019) ILLEGAL_ARGUMENT
  ": (I)LIKE pattern must not end with escape 
character");
@@ -1169,16 +1169,16 @@ PCRElike_imp(bit *ret, const char *const
*ret = *isens ? GDKstrcasecmp(*s, *pat) == 0
: strcmp(*s, *pat) == 0;
} else {
-   if (!(re = re_create(*pat, *isens, (unsigned char) 
**esc)))
+   if (!(re = mnre_create(*pat, *isens, (unsigned char) 
**esc)))
res = createException(MAL, "pcre.like4",
  
SQLSTATE(HY013) MAL_MALLOC_FAIL);
else
-   *ret = re_match(*s, re);
+   *ret = mnre_match(*s, re);
}
}
 
if (re)
-   re_destroy(re);
+   mnre_destroy(re);
return res;
 }
 
@@ -1202,11 +1202,11 @@ PCREnotlike(bit *ret, const char *const 
 }
 
 static inline str
-re_like_build(struct RE **re, const char *pat, bool caseignore,
+mnre_like_build(struct RE **re, const char *pat, bool caseignore,
  bool use_strcmp, uint32_t esc)
 {
if (!use_strcmp) {
-   if (!(*re = re_create(pat, caseignore, esc)))
+   if (!(*re = mnre_create(pat, caseignore, esc)))
return createException(MAL, "pcre.re_like_build",
   
SQLSTATE(HY013) MAL_MALLOC_FAIL);
}
@@ -1214,7 +1214,7 @@ re_like_build(struct RE **re, const char
 }
 
 static inline bit
-re_like_proj_apply(const char *s, const struct RE *restrict re,
+mnre_like_proj_apply(const char *s, const struct RE *restrict re,
   const char *pat,
 

MonetDB: check - merge with default

2024-05-20 Thread Yunus Koning via checkin-list
Changeset: 3ac1eb089295 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/3ac1eb089295
Modified Files:
sql/server/rel_select.c
Branch: check
Log Message:

merge with default


diffs (60 lines):

diff --git a/sql/server/rel_select.c b/sql/server/rel_select.c
--- a/sql/server/rel_select.c
+++ b/sql/server/rel_select.c
@@ -4744,6 +4744,23 @@ rel_rankop(sql_query *query, sql_rel **r
char *uaname = SA_NEW_ARRAY(sql->ta, char, strlen(aname) + 1);
return sql_error(sql, 02, SQLSTATE(42000) "%s: window functions 
cannot be nested", toUpperCopy(uaname, aname));
}
+   if (window_function->token == SQL_UNOP || window_function->token == 
SQL_OP) {
+   window_function->token = SQL_NOP;
+   dn->next->next->data.lval = dlist_append_symbol(sql->sa, 
dlist_create( sql->sa ), dn->next->next->data.sym); /* make a list */
+   }
+   if (window_function->token == SQL_BINOP) {
+   window_function->token = SQL_NOP;
+   dn->next->next->data.lval = dlist_append_symbol(sql->sa, 
dlist_append_symbol(sql->sa, dlist_create( sql->sa ), 
dn->next->next->data.sym), dn->next->next->next->data.sym); /* make a list */
+   dn->next->next->next = dn->next->next->next->next; /* skip 
second arg */
+   }
+   if (window_function->token == SQL_AGGR)
+   dn->next->next->data.lval = dlist_append_symbol(sql->sa, 
dlist_create( sql->sa ), dn->next->next->data.sym); /* make a list */
+   if (window_function->token == SQL_NOP)
+   window_function->token = SQL_AGGR;
+   if (window_function->token != SQL_RANK && window_function->token != 
SQL_AGGR) {
+   char *uaname = SA_NEW_ARRAY(sql->ta, char, strlen(aname) + 1);
+   return sql_error(sql, 02, SQLSTATE(42000) "SELECT: window 
function '%s' unknown", toUpperCopy(uaname, aname));
+   }
 
/* window operations are only allowed in the projection */
if (!is_sql_sel(f))
@@ -4814,7 +4831,7 @@ rel_rankop(sql_query *query, sql_rel **r
}
} else { /* aggregation function call */
distinct = dn->next->data.i_val;
-   for (dargs = dn->next->next ; dargs && dargs->data.sym ; dargs 
= dargs->next) {
+   for (dargs = dn->next->next->data.lval->h ; dargs && 
dargs->data.sym ; dargs = dargs->next) {
exp_kind ek = {type_value, card_column, FALSE};
sql_subtype *empty = sql_bind_localtype("void"), *bte = 
sql_bind_localtype("bte");
 
diff --git a/sql/test/BugTracker-2024/Tests/7514-wrong-window-function.test 
b/sql/test/BugTracker-2024/Tests/7514-wrong-window-function.test
new file mode 100644
--- /dev/null
+++ b/sql/test/BugTracker-2024/Tests/7514-wrong-window-function.test
@@ -0,0 +1,11 @@
+statement error SELECT: no such window function 'wrong_function'(tinyint, 
tinyint, tinyint)
+select
+   wrong_function(col1, col2, col3) over w
+from
+   (select 0 as col1, 1 as col2, 2 as col3) t window w as (partition by 
col1)
+
+statement error SELECT: identifier 'wrong_column' unknown
+select
+   wrong_function(col1, col2, wrong_column) over w
+from
+   (select 0 as col1, 1 as col2, 2 as col3) t window w as (partition by 
col1)
diff --git a/sql/test/BugTracker-2024/Tests/All 
b/sql/test/BugTracker-2024/Tests/All
--- a/sql/test/BugTracker-2024/Tests/All
+++ b/sql/test/BugTracker-2024/Tests/All
@@ -58,3 +58,4 @@ field-arg-error-Bug-7506
 7511-password-hash-missing-error
 7512-concurrent-globaltmp-instantiate-crash
 7513-uri-authority-parse-issue
+7514-wrong-window-function
___
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org


MonetDB: check - merge with default

2024-05-17 Thread Yunus Koning via checkin-list
Changeset: 91250c27a94f for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/91250c27a94f
Modified Files:
sql/backends/monet5/rel_bin.c
sql/server/rel_rel.h
sql/server/rel_select.c
sql/server/sql_parser.y
sql/storage/store.c
Branch: check
Log Message:

merge with default


diffs (truncated from 36794 to 300 lines):

diff --git a/.hgtags b/.hgtags
--- a/.hgtags
+++ b/.hgtags
@@ -825,3 +825,5 @@ dcc8c702e685a4faf21ccf663028d1bc3d1165d1
 dcc8c702e685a4faf21ccf663028d1bc3d1165d1 Dec2023_SP1_release
 d656785f49ee62c19705722aa6b7c171904c64d5 Dec2023_7
 d656785f49ee62c19705722aa6b7c171904c64d5 Dec2023_SP2_release
+9a694c41042503a22d6c92aeab5bc4ca1912b62e Dec2023_9
+9a694c41042503a22d6c92aeab5bc4ca1912b62e Dec2023_SP3_release
diff --git a/ChangeLog b/ChangeLog
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,21 @@
 # ChangeLog file for devel
 # This file is updated with Maddlog
 
+* Wed May  8 2024 Sjoerd Mullender 
+- The shared library (.dll aka .so files) now have the version number
+  as part of the name.  This should allow the building of compatibility
+  versions that can be installed in parallel to the latest version.
+- Some of the Debian/Ubuntu packages have been renamed.  The old monetdb5
+  names have been changed to plain monetdb, and libmonetdb5-server-*
+  packages have been renamed monetdb-*.
+- The names of some of the provided RPM files have been changed.
+  References to the old MonetDB5 name have been removed.  All packages
+  are now just MonetDB.
+
+* Wed May  8 2024 Niels Nes 
+- Add support for select exp, count(*) group by 1 order by 1; ie. using
+  numeric references Added support for group by all and order by all. The
+  later is ordering on all columns of the selection.  The group by all
+  finds all expressions from the selections which aren't aggregations
+  and groups on those.  All can also be replaced by '*'.
+
diff --git a/MonetDB.spec b/MonetDB.spec
--- a/MonetDB.spec
+++ b/MonetDB.spec
@@ -8,8 +8,12 @@
 # Copyright August 2008 - 2023 MonetDB B.V.;
 # Copyright 1997 - July 2008 CWI.
 
-%global name MonetDB
 %global version 11.50.0
+
+%bcond_with compat
+
+%global name MonetDB%{?with_compat:%version}
+
 %{!?buildno: %global buildno %(date +%Y%m%d)}
 
 # Use bcond_with to add a --with option; i.e., "without" is default.
@@ -57,7 +61,7 @@
 # available.  However, the geos library is available in the Extra
 # Packages for Enterprise Linux (EPEL).
 %if %{fedpkgs} && (0%{?rhel} != 7) && (0%{?rhel} != 8)
-# By default create the MonetDB-geom-MonetDB5 package on Fedora and RHEL 7
+# By default create the MonetDB-geom package on Fedora and RHEL 7
 %bcond_without geos
 %endif
 
@@ -91,7 +95,7 @@ Group: Applications/Databases
 License: MPL-2.0
 URL: https://www.monetdb.org/
 BugURL: https://github.com/MonetDB/MonetDB/issues
-Source: 
https://www.monetdb.org/downloads/sources/Dec2023-SP2/%{name}-%{version}.tar.bz2
+Source: 
https://www.monetdb.org/downloads/sources/Dec2023-SP3/MonetDB-%{version}.tar.bz2
 
 # The Fedora packaging document says we need systemd-rpm-macros for
 # the _unitdir and _tmpfilesdir macros to exist; however on RHEL 7
@@ -117,7 +121,9 @@ BuildRequires: unixODBC-devel
 BuildRequires: readline-devel
 %else
 BuildRequires: pkgconfig(bzip2)
+%if %{without compat}
 BuildRequires: pkgconfig(odbc)
+%endif
 BuildRequires: pkgconfig(readline)
 %endif
 %if %{with fits}
@@ -154,8 +160,8 @@ BuildRequires: pkgconfig(libR)
 # BuildRequires: pkgconfig(valgrind)# -DWITH_VALGRIND=ON
 
 %if (0%{?fedora} >= 22)
-Recommends: %{name}-SQL-server5%{?_isa} = %{version}-%{release}
-Recommends: MonetDB5-server%{?_isa} = %{version}-%{release}
+Recommends: %{name}-SQL%{?_isa} = %{version}-%{release}
+Recommends: %{name}-server%{?_isa} = %{version}-%{release}
 Suggests: %{name}-client%{?_isa} = %{version}-%{release}
 %endif
 
@@ -167,8 +173,8 @@ accelerators.  It also has an SQL front 
 
 This package contains the core components of MonetDB in the form of a
 single shared library.  If you want to use MonetDB, you will certainly
-need this package, but you will also need at least the MonetDB5-server
-package, and most likely also %{name}-SQL-server5, as well as one or
+need this package, but you will also need at least the %{name}-server
+package, and most likely also %{name}-SQL, as well as one or
 more client packages.
 
 %ldconfig_scriptlets
@@ -176,8 +182,9 @@ more client packages.
 %files
 %license COPYING
 %defattr(-,root,root)
-%{_libdir}/libbat.so.*
+%{_libdir}/libbat*.so.*
 
+%if %{without compat}
 %package devel
 Summary: MonetDB development files
 Group: Applications/Databases
@@ -202,8 +209,9 @@ functionality of MonetDB.
 %{_includedir}/monetdb/mstring.h
 %exclude %{_includedir}/monetdb/monetdbe.h
 %{_includedir}/monetdb/monet*.h
-%{_libdir}/libbat.so
+%{_libdir}/libbat*.so
 %{_libdir}/pkgconfig/monetdb-gdk.pc
+%endif
 
 %package stream
 Summary: MonetDB stream library
@@ -223,8 +231,9 @@ various other components.
 %files stream
 %license COPYING
 

MonetDB: check - disallow arbitrary subqueries in CHECK constraints

2024-05-17 Thread Yunus Koning via checkin-list
Changeset: 3f4075dc2680 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/3f4075dc2680
Modified Files:
sql/server/rel_rel.h
sql/server/rel_schema.c
sql/server/rel_select.c
sql/test/2024/Tests/check.test
Branch: check
Log Message:

disallow arbitrary subqueries in CHECK constraints


diffs (67 lines):

diff --git a/sql/server/rel_rel.h b/sql/server/rel_rel.h
--- a/sql/server/rel_rel.h
+++ b/sql/server/rel_rel.h
@@ -35,6 +35,7 @@
 #define psm_call (1 << 15) //ORed
 #define sql_or   (1 << 16) //ORed
 #define sql_merge(1 << 17) //ORed
+#define sql_no_subquery  (1 << 18) //ORed
 
 #define is_sql_from(X) ((X & sql_from) == sql_from)
 #define is_sql_where(X)((X & sql_where) == sql_where)
@@ -54,6 +55,7 @@
 #define is_psm_call(X) ((X & psm_call) == psm_call)
 #define is_sql_or(X)   ((X & sql_or) == sql_or)
 #define is_sql_merge(X)((X & sql_merge) == sql_merge)
+#define is_sql_no_subquery(X)  ((X & sql_no_subquery) == sql_no_subquery)
 
 #define is_anyequal_func(sf) (strcmp((sf)->func->base.name, "sql_anyequal") == 
0 || strcmp((sf)->func->base.name, "sql_not_anyequal") == 0)
 #define is_anyequal(sf) (strcmp((sf)->func->base.name, "sql_anyequal") == 0)
diff --git a/sql/server/rel_schema.c b/sql/server/rel_schema.c
--- a/sql/server/rel_schema.c
+++ b/sql/server/rel_schema.c
@@ -22,6 +22,7 @@
 #include "rel_psm.h"
 #include "rel_dump.h"
 #include "rel_propagate.h"
+#include "rel_unnest.h"
 #include "sql_parser.h"
 #include "sql_privileges.h"
 #include "sql_partition.h"
@@ -409,8 +410,8 @@ sql_rel* create_check_plan(sql_query *qu
mvc *sql = query->sql;
exp_kind ek = {type_value, card_value, FALSE};
sql_rel* rel = rel_basetable(sql, t, t->base.name);
-   sql_exp *e = rel_logical_value_exp(query, , s->data.sym, sql_sel, 
ek);
-   rel->exps = rel_base_projection(sql, rel, 0);
+   sql_exp *e = rel_logical_value_exp(query, , s->data.sym, sql_sel | 
sql_no_subquery, ek);
+   rel->exps = rel_base_projection(sql, rel, 0);   
list *pexps = sa_list(sql->sa);
pexps = append(pexps, e);
rel = rel_project(sql->sa, rel, pexps);
diff --git a/sql/server/rel_select.c b/sql/server/rel_select.c
--- a/sql/server/rel_select.c
+++ b/sql/server/rel_select.c
@@ -4988,6 +4988,9 @@ rel_value_exp2(sql_query *query, sql_rel
assert(se->token == SQL_SELECT);
exp_kind nek = ek;
nek.aggr = is_sql_aggr(f);
+   if (is_sql_no_subquery(f))
+   return sql_error(sql, 02, SQLSTATE(42000) 
"SELECT: subquery not allowed");
+
r = rel_subquery(query, se, nek);
}
if (rel && *rel) {
diff --git a/sql/test/2024/Tests/check.test b/sql/test/2024/Tests/check.test
--- a/sql/test/2024/Tests/check.test
+++ b/sql/test/2024/Tests/check.test
@@ -33,3 +33,9 @@ update bar set i = 50 where i = 30
 
 statement error
 update bar set i = 50, j = 40 where i = 30
+
+statement error
+create table baz(j int check (j > (select max(i) from foo)))
+
+statement error
+create table baz(j int check (j in (select i from foo)))
___
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org


MonetDB: check - merge with default

2024-04-30 Thread Yunus Koning via checkin-list
Changeset: 17c946f67a6a for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/17c946f67a6a
Modified Files:
sql/backends/monet5/rel_bin.c
sql/include/sql_catalog.h
sql/server/sql_parser.y
sql/storage/store.c
Branch: check
Log Message:

merge with default


diffs (truncated from 979 to 300 lines):

diff --git a/gdk/gdk_bbp.c b/gdk/gdk_bbp.c
--- a/gdk/gdk_bbp.c
+++ b/gdk/gdk_bbp.c
@@ -1711,6 +1711,9 @@ BBPjson_upgrade(json_storage_conversion 
const char *nme;
 
nme = ATOMunknown_name(b->ttype);
+   int tt = ATOMindex(nme);
+   if (tt >= 0)
+   b->ttype = tt;
if (strcmp(nme, "json") != 0)
continue;
} else if (b->ttype != JSON_type) {
@@ -4065,34 +4068,41 @@ BBPsync(int cnt, bat *restrict subcommit
if (lock)
MT_lock_set((bid));
}
-   if (subcommit) {
+   BAT *b = BBP_desc(bid);
+   if (subcommit && b->ttype != TYPE_void) {
/* move any tail/theap files we find for this bat that
 * are in the BACKUP directory to the SUBCOMMIT
 * directory */
char fname[16]; /* plenty big enough */
-   if (snprintf(fname, sizeof(fname), "%o", i) < 16) {
+   if (snprintf(fname, sizeof(fname), "%o", (unsigned) 
bid) < 16) {
/* the snprintf never fails, any of the
 * below may fail */
-   if (GDKmove(0, BAKDIR, fname, "tail", SUBDIR, 
fname, "tail", false) == GDK_SUCCEED)
-   TRC_DEBUG(BAT_, "moved %s.tail from %s 
to %s\n",
+   uint8_t stpe = ATOMstorage(b->ttype);
+   if ((b->ttype != TYPE_str || b->twidth >= 8) &&
+   GDKmove(0, BAKDIR, fname, "tail", SUBDIR, 
fname, "tail", false) == GDK_SUCCEED)
+   TRC_DEBUG(IO_, "moved %s.tail from %s 
to %s\n",
  fname, BAKDIR, SUBDIR);
-   if (GDKmove(0, BAKDIR, fname, "tail1", SUBDIR, 
fname, "tail1", false) == GDK_SUCCEED)
-   TRC_DEBUG(BAT_, "moved %s.tail1 from %s 
to %s\n",
+   if (stpe == TYPE_str &&
+   GDKmove(0, BAKDIR, fname, "tail1", SUBDIR, 
fname, "tail1", false) == GDK_SUCCEED)
+   TRC_DEBUG(IO_, "moved %s.tail1 from %s 
to %s\n",
  fname, BAKDIR, SUBDIR);
-   if (GDKmove(0, BAKDIR, fname, "tail2", SUBDIR, 
fname, "tail2", false) == GDK_SUCCEED)
-   TRC_DEBUG(BAT_, "moved %s.tail2 from %s 
to %s\n",
+   if (stpe == TYPE_str && b->twidth >= 2 &&
+   GDKmove(0, BAKDIR, fname, "tail2", SUBDIR, 
fname, "tail2", false) == GDK_SUCCEED)
+   TRC_DEBUG(IO_, "moved %s.tail2 from %s 
to %s\n",
  fname, BAKDIR, SUBDIR);
 #if SIZEOF_VAR_T == 8
-   if (GDKmove(0, BAKDIR, fname, "tail4", SUBDIR, 
fname, "tail4", false) == GDK_SUCCEED)
-   TRC_DEBUG(BAT_, "moved %s.tail4 from %s 
to %s\n",
+   if (stpe == TYPE_str && b->twidth >= 4 &&
+   GDKmove(0, BAKDIR, fname, "tail4", SUBDIR, 
fname, "tail4", false) == GDK_SUCCEED)
+   TRC_DEBUG(IO_, "moved %s.tail4 from %s 
to %s\n",
  fname, BAKDIR, SUBDIR);
 #endif
-   if (GDKmove(0, BAKDIR, fname, "theap", SUBDIR, 
fname, "theap", false) == GDK_SUCCEED)
-   TRC_DEBUG(BAT_, "moved %s.theap from %s 
to %s\n",
+   if (ATOMvarsized(b->ttype) &&
+   GDKmove(0, BAKDIR, fname, "theap", SUBDIR, 
fname, "theap", false) == GDK_SUCCEED)
+   TRC_DEBUG(IO_, "moved %s.theap from %s 
to %s\n",
  fname, BAKDIR, SUBDIR);
}
}
-   BAT *b = dirty_bat(, subcommit != NULL);
+   b = dirty_bat(, subcommit != NULL);
if (i <= 0)
ret = GDK_FAIL;
else if (BBP_status(bid) & BBPEXISTING &&
diff --git a/sql/backends/monet5/rel_bin.c b/sql/backends/monet5/rel_bin.c
--- 

MonetDB: check - implement check constraint for partial row update

2024-04-30 Thread Yunus Koning via checkin-list
Changeset: 5033a4523f7b for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/5033a4523f7b
Modified Files:
sql/backends/monet5/rel_bin.c
sql/test/2024/Tests/check.test
Branch: check
Log Message:

implement check constraint for partial row update


diffs (99 lines):

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
@@ -5917,17 +5917,42 @@ sql_update_triggers(backend *be, sql_tab
 }
 
 static void
-sql_update_check(backend *be, sql_key * key, sql_rel *rupdates, list *refs)
+sql_update_check(backend *be, sql_key * key, sql_rel *updates, list *refs)
 {
-   /*  TODO: this won't work for general table check constraints involving 
updates to a strict subset of check columns*/
mvc *sql = be->mvc;
+   int pos = 0;
+   sql_rel* rel = rel_read(sql, sa_strdup(sql->sa, key->check), , 
sa_list(sql->sa));
+   sql_rel* base = rel->l;
+   assert(strcmp(((sql_exp*) updates->exps->h->data)->alias.name, TID) == 
0);
+   list_append(base->exps, exp_copy(sql, updates->exps->h->data));
+
+   bool need_join = 0;
+   list* pexps = sa_list(sql->sa);
+   sql_exp* tid_exp = exp_copy(sql, updates->exps->h->data);
+   unsigned label = ++sql->label;
+   exp_setrelname(sql->sa, tid_exp, label);
+   list_append(pexps, tid_exp);
+   for (node* m = base->exps->h; m; m = m->next) {
+   if (exps_find_exp( updates->exps, m->data) == NULL) {
+   pexps = list_append(pexps, exp_copy(sql, m->data));
+   need_join = 1;
+   }
+   }
+
+   if (need_join) {
+   base = rel_project(sql->sa, base, pexps);
+   sql_rel* join = rel_crossproduct(sql->sa, base, updates, 
op_join);
+   sql_exp* join_cond = exp_compare(sql->sa, exp_ref(sql, 
base->exps->h->data), exp_ref(sql, updates->exps->h->data), cmp_equal);
+   join->exps = sa_list(sql->sa);
+   join->exps = list_append(join->exps, join_cond);
+   rel->l = join;
+   }
+   else {
+   rel->l = updates;
+   }
+
sql_subfunc *cnt = sql_bind_func(sql, "sys", "count", 
sql_bind_localtype("void"), NULL, F_AGGR, true, true);
sql_subtype *bt = sql_bind_localtype("bit");
-
-
-   int pos = 0;
-   sql_rel* rel = rel_read(sql, sa_strdup(sql->sa, key->check), , 
sa_list(sql->sa));
-   rel->l = rupdates;
stmt* s = subrel_bin(be, rel, refs);
s = stmt_uselect(be, column(be, s), stmt_atom(be, 
atom_zero_value(sql->sa, bt)), cmp_equal, NULL, 0, 1);
s = stmt_aggr(be, s, NULL, NULL, cnt, 1, 0, 1);
diff --git a/sql/test/2024/Tests/check.test b/sql/test/2024/Tests/check.test
--- a/sql/test/2024/Tests/check.test
+++ b/sql/test/2024/Tests/check.test
@@ -1,20 +1,35 @@
 statement ok
-create table bar (i int, j int CHECK (j > 0));
+create table foo (i int CHECK (i > 0), j int CHECK (j > 0))
 
 statement ok
-insert into bar values (1,10), (2, 20), (3, 30);
+insert into foo values (1,10), (2, 20), (3, 30)
 
 statement error
-update bar set j = -30 where i = 3;
+update foo set j = -30 where i = 3
+
+statement error
+update foo set j = -j
 
 statement error
-update bar set j = -j;
+insert into foo values (4, -40)
+
+statement ok
+insert into foo select * from foo
 
 statement error
-insert into bar values (4, -40);
+insert into foo select 4, -40
 
 statement ok
-insert into bar select * from bar
+create table bar (i int, j int, constraint check_i_j CHECK (i < j))
 
 statement error
-insert into bar select 4, -40;
+insert into bar values (30, 20)
+
+statement ok
+insert into bar values (10,20), (20, 30), (30, 40)
+
+statement error
+update bar set i = 50 where i = 30
+
+statement error
+update bar set i = 50, j = 40 where i = 30
___
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org


MonetDB: check - merge with default

2024-04-26 Thread Yunus Koning via checkin-list
Changeset: c14db874309b for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/c14db874309b
Branch: check
Log Message:

merge with default


diffs (288 lines):

diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml
--- a/.github/workflows/linux.yml
+++ b/.github/workflows/linux.yml
@@ -48,7 +48,12 @@ jobs:
   ref: ${{ github.ref }}
 
   - name: install pymonetdb cryptography
-run: pip3 install pymonetdb cryptography
+run: pip3 install --user --upgrade pymonetdb cryptography
+if: runner.os != 'macOS'
+
+  - name: install pymonetdb cryptography
+run: pip3 install --user --break-system-packages --upgrade pymonetdb 
cryptography
+if: runner.os == 'macOS'
 
   - name: make MonetDB on linux
 run: |
@@ -83,7 +88,23 @@ jobs:
 -DBISON_EXECUTABLE=/usr/local/opt/bison/bin/bison \
 -DCMAKE_SUMMARY=ON
   make install -j3
-if: runner.os == 'macOS'
+if: runner.os == 'macOS' && runner.arch == 'x64'
+
+  - name: make MonetDB on macos
+run: |
+  mkdir build
+  cd build 
+  cmake .. \
+-DCMAKE_INSTALL_PREFIX=$HOME/MDB \
+-DPY3INTEGRATION=OFF \
+-DRINTEGRATION=OFF  \
+-DCMAKE_BUILD_TYPE=Release \
+-DASSERT=OFF \
+-DCMAKE_C_COMPILER=${{ matrix.c_compiler }} \
+-DBISON_EXECUTABLE=/opt/homebrew/opt/bison/bin/bison \
+-DCMAKE_SUMMARY=ON
+  make install -j3
+if: runner.os == 'macOS' && runner.arch == 'arm64'
 
   - name: choco packages
 run: |
diff --git a/clients/odbc/driver/SQLConnect.c b/clients/odbc/driver/SQLConnect.c
--- a/clients/odbc/driver/SQLConnect.c
+++ b/clients/odbc/driver/SQLConnect.c
@@ -251,7 +251,7 @@ MNDBConnect(ODBCDbc *dbc,
}
if (mid == NULL || mapi_error(mid)) {
/* Client unable to establish connection */
-   addDbcError(dbc, "08001", NULL, 0);
+   addDbcError(dbc, "08001", mid ? mapi_error_str(mid) : NULL, 0);
rc = SQL_ERROR;
/* clean up */
if (mid)
diff --git a/gdk/gdk_bbp.c b/gdk/gdk_bbp.c
--- a/gdk/gdk_bbp.c
+++ b/gdk/gdk_bbp.c
@@ -4065,6 +4065,33 @@ BBPsync(int cnt, bat *restrict subcommit
if (lock)
MT_lock_set((bid));
}
+   if (subcommit) {
+   /* move any tail/theap files we find for this bat that
+* are in the BACKUP directory to the SUBCOMMIT
+* directory */
+   char fname[16]; /* plenty big enough */
+   if (snprintf(fname, sizeof(fname), "%o", i) < 16) {
+   /* the snprintf never fails, any of the
+* below may fail */
+   if (GDKmove(0, BAKDIR, fname, "tail", SUBDIR, 
fname, "tail", false) == GDK_SUCCEED)
+   TRC_DEBUG(BAT_, "moved %s.tail from %s 
to %s\n",
+ fname, BAKDIR, SUBDIR);
+   if (GDKmove(0, BAKDIR, fname, "tail1", SUBDIR, 
fname, "tail1", false) == GDK_SUCCEED)
+   TRC_DEBUG(BAT_, "moved %s.tail1 from %s 
to %s\n",
+ fname, BAKDIR, SUBDIR);
+   if (GDKmove(0, BAKDIR, fname, "tail2", SUBDIR, 
fname, "tail2", false) == GDK_SUCCEED)
+   TRC_DEBUG(BAT_, "moved %s.tail2 from %s 
to %s\n",
+ fname, BAKDIR, SUBDIR);
+#if SIZEOF_VAR_T == 8
+   if (GDKmove(0, BAKDIR, fname, "tail4", SUBDIR, 
fname, "tail4", false) == GDK_SUCCEED)
+   TRC_DEBUG(BAT_, "moved %s.tail4 from %s 
to %s\n",
+ fname, BAKDIR, SUBDIR);
+#endif
+   if (GDKmove(0, BAKDIR, fname, "theap", SUBDIR, 
fname, "theap", false) == GDK_SUCCEED)
+   TRC_DEBUG(BAT_, "moved %s.theap from %s 
to %s\n",
+ fname, BAKDIR, SUBDIR);
+   }
+   }
BAT *b = dirty_bat(, subcommit != NULL);
if (i <= 0)
ret = GDK_FAIL;
diff --git a/monetdb5/modules/mal/pcre.c b/monetdb5/modules/mal/pcre.c
--- a/monetdb5/modules/mal/pcre.c
+++ b/monetdb5/modules/mal/pcre.c
@@ -733,6 +733,7 @@ single_replace(pcre *pcre_code, pcre_ext
int offset = 0;
int len_result = 0;
int addlen;
+   int empty_match_correction = 0;
char *tmp;
 
do {
@@ -740,7 +741,12 @@ single_replace(pcre *pcre_code, pcre_ext
  

MonetDB: check - allow table level CHECK constraints

2024-04-26 Thread Yunus Koning via checkin-list
Changeset: 874eec5ec066 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/874eec5ec066
Modified Files:
sql/server/rel_schema.c
Branch: check
Log Message:

allow table level CHECK constraints


diffs (83 lines):

diff --git a/sql/server/rel_schema.c b/sql/server/rel_schema.c
--- a/sql/server/rel_schema.c
+++ b/sql/server/rel_schema.c
@@ -404,17 +404,17 @@ key_type token2key_type(int token) {
 }
 
 static
-str serialize_check_plan(sql_query *query, symbol *s, sql_table *t) {
+sql_rel* create_check_plan(sql_query *query, symbol *s, sql_table *t) {
 
mvc *sql = query->sql;
exp_kind ek = {type_value, card_value, FALSE};
sql_rel* rel = rel_basetable(sql, t, t->base.name);
sql_exp *e = rel_logical_value_exp(query, , s->data.sym, sql_sel, 
ek);
+   rel->exps = rel_base_projection(sql, rel, 0);
list *pexps = sa_list(sql->sa);
pexps = append(pexps, e);
rel = rel_project(sql->sa, rel, pexps);
-   str check = rel2str(sql, rel);
-   return check;
+   return rel;
 }
 
 static int
@@ -460,9 +460,12 @@ column_constraint_type(sql_query *query,
}
char* check = NULL;
if (kt == ckey) {
-   if ((check = serialize_check_plan(query, s, t)) == 
NULL) {
+   sql_rel* check_rel = NULL;
+   if ((check_rel = create_check_plan(query, s, t)) == 
NULL) {
/*TODO error*/
}
+
+   check = rel2str(sql, check_rel);
}
switch (mvc_create_ukey(, sql, t, name, kt, check)) {
case -1:
@@ -929,10 +932,13 @@ table_constraint_type(sql_query *query, 
return SQL_ERR;
}
char* check = NULL;
+   sql_rel* check_rel = NULL;
if (kt == ckey) {
-   if ((check = serialize_check_plan(query, s, t)) == 
NULL) {
+   if ((check_rel = create_check_plan(query, s, t)) == 
NULL) {
/*TODO error*/
}
+
+   check = rel2str(sql, check_rel);
}
 
switch (mvc_create_ukey(, sql, t, name, kt, check)) {
@@ -946,9 +952,26 @@ table_constraint_type(sql_query *query, 
default:
break;
}
-   /* TODO: iterate over all columns in case of CHECK constraint*/
-   for (; nms; nms = nms->next) {
-   char *nm = nms->data.sval;
+   node* n = NULL;
+   if (check) {
+   sql_rel* btrel = check_rel->l;
+   n = btrel->exps->h;
+   }
+   while (true) {
+   const char *nm;
+   if (check) {
+   if (!n)
+   break;
+   sql_exp* e = n->data;
+   nm = e->alias.name;
+   n = n->next;
+   }
+   else {
+   if (!nms)
+   break;
+   nm = nms->data.sval;
+   nms = nms->next;
+   }
sql_column *c = mvc_bind_column(sql, t, nm);
 
if (!c) {
___
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org


MonetDB: distinct_from - close branch

2024-04-25 Thread Yunus Koning via checkin-list
Changeset: dae1be24896b for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/dae1be24896b
Branch: distinct_from
Log Message:

close branch

___
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

2024-04-25 Thread Yunus Koning via checkin-list
Changeset: 9e5dc56e1f8e for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/9e5dc56e1f8e
Branch: default
Log Message:

merge with distinct_from

___
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org


MonetDB: distinct_from - merge default

2024-04-25 Thread Yunus Koning via checkin-list
Changeset: bafc6c5e0f97 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/bafc6c5e0f97
Branch: distinct_from
Log Message:

merge default


diffs (truncated from 176299 to 300 lines):

diff --git a/.hgtags b/.hgtags
--- a/.hgtags
+++ b/.hgtags
@@ -823,3 +823,5 @@ 1230526af30f40eeea30fb87c47c3e414920561f
 95d8feaa1167b5ba87bd99253c3f4e62ebf528a1 Dec2023_3
 dcc8c702e685a4faf21ccf663028d1bc3d1165d1 Dec2023_5
 dcc8c702e685a4faf21ccf663028d1bc3d1165d1 Dec2023_SP1_release
+d656785f49ee62c19705722aa6b7c171904c64d5 Dec2023_7
+d656785f49ee62c19705722aa6b7c171904c64d5 Dec2023_SP2_release
diff --git a/MonetDB.spec b/MonetDB.spec
--- a/MonetDB.spec
+++ b/MonetDB.spec
@@ -91,7 +91,7 @@ Group: Applications/Databases
 License: MPL-2.0
 URL: https://www.monetdb.org/
 BugURL: https://github.com/MonetDB/MonetDB/issues
-Source: 
https://www.monetdb.org/downloads/sources/Dec2023-SP1/%{name}-%{version}.tar.bz2
+Source: 
https://www.monetdb.org/downloads/sources/Dec2023-SP2/%{name}-%{version}.tar.bz2
 
 # The Fedora packaging document says we need systemd-rpm-macros for
 # the _unitdir and _tmpfilesdir macros to exist; however on RHEL 7
@@ -151,7 +151,6 @@ BuildRequires: pkgconfig(libR)
 # BuildRequires: pkgconfig(gdal)# -DSHP=ON
 # BuildRequires: pkgconfig(netcdf)  # -DNETCDF=ON
 # BuildRequires: pkgconfig(proj)# -DWITH_PROJ=ON
-# BuildRequires: pkgconfig(snappy)  # -DWITH_SNAPPY=ON
 # BuildRequires: pkgconfig(valgrind)# -DWITH_VALGRIND=ON
 
 %if (0%{?fedora} >= 22)
@@ -679,7 +678,6 @@ This package contains files needed to de
 
 %files SQL-server5-devel
 %defattr(-,root,root)
-%{_includedir}/monetdb/exception_buffer.h
 %{_includedir}/monetdb/opt_backend.h
 %{_includedir}/monetdb/rel_*.h
 %{_includedir}/monetdb/sql*.h
@@ -808,9 +806,7 @@ do
   /usr/sbin/semodule -s ${selinuxvariant} -i \
 %{_datadir}/selinux/${selinuxvariant}/monetdb.pp &> /dev/null || :
 done
-# use /var/run/monetdb since that's what it says in the monetdb.fc file
-# it says that because /run/monetdb for some reason doesn't work
-/sbin/restorecon -R %{_localstatedir}/monetdb5 %{_localstatedir}/log/monetdb 
/var/run/monetdb %{_bindir}/monetdbd %{_bindir}/mserver5 
%{_unitdir}/monetdbd.service &> /dev/null || :
+/sbin/restorecon -R %{_localstatedir}/monetdb5 %{_localstatedir}/log/monetdb 
%{_rundir}/monetdb %{_bindir}/monetdbd %{_bindir}/mserver5 
%{_unitdir}/monetdbd.service &> /dev/null || :
 /usr/bin/systemctl try-restart monetdbd.service
 
 %postun selinux
@@ -839,6 +835,13 @@ fi
 %setup -q
 
 %build
+# from Fedora 40, selinux uses /run where before it used /var/run
+# the code is now for Fedora 40 but needs a patch for older versions
+%if (0%{?fedora} < 40)
+sed -i 
's;@CMAKE_INSTALL_FULL_RUNSTATEDIR@/monetdb;@CMAKE_INSTALL_FULL_LOCALSTATEDIR@/run/monetdb;'
 misc/selinux/monetdb.fc.in
+sed -i 's/1\.2/1.1/' misc/selinux/monetdb.te
+%endif
+
 %cmake3 \
 -DCMAKE_INSTALL_RUNSTATEDIR=/run \
 -DRELEASE_VERSION=ON \
@@ -864,7 +867,6 @@ fi
 -DWITH_PCRE=ON \
 -DWITH_PROJ=OFF \
 -DWITH_READLINE=ON \
--DWITH_SNAPPY=OFF \
 -DWITH_VALGRIND=OFF \
 -DWITH_XML2=ON \
 -DWITH_ZLIB=ON
@@ -891,9 +893,6 @@ install -d -m 0775 %{buildroot}%{_locals
 install -d -m 0775 %{buildroot}%{_rundir}/monetdb
 
 # remove unwanted stuff
-# .la files
-rm -f %{buildroot}%{_libdir}/*.la
-rm -f %{buildroot}%{_libdir}/monetdb5/*.la
 rm -f %{buildroot}%{_libdir}/monetdb5/lib_opt_sql_append.so
 rm -f %{buildroot}%{_libdir}/monetdb5/lib_microbenchmark*.so
 rm -f %{buildroot}%{_libdir}/monetdb5/lib_udf*.so
@@ -917,6 +916,31 @@ fi
 %endif
 
 %changelog
+* Tue Apr 09 2024 Sjoerd Mullender  - 11.49.7-20240409
+- Rebuilt.
+- GH#7469: Crash when using `CONTAINS`
+- GH#7479: MonetDB server crashes in `exp_ref`
+- GH#7490: commonTerms optimizer no longer works
+- GH#7495: Crash when simultaneously querying and updating a string column.
+
+* Thu Mar 28 2024 Sjoerd Mullender  - 11.49.7-20240409
+- gdk: Threads have their own list of free bats.  The list was not returned
+  to the system when a thread exited, meaning that the free bats that
+  were in the list would not be reused by any thread.  This has been
+  fixed.
+
+* Tue Mar 19 2024 Sjoerd Mullender  - 11.49.7-20240409
+- monetdb5: Fixed interaction between mserver5 and remote mserver5 when only 
one
+  of the two has 128 bit integer support.
+
+* Tue Mar 19 2024 Sjoerd Mullender  - 11.49.7-20240409
+- sql: Fixed issue where equal column aliases were created. When those
+  aliases were parsed on the remote side it could give crashes.
+
+* Mon Mar 18 2024 Sjoerd Mullender  - 11.49.7-20240409
+- gdk: Fixed a couple of deadlock situations, one actually observed, one
+  never observed.
+
 * Tue Mar 12 2024 Sjoerd Mullender  - 11.49.5-20240312
 - Rebuilt.
 - GH#7390: Some MonetDB Server crashes found
diff --git a/NT/mksqlwxs.py b/NT/mksqlwxs.py
--- a/NT/mksqlwxs.py
+++ b/NT/mksqlwxs.py
@@ -187,7 +187,7 @@ def main():
 print(r'')
 

MonetDB: check - merge with default

2024-04-24 Thread Yunus Koning via checkin-list
Changeset: 94f72926051f for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/94f72926051f
Modified Files:
sql/storage/store.c
Branch: check
Log Message:

merge with default


diffs (truncated from 1070 to 300 lines):

diff --git a/cmake/monetdb-defines.cmake b/cmake/monetdb-defines.cmake
--- a/cmake/monetdb-defines.cmake
+++ b/cmake/monetdb-defines.cmake
@@ -85,6 +85,7 @@ function(monetdb_configure_defines)
 check_symbol_exists("getopt_long" "getopt.h" HAVE_GETOPT_LONG)
   cmake_pop_check_state()
   check_function_exists("getrlimit" HAVE_GETRLIMIT)
+  check_function_exists("gettid" HAVE_GETTID)
   check_function_exists("gettimeofday" HAVE_GETTIMEOFDAY)
   check_function_exists("getuid" HAVE_GETUID)
   check_symbol_exists("gmtime_r" "time.h" HAVE_GMTIME_R)
diff --git a/common/utils/matomic.h b/common/utils/matomic.h
--- a/common/utils/matomic.h
+++ b/common/utils/matomic.h
@@ -18,7 +18,6 @@
  * The following operations are defined:
  * ATOMIC_VAR_INIT -- initializer for the variable (not necessarily atomic!);
  * ATOMIC_INIT -- initialize the variable (not necessarily atomic!);
- * ATOMIC_DESTROY -- destroy the variable
  * ATOMIC_GET -- return the value of a variable;
  * ATOMIC_SET -- set the value of a variable;
  * ATOMIC_XCG -- set the value of a variable, return original value;
@@ -114,7 +113,6 @@ typedef unsigned long ATOMIC_BASE_TYPE;
 #endif
 
 #define ATOMIC_INIT(var, val)  atomic_init(var, (ATOMIC_BASE_TYPE) (val))
-#define ATOMIC_DESTROY(var)((void) 0)
 #define ATOMIC_GET(var)((ATOMIC_BASE_TYPE) *(var))
 #define ATOMIC_SET(var, val)   (*(var) = (ATOMIC_BASE_TYPE) (val))
 #define ATOMIC_XCG(var, val)   atomic_exchange(var, (ATOMIC_BASE_TYPE) (val))
@@ -173,7 +171,6 @@ typedef __declspec(align(8)) volatile AT
 
 #define ATOMIC_VAR_INIT(val)   (val)
 #define ATOMIC_INIT(var, val)  (*(var) = (val))
-#define ATOMIC_DESTROY(var)((void) 0)
 
 #if SIZEOF_SIZE_T == 8
 
@@ -276,7 +273,6 @@ typedef volatile ATOMIC_BASE_TYPE ATOMIC
 
 #define ATOMIC_VAR_INIT(val)   (val)
 #define ATOMIC_INIT(var, val)  (*(var) = (val))
-#define ATOMIC_DESTROY(var)((void) 0)
 
 #define ATOMIC_GET(var)((ATOMIC_BASE_TYPE) 
__atomic_load_n(var, __ATOMIC_SEQ_CST))
 #define ATOMIC_SET(var, val)   __atomic_store_n(var, (ATOMIC_BASE_TYPE) (val), 
__ATOMIC_SEQ_CST)
diff --git a/gdk/gdk_align.c b/gdk/gdk_align.c
--- a/gdk/gdk_align.c
+++ b/gdk/gdk_align.c
@@ -258,6 +258,7 @@ BATmaterialize(BAT *b, BUN cap)
.farmid = BBPselectfarm(b->batRole, TYPE_oid, offheap),
.parentid = b->batCacheid,
.dirty = true,
+   .refs = ATOMIC_VAR_INIT(1),
};
settailname(tail, BBP_physical(b->batCacheid), TYPE_oid, 0);
if (HEAPalloc(tail, cap, sizeof(oid)) != GDK_SUCCEED) {
@@ -273,7 +274,6 @@ BATmaterialize(BAT *b, BUN cap)
for (p = 0; p < q; p++)
x[p] = t++;
}
-   ATOMIC_INIT(>refs, 1);
/* point of no return */
MT_lock_set(>theaplock);
assert((ATOMIC_GET(>theap->refs) & HEAPREFS) > 0);
diff --git a/gdk/gdk_bat.c b/gdk/gdk_bat.c
--- a/gdk/gdk_bat.c
+++ b/gdk/gdk_bat.c
@@ -74,6 +74,7 @@ BATcreatedesc(oid hseq, int tt, bool hea
*h = (Heap) {
.farmid = BBPselectfarm(role, tt, offheap),
.dirty = true,
+   .refs = ATOMIC_VAR_INIT(1),
};
 
if (ATOMneedheap(tt)) {
@@ -84,6 +85,7 @@ BATcreatedesc(oid hseq, int tt, bool hea
*vh = (Heap) {
.farmid = BBPselectfarm(role, tt, varheap),
.dirty = true,
+   .refs = ATOMIC_VAR_INIT(1),
};
}
}
@@ -124,13 +126,11 @@ BATcreatedesc(oid hseq, int tt, bool hea
 
if (bn->theap) {
bn->theap->parentid = bn->batCacheid;
-   ATOMIC_INIT(>theap->refs, 1);
const char *nme = BBP_physical(bn->batCacheid);
settailname(bn->theap, nme, tt, width);
 
if (bn->tvheap) {
bn->tvheap->parentid = bn->batCacheid;
-   ATOMIC_INIT(>tvheap->refs, 1);
strconcat_len(bn->tvheap->filename,
  sizeof(bn->tvheap->filename),
  nme, ".theap", NULL);
@@ -603,6 +603,7 @@ BATclear(BAT *b, bool force)
.parentid = b->tvheap->parentid,
.dirty = true,
.hasfile = b->tvheap->hasfile,
+   .refs = ATOMIC_VAR_INIT(1),
};
strcpy_len(th->filename, b->tvheap->filename, 
sizeof(th->filename));
if (ATOMheap(b->ttype, th, 0) != GDK_SUCCEED) {

MonetDB: check - serialize used columns

2024-04-24 Thread Yunus Koning via checkin-list
Changeset: d4f871ae47a4 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/d4f871ae47a4
Modified Files:
sql/server/rel_basetable.c
sql/server/rel_schema.c
Branch: check
Log Message:

serialize used columns


diffs (29 lines):

diff --git a/sql/server/rel_basetable.c b/sql/server/rel_basetable.c
--- a/sql/server/rel_basetable.c
+++ b/sql/server/rel_basetable.c
@@ -567,9 +567,9 @@ rel_base_dump_exps( stream *fout, sql_re
}
}
if (rel_base_is_used(ba, i)) {
-   mnstr_printf(fout, "%s\"%s\".\"%%TID\"", comma?", ":"", 
t->base.name);
+   mnstr_printf(fout, "%s\"%s\".\"%%TID%%\"", comma?", ":"", 
t->base.name);
if (ba->name)
-   mnstr_printf(fout, " as \"%s\".\"%%TID\"", ba->name);
+   mnstr_printf(fout, " as \"%s\".\"%%TID%%\"", ba->name);
comma = 1;
}
i++;
diff --git a/sql/server/rel_schema.c b/sql/server/rel_schema.c
--- a/sql/server/rel_schema.c
+++ b/sql/server/rel_schema.c
@@ -410,7 +410,9 @@ str serialize_check_plan(sql_query *quer
exp_kind ek = {type_value, card_value, FALSE};
sql_rel* rel = rel_basetable(sql, t, t->base.name);
sql_exp *e = rel_logical_value_exp(query, , s->data.sym, sql_sel, 
ek);
-   rel = rel_project_exp(sql, e);
+   list *pexps = sa_list(sql->sa);
+   pexps = append(pexps, e);
+   rel = rel_project(sql->sa, rel, pexps);
str check = rel2str(sql, rel);
return check;
 }
___
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org


MonetDB: check - iterate over all columns in table

2024-04-24 Thread Yunus Koning via checkin-list
Changeset: 5a15e450142e for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/5a15e450142e
Modified Files:
sql/backends/monet5/rel_bin.c
Branch: check
Log Message:

iterate over all columns in table


diffs (26 lines):

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
@@ -4931,12 +4931,10 @@ sql_insert_check(backend *be, sql_key *k
inserts = rel_copy(sql, inserts, 1);
list* exps = inserts->exps;
 
-   sql_subtype *bt = sql_bind_localtype("bit");
-
-   for (n = key->columns->h, m = exps->h; n && m;
+   for (n = ol_first_node(key->t->columns), m = exps->h; n && m;
n = n->next, m = m->next) {
sql_exp *i = m->data;
-   sql_column *c = ((sql_kc*) n->data)->c;
+   sql_column *c = n->data;
i->alias.rname= sa_strdup(sql->sa, c->t->base.name);
i->alias.name= sa_strdup(sql->sa, c->base.name);
}
@@ -4945,6 +4943,7 @@ sql_insert_check(backend *be, sql_key *k
sql_rel* rel = rel_read(sql, sa_strdup(sql->sa, key->check), , 
sa_list(sql->sa));
rel->l = inserts;
stmt* s = subrel_bin(be, rel, refs);
+   sql_subtype *bt = sql_bind_localtype("bit");
s = stmt_uselect(be, column(be, s), stmt_atom(be, 
atom_zero_value(sql->sa, bt)), cmp_equal, NULL, 0, 1);
sql_subfunc *cnt = sql_bind_func(sql, "sys", "count", 
sql_bind_localtype("void"), NULL, F_AGGR, true, true);
s = stmt_aggr(be, s, NULL, NULL, cnt, 1, 0, 1);
___
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org


MonetDB: check - merge with default

2024-04-23 Thread Yunus Koning via checkin-list
Changeset: b9e1b9936232 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/b9e1b9936232
Modified Files:
sql/server/sql_mvc.c
sql/storage/store.c
Branch: check
Log Message:

merge with default


diffs (truncated from 1294 to 300 lines):

diff --git a/.hgtags b/.hgtags
--- a/.hgtags
+++ b/.hgtags
@@ -824,3 +824,4 @@ 95d8feaa1167b5ba87bd99253c3f4e62ebf528a1
 dcc8c702e685a4faf21ccf663028d1bc3d1165d1 Dec2023_5
 dcc8c702e685a4faf21ccf663028d1bc3d1165d1 Dec2023_SP1_release
 d656785f49ee62c19705722aa6b7c171904c64d5 Dec2023_7
+d656785f49ee62c19705722aa6b7c171904c64d5 Dec2023_SP2_release
diff --git a/MonetDB.spec b/MonetDB.spec
--- a/MonetDB.spec
+++ b/MonetDB.spec
@@ -151,7 +151,6 @@ BuildRequires: pkgconfig(libR)
 # BuildRequires: pkgconfig(gdal)# -DSHP=ON
 # BuildRequires: pkgconfig(netcdf)  # -DNETCDF=ON
 # BuildRequires: pkgconfig(proj)# -DWITH_PROJ=ON
-# BuildRequires: pkgconfig(snappy)  # -DWITH_SNAPPY=ON
 # BuildRequires: pkgconfig(valgrind)# -DWITH_VALGRIND=ON
 
 %if (0%{?fedora} >= 22)
@@ -868,7 +867,6 @@ sed -i 's/1\.2/1.1/' misc/selinux/monetd
 -DWITH_PCRE=ON \
 -DWITH_PROJ=OFF \
 -DWITH_READLINE=ON \
--DWITH_SNAPPY=OFF \
 -DWITH_VALGRIND=OFF \
 -DWITH_XML2=ON \
 -DWITH_ZLIB=ON
@@ -895,9 +893,6 @@ install -d -m 0775 %{buildroot}%{_locals
 install -d -m 0775 %{buildroot}%{_rundir}/monetdb
 
 # remove unwanted stuff
-# .la files
-rm -f %{buildroot}%{_libdir}/*.la
-rm -f %{buildroot}%{_libdir}/monetdb5/*.la
 rm -f %{buildroot}%{_libdir}/monetdb5/lib_opt_sql_append.so
 rm -f %{buildroot}%{_libdir}/monetdb5/lib_microbenchmark*.so
 rm -f %{buildroot}%{_libdir}/monetdb5/lib_udf*.so
diff --git a/README.rst b/README.rst
--- a/README.rst
+++ b/README.rst
@@ -69,8 +69,8 @@ CINTEGRATIONEnable support for C
 CMAKE_SUMMARY   Show a summary of the cmake configuration (for debug 
purposes, default=OFF)
 CMAKE_UNITTESTS Build and run the unittest for the build system 
(default=OFF)
 FITSEnable support for FITS
-GEOMEnable support for geom module
-INT128  Enable support for 128-bit integers
+GEOMEnable support for geom module (using libgeos library)
+INT128  Enable support for 128-bit integers (if compiler supports 
them)
 NETCDF  Enable support for netcdf
 ODBCCompile the MonetDB ODBC driver
 PY3INTEGRATION  Enable support for Python 3 integration into MonetDB
@@ -82,7 +82,9 @@ TESTING Enable support for t
 WITH_BZ2Include bz2 support
 WITH_CMOCKA Include cmocka support (default=OFF)
 WITH_CURL   Include curl support
+WITH_LZ4Include lz4 support
 WITH_LZMA   Include lzma support
+WITH_OPENSSLInclude TLS support (secure client/server connection)
 WITH_PCRE   Include pcre support
 WITH_PROJ   Include proj support
 WITH_READLINE   Include readline support
@@ -98,27 +100,27 @@ On Fedora, the following packages are re
 ``bison``, ``cmake``, ``gcc``, ``pkgconf``, ``python3``.
 
 The following packages are optional but recommended:
-``bzip2-devel``, ``pcre-devel``, ``readline-devel``,
-``xz-devel``, ``zlib-devel``.
+``bzip2-devel``, ``lz4-devel``, ``openssl-devel``, ``pcre-devel``,
+``readline-devel``, ``xz-devel``, ``zlib-devel``.
 
 The following packages are optional:
 ``cfitsio-devel``, ``gdal-devel``, ``geos-devel``, ``libasan``,
-``libcurl-devel``, ``libxml2-devel``, ``netcdf-devel``, ``proj-devel``,
-``python3-devel``, ``python3-numpy``, ``R-core-devel``,
-``unixODBC-devel``, ``valgrind-devel``.
+``libcmocka-devel``, ``libcurl-devel``, ``libxml2-devel``,
+``netcdf-devel``, ``proj-devel``, ``python3-devel``, ``python3-numpy``,
+``R-core-devel``, ``unixODBC-devel``, ``valgrind-devel``.
 
 On Ubuntu and Debian the following packages are required:
 ``bison``, ``cmake``, ``gcc``, ``pkg-config``, ``python3``.
 
 The following packages are optional but recommended:
-``libbz2-dev``, ``libpcre3-dev``, ``libreadline-dev``,
-``liblzma-dev``, ``zlib1g-dev``.
+``libbz2-dev``, ``liblz4-dev``, ``libpcre3-dev``, ``libreadline-dev``,
+``liblzma-dev``, ``libssl-dev``, ``zlib1g-dev``.
 
 The following packages are optional:
-``libasan5``, ``libcfitsio-dev``, ``libcurl4-gnutls-dev``,
-``libgdal-dev``, ``libgeos-dev``, ``libnetcdf-dev``, ``libproj-dev``,
-``libxml2-dev``, ``python3-dev``, ``python3-numpy``, ``r-base-dev``,
-``unixodbc-dev``, ``valgrind``.
+``libasan5``, ``libcfitsio-dev``, ``libcmocka-dev``,
+``libcurl4-gnutls-dev``, ``libgdal-dev``, ``libgeos-dev``,
+``libnetcdf-dev``, ``libproj-dev``, ``libxml2-dev``, ``python3-dev``,
+``python3-numpy``, ``r-base-dev``, ``unixodbc-dev``, ``valgrind``.
 
 ``cmake`` must be at least version 3.12, ``python`` must be at least
 version 3.5.
diff --git a/clients/Tests/exports.stable.out b/clients/Tests/exports.stable.out
--- a/clients/Tests/exports.stable.out
+++ 

MonetDB: check - extend key_types table.

2024-04-23 Thread Yunus Koning via checkin-list
Changeset: 809397ccd000 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/809397ccd000
Modified Files:
sql/scripts/10_sys_schema_extension.sql
Branch: check
Log Message:

extend key_types table.


diffs (22 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
@@ -396,14 +396,16 @@ GRANT SELECT ON sys.function_languages T
 
 CREATE TABLE sys.key_types (
 key_type_id   SMALLINT NOT NULL PRIMARY KEY,
-key_type_name VARCHAR(15) NOT NULL UNIQUE);
+key_type_name VARCHAR(35) NOT NULL UNIQUE);
 
 -- Values taken from sql/include/sql_catalog.h see typedef enum
 -- key_type: pkey, ukey, fkey.
 INSERT INTO sys.key_types (key_type_id, key_type_name) VALUES
   (0, 'Primary Key'),
   (1, 'Unique Key'),
-  (2, 'Foreign Key');
+  (2, 'Foreign Key'),
+  (3, 'Unique Key With Nulls Not Distinct'),
+  (4, 'Check Constraint');
 
 ALTER TABLE sys.key_types SET READ ONLY;
 GRANT SELECT ON sys.key_types TO PUBLIC;
___
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org


MonetDB: check - implement CHECK constraint as a key type instea...

2024-04-23 Thread Yunus Koning via checkin-list
Changeset: 49dcdaff8bf0 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/49dcdaff8bf0
Modified Files:
sql/backends/monet5/rel_bin.c
sql/include/sql_catalog.h
sql/server/rel_schema.c
sql/server/sql_mvc.c
sql/server/sql_mvc.h
sql/server/sql_parser.y
sql/server/sql_partition.c
sql/storage/sql_storage.h
sql/storage/store.c
Branch: check
Log Message:

implement CHECK constraint as a key type instead of as a column property


diffs (truncated from 695 to 300 lines):

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
@@ -4923,7 +4923,7 @@ sql_insert_triggers(backend *be, sql_tab
 }
 
 static void
-sql_insert_check(backend *be, sql_table *t, sql_rel *inserts, list *refs)
+sql_insert_check(backend *be, sql_key *key, sql_rel *inserts, list *refs)
 {
mvc *sql = be->mvc;
node *m, *n;
@@ -4933,25 +4933,23 @@ sql_insert_check(backend *be, sql_table 
 
sql_subtype *bt = sql_bind_localtype("bit");
 
-   for (n = ol_first_node(t->columns), m = exps->h; n && m;
+   for (n = key->columns->h, m = exps->h; n && m;
n = n->next, m = m->next) {
sql_exp *i = m->data;
-   sql_column *c = n->data;
-   if (c->check) {
-   i->alias.rname= sa_strdup(sql->sa, t->base.name);
-   i->alias.name= sa_strdup(sql->sa, c->base.name);
-
-   int pos = 0;
-   sql_rel* rel = rel_read(sql, sa_strdup(sql->sa, 
c->check), , sa_list(sql->sa));
-   rel->l = inserts;
-   stmt* s = subrel_bin(be, rel, refs);
-   s = stmt_uselect(be, column(be, s), stmt_atom(be, 
atom_zero_value(sql->sa, bt)), cmp_equal, NULL, 0, 1);
-   sql_subfunc *cnt = sql_bind_func(sql, "sys", "count", 
sql_bind_localtype("void"), NULL, F_AGGR, true, true);
-   s = stmt_aggr(be, s, NULL, NULL, cnt, 1, 0, 1);
-   char *msg = sa_message(sql->sa, SQLSTATE(40002) "INSERT 
INTO: CHECK constraint violated for column %s.%s", c->t->base.name, 
c->base.name);
-   (void)stmt_exception(be, s, msg, 1);
-   }
-   }
+   sql_column *c = ((sql_kc*) n->data)->c;
+   i->alias.rname= sa_strdup(sql->sa, c->t->base.name);
+   i->alias.name= sa_strdup(sql->sa, c->base.name);
+   }
+
+   int pos = 0;
+   sql_rel* rel = rel_read(sql, sa_strdup(sql->sa, key->check), , 
sa_list(sql->sa));
+   rel->l = inserts;
+   stmt* s = subrel_bin(be, rel, refs);
+   s = stmt_uselect(be, column(be, s), stmt_atom(be, 
atom_zero_value(sql->sa, bt)), cmp_equal, NULL, 0, 1);
+   sql_subfunc *cnt = sql_bind_func(sql, "sys", "count", 
sql_bind_localtype("void"), NULL, F_AGGR, true, true);
+   s = stmt_aggr(be, s, NULL, NULL, cnt, 1, 0, 1);
+   char *msg = sa_message(sql->sa, SQLSTATE(40002) "INSERT INTO: CHECK 
constraint violated: %s", key->base.name);
+   (void)stmt_exception(be, s, msg, 1);
 }
 
 static sql_table *
@@ -5032,7 +5030,11 @@ rel2bin_insert(backend *be, sql_rel *rel
if (idx_ins)
pin = refs_find_rel(refs, prel);
 
-   sql_insert_check(be, t, rel->r, refs);
+   for (n = ol_first_node(t->keys); n; n = n->next) {
+   sql_key * key = n->data;
+   if (key->type == ckey)
+   sql_insert_check(be, key, rel->r, refs);
+   }
 
if (!sql_insert_check_null(be, t, inserts->op4.lval))
return NULL;
@@ -5916,28 +5918,22 @@ sql_update_triggers(backend *be, sql_tab
 }
 
 static void
-sql_update_check(backend *be, sql_table *t, sql_rel *rupdates, stmt **updates, 
list *refs)
+sql_update_check(backend *be, sql_key * key, sql_rel *rupdates, list *refs)
 {
+   /*  TODO: this won't work for general table check constraints involving 
updates to a strict subset of check columns*/
mvc *sql = be->mvc;
-   node *n;
sql_subfunc *cnt = sql_bind_func(sql, "sys", "count", 
sql_bind_localtype("void"), NULL, F_AGGR, true, true);
sql_subtype *bt = sql_bind_localtype("bit");
 
-   for (n = ol_first_node(t->columns); n; n = n->next) {
-   sql_column *c = n->data;
-
-   if (updates[c->colnr] && c->check) {
-
-   int pos = 0;
-   sql_rel* rel = rel_read(sql, sa_strdup(sql->sa, 
c->check), , sa_list(sql->sa));
-   rel->l = rupdates;
-   stmt* s = subrel_bin(be, rel, refs);
-   s = stmt_uselect(be, column(be, s), stmt_atom(be, 
atom_zero_value(sql->sa, bt)), cmp_equal, NULL, 0, 1);
-   s = stmt_aggr(be, s, NULL, NULL, cnt, 1, 0, 1);
-   char *msg = sa_message(sql->sa, SQLSTATE(40002) 

MonetDB: check - add tests for check constraint

2024-04-23 Thread Yunus Koning via checkin-list
Changeset: 7b5630309f11 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/7b5630309f11
Added Files:
sql/test/2024/Tests/check.test
Modified Files:
sql/test/2024/Tests/All
Branch: check
Log Message:

add tests for check constraint


diffs (32 lines):

diff --git a/sql/test/2024/Tests/All b/sql/test/2024/Tests/All
--- a/sql/test/2024/Tests/All
+++ b/sql/test/2024/Tests/All
@@ -1,2 +1,3 @@
 groupby_primary_key_project_unique_key
 distinct_from
+check
diff --git a/sql/test/2024/Tests/check.test b/sql/test/2024/Tests/check.test
new file mode 100644
--- /dev/null
+++ b/sql/test/2024/Tests/check.test
@@ -0,0 +1,20 @@
+statement ok
+create table bar (i int, j int CHECK (j > 0));
+
+statement ok
+insert into bar values (1,10), (2, 20), (3, 30);
+
+statement error
+update bar set j = -30 where i = 3;
+
+statement error
+update bar set j = -j;
+
+statement error
+insert into bar values (4, -40);
+
+statement ok
+insert into bar select * from bar
+
+statement error
+insert into bar select 4, -40;
___
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org


MonetDB: check - merge with default

2024-04-15 Thread Yunus Koning via checkin-list
Changeset: aad96fbaf536 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/aad96fbaf536
Modified Files:
sql/backends/monet5/rel_bin.c
sql/include/sql_catalog.h
sql/server/rel_schema.c
sql/server/sql_mvc.c
sql/storage/sql_storage.h
sql/storage/store.c
Branch: check
Log Message:

merge with default


diffs (truncated from 2471 to 300 lines):

diff --git a/clients/Tests/MAL-signatures.test 
b/clients/Tests/MAL-signatures.test
--- a/clients/Tests/MAL-signatures.test
+++ b/clients/Tests/MAL-signatures.test
@@ -25330,122 +25330,62 @@ SQLvar_pop;
 return the variance population of groups
 batsql
 window_bound
-pattern batsql.window_bound(X_0:bat[:any_1], X_1:int, X_2:int, X_3:int, 
X_4:bat[:bte]):bat[:oid]
-SQLwindow_bound;
-computes window ranges for each row
-batsql
-window_bound
-pattern batsql.window_bound(X_0:bat[:any_1], X_1:int, X_2:int, X_3:int, 
X_4:bat[:dbl]):bat[:oid]
+pattern batsql.window_bound(X_0:bat[:any_1], X_1:int, X_2:int, X_3:int, 
X_4:bat?[:bte]):bat[:oid]
 SQLwindow_bound;
 computes window ranges for each row
 batsql
 window_bound
-pattern batsql.window_bound(X_0:bat[:any_1], X_1:int, X_2:int, X_3:int, 
X_4:bat[:flt]):bat[:oid]
-SQLwindow_bound;
-computes window ranges for each row
-batsql
-window_bound
-pattern batsql.window_bound(X_0:bat[:any_1], X_1:int, X_2:int, X_3:int, 
X_4:bat[:int]):bat[:oid]
-SQLwindow_bound;
-computes window ranges for each row
-batsql
-window_bound
-pattern batsql.window_bound(X_0:bat[:any_1], X_1:int, X_2:int, X_3:int, 
X_4:bat[:lng]):bat[:oid]
+pattern batsql.window_bound(X_0:bat[:any_1], X_1:int, X_2:int, X_3:int, 
X_4:bat?[:dbl]):bat[:oid]
 SQLwindow_bound;
 computes window ranges for each row
 batsql
 window_bound
-pattern batsql.window_bound(X_0:bat[:any_1], X_1:int, X_2:int, X_3:int, 
X_4:bat[:sht]):bat[:oid]
-SQLwindow_bound;
-computes window ranges for each row
-batsql
-window_bound
-pattern batsql.window_bound(X_0:bat[:any_1], X_1:int, X_2:int, X_3:int, 
X_4:bte):bat[:oid]
+pattern batsql.window_bound(X_0:bat[:any_1], X_1:int, X_2:int, X_3:int, 
X_4:bat?[:flt]):bat[:oid]
 SQLwindow_bound;
 computes window ranges for each row
 batsql
 window_bound
-pattern batsql.window_bound(X_0:bat[:any_1], X_1:int, X_2:int, X_3:int, 
X_4:dbl):bat[:oid]
+pattern batsql.window_bound(X_0:bat[:any_1], X_1:int, X_2:int, X_3:int, 
X_4:bat?[:int]):bat[:oid]
 SQLwindow_bound;
 computes window ranges for each row
 batsql
 window_bound
-pattern batsql.window_bound(X_0:bat[:any_1], X_1:int, X_2:int, X_3:int, 
X_4:flt):bat[:oid]
-SQLwindow_bound;
-computes window ranges for each row
-batsql
-window_bound
-pattern batsql.window_bound(X_0:bat[:any_1], X_1:int, X_2:int, X_3:int, 
X_4:int):bat[:oid]
-SQLwindow_bound;
-computes window ranges for each row
-batsql
-window_bound
-pattern batsql.window_bound(X_0:bat[:any_1], X_1:int, X_2:int, X_3:int, 
X_4:lng):bat[:oid]
+pattern batsql.window_bound(X_0:bat[:any_1], X_1:int, X_2:int, X_3:int, 
X_4:bat?[:lng]):bat[:oid]
 SQLwindow_bound;
 computes window ranges for each row
 batsql
 window_bound
-pattern batsql.window_bound(X_0:bat[:any_1], X_1:int, X_2:int, X_3:int, 
X_4:sht):bat[:oid]
-SQLwindow_bound;
-computes window ranges for each row
-batsql
-window_bound
-pattern batsql.window_bound(X_0:bat[:bit], X_1:bat[:any_1], X_2:int, X_3:int, 
X_4:int, X_5:bat[:bte]):bat[:oid]
+pattern batsql.window_bound(X_0:bat[:any_1], X_1:int, X_2:int, X_3:int, 
X_4:bat?[:sht]):bat[:oid]
 SQLwindow_bound;
 computes window ranges for each row
 batsql
 window_bound
-pattern batsql.window_bound(X_0:bat[:bit], X_1:bat[:any_1], X_2:int, X_3:int, 
X_4:int, X_5:bat[:dbl]):bat[:oid]
+pattern batsql.window_bound(X_0:bat[:bit], X_1:bat[:any_1], X_2:int, X_3:int, 
X_4:int, X_5:bat?[:bte]):bat[:oid]
 SQLwindow_bound;
 computes window ranges for each row
 batsql
 window_bound
-pattern batsql.window_bound(X_0:bat[:bit], X_1:bat[:any_1], X_2:int, X_3:int, 
X_4:int, X_5:bat[:flt]):bat[:oid]
-SQLwindow_bound;
-computes window ranges for each row
-batsql
-window_bound
-pattern batsql.window_bound(X_0:bat[:bit], X_1:bat[:any_1], X_2:int, X_3:int, 
X_4:int, X_5:bat[:int]):bat[:oid]
-SQLwindow_bound;
-computes window ranges for each row
-batsql
-window_bound
-pattern batsql.window_bound(X_0:bat[:bit], X_1:bat[:any_1], X_2:int, X_3:int, 
X_4:int, X_5:bat[:lng]):bat[:oid]
+pattern batsql.window_bound(X_0:bat[:bit], X_1:bat[:any_1], X_2:int, X_3:int, 
X_4:int, X_5:bat?[:dbl]):bat[:oid]
 SQLwindow_bound;
 computes window ranges for each row
 batsql
 window_bound
-pattern batsql.window_bound(X_0:bat[:bit], X_1:bat[:any_1], X_2:int, X_3:int, 
X_4:int, X_5:bat[:sht]):bat[:oid]
-SQLwindow_bound;
-computes window ranges for each row
-batsql
-window_bound
-pattern batsql.window_bound(X_0:bat[:bit], X_1:bat[:any_1], X_2:int, X_3:int, 
X_4:int, X_5:bte):bat[:oid]
-SQLwindow_bound;
-computes window ranges for each row
-batsql
-window_bound
-pattern batsql.window_bound(X_0:bat[:bit], X_1:bat[:any_1], X_2:int, X_3:int, 
X_4:int, 

MonetDB: check - implement CHECK constraint for updates.

2024-04-15 Thread Yunus Koning via checkin-list
Changeset: 0bd4d7a4c899 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/0bd4d7a4c899
Modified Files:
sql/backends/monet5/rel_bin.c
Branch: check
Log Message:

implement CHECK constraint for updates.


diffs (43 lines):

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
@@ -5916,6 +5916,31 @@ sql_update_triggers(backend *be, sql_tab
 }
 
 static void
+sql_update_check(backend *be, sql_table *t, sql_rel *rupdates, stmt **updates, 
list *refs)
+{
+   mvc *sql = be->mvc;
+   node *n;
+   sql_subfunc *cnt = sql_bind_func(sql, "sys", "count", 
sql_bind_localtype("void"), NULL, F_AGGR, true, true);
+   sql_subtype *bt = sql_bind_localtype("bit");
+
+   for (n = ol_first_node(t->columns); n; n = n->next) {
+   sql_column *c = n->data;
+
+   if (updates[c->colnr] && c->check) {
+
+   int pos = 0;
+   sql_rel* rel = rel_read(sql, sa_strdup(sql->sa, 
c->check), , sa_list(sql->sa));
+   rel->l = rupdates;
+   stmt* s = subrel_bin(be, rel, refs);
+   s = stmt_uselect(be, column(be, s), stmt_atom(be, 
atom_zero_value(sql->sa, bt)), cmp_equal, NULL, 0, 1);
+   s = stmt_aggr(be, s, NULL, NULL, cnt, 1, 0, 1);
+   char *msg = sa_message(sql->sa, SQLSTATE(40002) 
"UPDATE: CHECK constraint violated for column %s.%s", c->t->base.name, 
c->base.name);
+   (void)stmt_exception(be, s, msg, 1);
+   }
+   }
+}
+
+static void
 sql_update_check_null(backend *be, sql_table *t, stmt **updates)
 {
mvc *sql = be->mvc;
@@ -6044,6 +6069,7 @@ rel2bin_update(backend *be, sql_rel *rel
if (c)
updates[c->colnr] = bin_find_column(be, update, ce->l, 
ce->r);
}
+   sql_update_check(be, t, rel->r, updates, refs);
sql_update_check_null(be, t, updates);
 
/* check keys + get idx */
___
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org


MonetDB: check - refactoring

2024-04-15 Thread Yunus Koning via checkin-list
Changeset: 53f601216841 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/53f601216841
Modified Files:
sql/backends/monet5/rel_bin.c
Branch: check
Log Message:

refactoring


diffs (37 lines):

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
@@ -4923,17 +4923,13 @@ sql_insert_triggers(backend *be, sql_tab
 }
 
 static void
-sql_insert_check(backend *be, sql_table *t, sql_rel *rel, list *refs)
+sql_insert_check(backend *be, sql_table *t, sql_rel *inserts, list *refs)
 {
mvc *sql = be->mvc;
node *m, *n;
 
-   sql_rel* rel2 = rel_copy(sql, rel, 1);
-
-   list* exps = rel2->exps;
-
-   sql_rel* rel3;
-
+   inserts = rel_copy(sql, inserts, 1);
+   list* exps = inserts->exps;
 
sql_subtype *bt = sql_bind_localtype("bit");
 
@@ -4946,9 +4942,9 @@ sql_insert_check(backend *be, sql_table 
i->alias.name= sa_strdup(sql->sa, c->base.name);
 
int pos = 0;
-   rel3 = rel_read(sql, sa_strdup(sql->sa, c->check), 
, sa_list(sql->sa));
-   rel3->l = rel2;
-   stmt* s = subrel_bin(be, rel3, refs);
+   sql_rel* rel = rel_read(sql, sa_strdup(sql->sa, 
c->check), , sa_list(sql->sa));
+   rel->l = inserts;
+   stmt* s = subrel_bin(be, rel, refs);
s = stmt_uselect(be, column(be, s), stmt_atom(be, 
atom_zero_value(sql->sa, bt)), cmp_equal, NULL, 0, 1);
sql_subfunc *cnt = sql_bind_func(sql, "sys", "count", 
sql_bind_localtype("void"), NULL, F_AGGR, true, true);
s = stmt_aggr(be, s, NULL, NULL, cnt, 1, 0, 1);
___
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org


MonetDB: check - merge with default

2024-04-15 Thread Yunus Koning via checkin-list
Changeset: 04574dd85264 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/04574dd85264
Modified Files:
sql/backends/monet5/rel_bin.c
sql/include/sql_catalog.h
sql/server/rel_schema.c
sql/server/sql_mvc.c
sql/server/sql_mvc.h
sql/server/sql_parser.y
sql/storage/sql_storage.h
sql/storage/store.c
Branch: check
Log Message:

merge with default


diffs (truncated from 175674 to 300 lines):

diff --git a/.hgtags b/.hgtags
--- a/.hgtags
+++ b/.hgtags
@@ -822,3 +822,5 @@ 1230526af30f40eeea30fb87c47c3e414920561f
 1230526af30f40eeea30fb87c47c3e414920561f Dec2023_release
 95d8feaa1167b5ba87bd99253c3f4e62ebf528a1 Dec2023_3
 dcc8c702e685a4faf21ccf663028d1bc3d1165d1 Dec2023_5
+dcc8c702e685a4faf21ccf663028d1bc3d1165d1 Dec2023_SP1_release
+d656785f49ee62c19705722aa6b7c171904c64d5 Dec2023_7
diff --git a/MonetDB.spec b/MonetDB.spec
--- a/MonetDB.spec
+++ b/MonetDB.spec
@@ -91,7 +91,7 @@ Group: Applications/Databases
 License: MPL-2.0
 URL: https://www.monetdb.org/
 BugURL: https://github.com/MonetDB/MonetDB/issues
-Source: 
https://www.monetdb.org/downloads/sources/Dec2023-SP1/%{name}-%{version}.tar.bz2
+Source: 
https://www.monetdb.org/downloads/sources/Dec2023-SP2/%{name}-%{version}.tar.bz2
 
 # The Fedora packaging document says we need systemd-rpm-macros for
 # the _unitdir and _tmpfilesdir macros to exist; however on RHEL 7
@@ -679,7 +679,6 @@ This package contains files needed to de
 
 %files SQL-server5-devel
 %defattr(-,root,root)
-%{_includedir}/monetdb/exception_buffer.h
 %{_includedir}/monetdb/opt_backend.h
 %{_includedir}/monetdb/rel_*.h
 %{_includedir}/monetdb/sql*.h
@@ -808,9 +807,7 @@ do
   /usr/sbin/semodule -s ${selinuxvariant} -i \
 %{_datadir}/selinux/${selinuxvariant}/monetdb.pp &> /dev/null || :
 done
-# use /var/run/monetdb since that's what it says in the monetdb.fc file
-# it says that because /run/monetdb for some reason doesn't work
-/sbin/restorecon -R %{_localstatedir}/monetdb5 %{_localstatedir}/log/monetdb 
/var/run/monetdb %{_bindir}/monetdbd %{_bindir}/mserver5 
%{_unitdir}/monetdbd.service &> /dev/null || :
+/sbin/restorecon -R %{_localstatedir}/monetdb5 %{_localstatedir}/log/monetdb 
%{_rundir}/monetdb %{_bindir}/monetdbd %{_bindir}/mserver5 
%{_unitdir}/monetdbd.service &> /dev/null || :
 /usr/bin/systemctl try-restart monetdbd.service
 
 %postun selinux
@@ -839,6 +836,13 @@ fi
 %setup -q
 
 %build
+# from Fedora 40, selinux uses /run where before it used /var/run
+# the code is now for Fedora 40 but needs a patch for older versions
+%if (0%{?fedora} < 40)
+sed -i 
's;@CMAKE_INSTALL_FULL_RUNSTATEDIR@/monetdb;@CMAKE_INSTALL_FULL_LOCALSTATEDIR@/run/monetdb;'
 misc/selinux/monetdb.fc.in
+sed -i 's/1\.2/1.1/' misc/selinux/monetdb.te
+%endif
+
 %cmake3 \
 -DCMAKE_INSTALL_RUNSTATEDIR=/run \
 -DRELEASE_VERSION=ON \
@@ -917,6 +921,31 @@ fi
 %endif
 
 %changelog
+* Tue Apr 09 2024 Sjoerd Mullender  - 11.49.7-20240409
+- Rebuilt.
+- GH#7469: Crash when using `CONTAINS`
+- GH#7479: MonetDB server crashes in `exp_ref`
+- GH#7490: commonTerms optimizer no longer works
+- GH#7495: Crash when simultaneously querying and updating a string column.
+
+* Thu Mar 28 2024 Sjoerd Mullender  - 11.49.7-20240409
+- gdk: Threads have their own list of free bats.  The list was not returned
+  to the system when a thread exited, meaning that the free bats that
+  were in the list would not be reused by any thread.  This has been
+  fixed.
+
+* Tue Mar 19 2024 Sjoerd Mullender  - 11.49.7-20240409
+- monetdb5: Fixed interaction between mserver5 and remote mserver5 when only 
one
+  of the two has 128 bit integer support.
+
+* Tue Mar 19 2024 Sjoerd Mullender  - 11.49.7-20240409
+- sql: Fixed issue where equal column aliases were created. When those
+  aliases were parsed on the remote side it could give crashes.
+
+* Mon Mar 18 2024 Sjoerd Mullender  - 11.49.7-20240409
+- gdk: Fixed a couple of deadlock situations, one actually observed, one
+  never observed.
+
 * Tue Mar 12 2024 Sjoerd Mullender  - 11.49.5-20240312
 - Rebuilt.
 - GH#7390: Some MonetDB Server crashes found
diff --git a/NT/mksqlwxs.py b/NT/mksqlwxs.py
--- a/NT/mksqlwxs.py
+++ b/NT/mksqlwxs.py
@@ -187,7 +187,7 @@ def main():
 print(r'')
 print(r'  ')
 id = comp(extend, id, 16,
-  sorted([r'include\monetdb\{}'.format(x) for x in filter(lambda 
x: (x.startswith('gdk') or x.startswith('monet') or x.startswith('mal') or 
x.startswith('sql') or x.startswith('rel') or x.startswith('store') or 
x.startswith('exception') or x.startswith('opt_backend')) and x.endswith('.h'), 
os.listdir(os.path.join(sys.argv[3], 'include', 'monetdb')))] +
+  sorted([r'include\monetdb\{}'.format(x) for x in filter(lambda 
x: (x.startswith('gdk') or x.startswith('monet') or x.startswith('mal') or 
x.startswith('sql') or x.startswith('rel') or x.startswith('store') or 
x.startswith('opt_backend')) and x.endswith('.h'), 

MonetDB: check - column CHECK condition on insert

2024-04-15 Thread Yunus Koning via checkin-list
Changeset: 4a1b36c42d20 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/4a1b36c42d20
Modified Files:
sql/backends/monet5/rel_bin.c
sql/server/rel_schema.c
Branch: check
Log Message:

column CHECK condition on insert


diffs (86 lines):

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
@@ -16,6 +16,7 @@
 #include "rel_rel.h"
 #include "rel_basetable.h"
 #include "rel_exp.h"
+#include "rel_dump.h"
 #include "rel_psm.h"
 #include "rel_prop.h"
 #include "rel_select.h"
@@ -4926,6 +4927,42 @@ sql_insert_triggers(backend *be, sql_tab
return res;
 }
 
+static void
+sql_insert_check(backend *be, sql_table *t, sql_rel *rel, list *refs)
+{
+   mvc *sql = be->mvc;
+   node *m, *n;
+
+   sql_rel* rel2 = rel_copy(sql, rel, 1);
+
+   list* exps = rel2->exps;
+
+   sql_rel* rel3;
+
+
+   sql_subtype *bt = sql_bind_localtype("bit");
+
+   for (n = ol_first_node(t->columns), m = exps->h; n && m;
+   n = n->next, m = m->next) {
+   sql_exp *i = m->data;
+   sql_column *c = n->data;
+   if (c->check) {
+   i->alias.rname= sa_strdup(sql->sa, t->base.name);
+   i->alias.name= sa_strdup(sql->sa, c->base.name);
+
+   int pos = 0;
+   rel3 = rel_read(sql, sa_strdup(sql->sa, c->check), 
, sa_list(sql->sa));
+   rel3->l = rel2;
+   stmt* s = subrel_bin(be, rel3, refs);
+   s = stmt_uselect(be, column(be, s), stmt_atom(be, 
atom_zero_value(sql->sa, bt)), cmp_equal, NULL, 0, 1);
+   sql_subfunc *cnt = sql_bind_func(sql, "sys", "count", 
sql_bind_localtype("void"), NULL, F_AGGR, true, true);
+   s = stmt_aggr(be, s, NULL, NULL, cnt, 1, 0, 1);
+   char *msg = sa_message(sql->sa, SQLSTATE(40002) "INSERT 
INTO: CHECK constraint violated for column %s.%s", c->t->base.name, 
c->base.name);
+   (void)stmt_exception(be, s, msg, 1);
+   }
+   }
+}
+
 static sql_table *
 sql_insert_check_null(backend *be, sql_table *t, list *inserts)
 {
@@ -5004,6 +5041,8 @@ rel2bin_insert(backend *be, sql_rel *rel
if (idx_ins)
pin = refs_find_rel(refs, prel);
 
+   sql_insert_check(be, t, rel->r, refs);
+
if (!sql_insert_check_null(be, t, inserts->op4.lval))
return NULL;
 
diff --git a/sql/server/rel_schema.c b/sql/server/rel_schema.c
--- a/sql/server/rel_schema.c
+++ b/sql/server/rel_schema.c
@@ -608,19 +608,8 @@ column_constraint_type(sql_query *query,
sql_rel* rel3 = rel_basetable(sql, t, t->base.name);
sql_exp *e = rel_logical_value_exp(query, , s->data.sym, 
sql_sel, ek);
sql_rel *rel = rel_project_exp(sql, e);
-   (void) rel;
-
char* check = rel2str(sql, rel);
 
-   int pos = 0;
-   list *refs = sa_list(sql->sa);
-   sql_rel* rel2 = rel_read(sql, check, , refs);
-   (void) check;
-   (void) rel2;
-   char *err = NULL, *r;
-   r = symbol2string(sql, s->data.sym, 0, );
-   (void) r;
-
switch (mvc_check(sql, cs, check)) {
case -1:
(void) sql_error(sql, 02, 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: check - persist check condition in the catalog

2024-04-08 Thread Yunus Koning via checkin-list
Changeset: b94c34073d77 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/b94c34073d77
Modified Files:
sql/server/rel_schema.c
sql/server/sql_mvc.c
sql/server/sql_mvc.h
sql/storage/sql_storage.h
sql/storage/store.c
Branch: check
Log Message:

persist check condition in the catalog


diffs (125 lines):

diff --git a/sql/server/rel_schema.c b/sql/server/rel_schema.c
--- a/sql/server/rel_schema.c
+++ b/sql/server/rel_schema.c
@@ -610,18 +610,29 @@ column_constraint_type(sql_query *query,
sql_rel *rel = rel_project_exp(sql, e);
(void) rel;
 
-   char* rel_str = rel2str(sql, rel);
+   char* check = rel2str(sql, rel);
 
int pos = 0;
list *refs = sa_list(sql->sa);
-   sql_rel* rel2 = rel_read(sql, rel_str, , refs);
-   (void) rel_str;
+   sql_rel* rel2 = rel_read(sql, check, , refs);
+   (void) check;
(void) rel2;
char *err = NULL, *r;
r = symbol2string(sql, s->data.sym, 0, );
(void) r;
-   (void) sql_error(sql, 02, SQLSTATE(42000) "CONSTRAINT CHECK: 
check constraints not supported");
-   return SQL_ERR;
+
+   switch (mvc_check(sql, cs, check)) {
+   case -1:
+   (void) sql_error(sql, 02, SQLSTATE(HY013) 
MAL_MALLOC_FAIL);
+   return SQL_ERR;
+   case -2:
+   case -3:
+   (void) sql_error(sql, 02, SQLSTATE(42000) 
"CHECK CONSTRAINT: transaction conflict detected");
+   return SQL_ERR;
+   default:
+   break;
+   }
+   res = SQL_OK;
}   break;
default:{
res = SQL_ERR;
diff --git a/sql/server/sql_mvc.c b/sql/server/sql_mvc.c
--- a/sql/server/sql_mvc.c
+++ b/sql/server/sql_mvc.c
@@ -1496,6 +1496,18 @@ mvc_storage(mvc *m, sql_column *col, cha
 }
 
 int
+mvc_check(mvc *m, sql_column *col, char *check)
+{
+   TRC_DEBUG(SQL_TRANS, "Check: %s %s\n", col->base.name, check);
+   if (col->t->persistence == SQL_DECLARED_TABLE) {
+   col->check = check?sa_strdup(m->sa, check):NULL;
+   return 0;
+   } else {
+   return sql_trans_alter_check(m->session->tr, col, check);
+   }
+}
+
+int
 mvc_access(mvc *m, sql_table *t, sht access)
 {
TRC_DEBUG(SQL_TRANS, "Access: %s %d\n", t->base.name, access);
diff --git a/sql/server/sql_mvc.h b/sql/server/sql_mvc.h
--- a/sql/server/sql_mvc.h
+++ b/sql/server/sql_mvc.h
@@ -226,6 +226,7 @@ sql_export int mvc_create_column(sql_col
 extern int mvc_create_column_(sql_column **col, mvc *m, sql_table *t, const 
char *name, const char *type, unsigned int digits);
 extern int mvc_null(mvc *c, sql_column *col, int flag);
 extern int mvc_default(mvc *c, sql_column *col, char *val);
+extern int mvc_check(mvc *m, sql_column *col, char *check);
 extern int mvc_drop_default(mvc *c, sql_column *col);
 extern int mvc_storage(mvc *c, sql_column *col, char *storage);
 extern int mvc_access(mvc *m, sql_table *t, sht access);
diff --git a/sql/storage/sql_storage.h b/sql/storage/sql_storage.h
--- a/sql/storage/sql_storage.h
+++ b/sql/storage/sql_storage.h
@@ -410,6 +410,7 @@ extern int sql_trans_drop_column(sql_tra
 extern int sql_trans_alter_null(sql_trans *tr, sql_column *col, int isnull);
 extern int sql_trans_alter_default(sql_trans *tr, sql_column *col, char *val);
 extern int sql_trans_alter_storage(sql_trans *tr, sql_column *col, char 
*storage);
+extern int sql_trans_alter_check(sql_trans *tr, sql_column *col, char *check);
 extern int sql_trans_is_sorted(sql_trans *tr, sql_column *col);
 extern int sql_trans_is_unique(sql_trans *tr, sql_column *col);
 extern int sql_trans_is_duplicate_eliminated(sql_trans *tr, sql_column *col);
diff --git a/sql/storage/store.c b/sql/storage/store.c
--- a/sql/storage/store.c
+++ b/sql/storage/store.c
@@ -6432,6 +6432,39 @@ sql_trans_alter_storage(sql_trans *tr, s
 }
 
 int
+sql_trans_alter_check(sql_trans *tr, sql_column *col, char *check)
+{
+   int res = LOG_OK;
+   sqlstore *store = tr->store;
+
+   if ((col->check || check) && (!col->check || !check || 
strcmp(col->check, check) != 0)) {
+   void *p = check ? check : (void *) ATOMnilptr(TYPE_str);
+   sql_schema *syss = find_sql_schema(tr, 
isGlobal(col->t)?"sys":"tmp");
+   sql_table *syscolumn = find_sql_table(tr, syss, "_columns");
+   sql_column *col_ids = find_sql_column(syscolumn, "id");
+   sql_column *col_chks = find_sql_column(syscolumn, "check");
+   oid rid = store->table_api.column_find_row(tr, col_ids, 
>base.id, NULL);
+   sql_column *dup = NULL;
+
+   if (is_oid_nil(rid))
+

MonetDB: check - add "check" column to _columns tables

2024-04-08 Thread Yunus Koning via checkin-list
Changeset: 387d76d5c476 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/387d76d5c476
Modified Files:
sql/include/sql_catalog.h
sql/storage/store.c
Branch: check
Log Message:

add "check" column to _columns tables


diffs (126 lines):

diff --git a/sql/include/sql_catalog.h b/sql/include/sql_catalog.h
--- a/sql/include/sql_catalog.h
+++ b/sql/include/sql_catalog.h
@@ -618,6 +618,7 @@ typedef struct sql_column {
char unique;/* 0 NOT UNIQUE, 1 SUB_UNIQUE, 2 UNIQUE */
int drop_action;/* only used for alter statements */
char *storage_type;
+   char *check; /* check condition*/
size_t dcount;
void *min;
void *max;
diff --git a/sql/storage/store.c b/sql/storage/store.c
--- a/sql/storage/store.c
+++ b/sql/storage/store.c
@@ -545,7 +545,7 @@ load_column(sql_trans *tr, sql_table *t,
sql_schema *syss = find_sql_schema(tr, "sys");
sql_table *columns = find_sql_table(tr, syss, "_columns");
sqlstore *store = tr->store;
-   str v, def, tpe, st;
+   str v, def, tpe, st, ch;
int sz, d;
 
sqlid cid = *(sqlid*)store->table_api.table_fetch_value(rt_cols, 
find_sql_column(columns, "id"));
@@ -576,6 +576,10 @@ load_column(sql_trans *tr, sql_table *t,
st = (char*)store->table_api.table_fetch_value(rt_cols, 
find_sql_column(columns, "storage"));
if (!strNil(st))
c->storage_type =_STRDUP(st);
+   c->check = NULL;
+   ch = (char*)store->table_api.table_fetch_value(rt_cols, 
find_sql_column(columns, "check"));
+   if (!strNil(ch))
+   c->check =_STRDUP(ch);
ATOMIC_PTR_INIT(>data, NULL);
c->t = t;
if (isTable(c->t))
@@ -1489,7 +1493,7 @@ insert_schemas(sql_trans *tr)
sql_column *c = o->data;
 
if ((res = store->table_api.table_insert(tr, 
syscolumn, >base.id, >base.name, >type.type->base.name, 
>type.digits, >type.scale,
-   
>base.id, (c->def) ? >def : , >null, >colnr, 
(c->storage_type)? >storage_type : )))
+   
>base.id, (c->def) ? >def : , >null, >colnr, 
(c->storage_type)? >storage_type : , (c->check)? >check : 
)))
return res;
}
}
@@ -1593,6 +1597,7 @@ bootstrap_create_column(sql_trans *tr, s
col->t = t;
col->unique = 0;
col->storage_type = NULL;
+   col->check = NULL;
if (ol_add(t->columns, >base))
return NULL;
 
@@ -1680,6 +1685,11 @@ dup_sql_column(sql_allocator *sa, sql_ta
col->storage_type = SA_STRDUP(sa, c->storage_type);
if (ol_add(t->columns, >base))
return NULL;
+   col->check = NULL;
+   if (c->check)
+   col->check = SA_STRDUP(sa, c->check);
+   if (ol_add(t->columns, >base))
+   return NULL;
return col;
 }
 
@@ -2017,6 +2027,7 @@ store_load(sqlstore *store, sql_allocato
bootstrap_create_column(tr, t, "null", 2084, "boolean", 1) == 
NULL ||
bootstrap_create_column(tr, t, "number", 2085, "int", 31) == 
NULL ||
bootstrap_create_column(tr, t, "storage", 2086, "varchar", 
2048) == NULL ||
+   bootstrap_create_column(tr, t, "check", 2165, "varchar", 2048) 
== NULL ||
 
(t = bootstrap_create_table(tr, s, "keys", 2087)) == NULL ||
bootstrap_create_column(tr, t, "id", 2088, "int", 31) == NULL ||
@@ -2078,6 +2089,7 @@ store_load(sqlstore *store, sql_allocato
bootstrap_create_column(tr, t, "null", 2132, "boolean", 1) == 
NULL ||
bootstrap_create_column(tr, t, "number", 2133, "int", 31) == 
NULL ||
bootstrap_create_column(tr, t, "storage", 2134, "varchar", 
2048) == NULL ||
+   bootstrap_create_column(tr, t, "check", 2166, "varchar", 2048) 
== NULL ||
 
(t = bootstrap_create_table(tr, s, "keys", 2135)) == NULL ||
bootstrap_create_column(tr, t, "id", 2136, "int", 31) == NULL ||
@@ -2976,6 +2988,9 @@ column_dup(sql_trans *tr, sql_column *oc
c->storage_type = NULL;
if (oc->storage_type)
c->storage_type =_STRDUP(oc->storage_type);
+   c->check = NULL;
+   if (oc->check)
+   c->check =_STRDUP(oc->check);
ATOMIC_PTR_INIT(>data, NULL);
 
if (isTable(c->t)) {
@@ -3642,6 +3657,9 @@ sql_trans_copy_column( sql_trans *tr, sq
col->storage_type = NULL;
if (c->storage_type)
col->storage_type =_STRDUP(c->storage_type);
+   col->check = NULL;
+   if (c->check)
+   col->check =_STRDUP(c->check);
 
if ((res = ol_add(t->columns, >base)))
return res;
@@ -3666,7 +3684,8 @@ 

MonetDB: check - (de)serialise relational plan check condition

2024-04-03 Thread Yunus Koning via checkin-list
Changeset: 2f299854001c for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/2f299854001c
Modified Files:
sql/server/rel_schema.c
sql/server/sql_parser.y
Branch: check
Log Message:

(de)serialise relational plan check condition


diffs (115 lines):

diff --git a/sql/server/rel_schema.c b/sql/server/rel_schema.c
--- a/sql/server/rel_schema.c
+++ b/sql/server/rel_schema.c
@@ -20,6 +20,7 @@
 #include "rel_schema.h"
 #include "rel_remote.h"
 #include "rel_psm.h"
+#include "rel_dump.h"
 #include "rel_propagate.h"
 #include "sql_parser.h"
 #include "sql_privileges.h"
@@ -359,10 +360,41 @@ foreign_key_check_types(sql_subtype *lt,
return lt->type->localtype == rt->type->localtype;
return lt->type->eclass == rt->type->eclass || 
(EC_VARCHAR(lt->type->eclass) && EC_VARCHAR(rt->type->eclass));
 }
+static str
+rel2str( mvc *sql, sql_rel *rel)
+{
+   buffer *b = NULL;
+   stream *s = NULL;
+   list *refs = NULL;
+   char *res = NULL;
+
+   b = buffer_create(1024);
+   if(b == NULL)
+   goto cleanup;
+   s = buffer_wastream(b, "rel_dump");
+   if(s == NULL)
+   goto cleanup;
+   refs = sa_list(sql->sa);
+   if (!refs)
+   goto cleanup;
+
+   rel_print_refs(sql, s, rel, 0, refs, 0);
+   rel_print_(sql, s, rel, 0, refs, 0);
+   mnstr_printf(s, "\n");
+   res = buffer_get_buf(b);
+
+cleanup:
+   if(b)
+   buffer_destroy(b);
+   if(s)
+   close_stream(s);
+   return res;
+}
 
 static int
-column_constraint_type(mvc *sql, const char *name, symbol *s, sql_schema *ss, 
sql_table *t, sql_column *cs, bool isDeclared, int *used)
+column_constraint_type(sql_query *query, const char *name, symbol *s, 
sql_schema *ss, sql_table *t, sql_column *cs, bool isDeclared, int *used)
 {
+   mvc *sql = query->sql;
int res = SQL_ERR;
 
if (isDeclared && (s->token != SQL_NULL && s->token != SQL_NOT_NULL)) {
@@ -571,6 +603,23 @@ column_constraint_type(mvc *sql, const c
res = SQL_OK;
}   break;
case SQL_CHECK: {
+   
+   exp_kind ek = {type_value, card_value, FALSE};
+   sql_rel* rel3 = rel_basetable(sql, t, t->base.name);
+   sql_exp *e = rel_logical_value_exp(query, , s->data.sym, 
sql_sel, ek);
+   sql_rel *rel = rel_project_exp(sql, e);
+   (void) rel;
+
+   char* rel_str = rel2str(sql, rel);
+
+   int pos = 0;
+   list *refs = sa_list(sql->sa);
+   sql_rel* rel2 = rel_read(sql, rel_str, , refs);
+   (void) rel_str;
+   (void) rel2;
+   char *err = NULL, *r;
+   r = symbol2string(sql, s->data.sym, 0, );
+   (void) r;
(void) sql_error(sql, 02, SQLSTATE(42000) "CONSTRAINT CHECK: 
check constraints not supported");
return SQL_ERR;
}   break;
@@ -604,7 +653,7 @@ column_options(sql_query *query, dlist *
if (!opt_name && !(default_name = 
column_constraint_name(sql, sym, cs, t)))
return SQL_ERR;
 
-   res = column_constraint_type(sql, 
opt_name ? opt_name : default_name, sym, ss, t, cs, isDeclared, );
+   res = column_constraint_type(query, 
opt_name ? opt_name : default_name, sym, ss, t, cs, isDeclared, );
}   break;
case SQL_DEFAULT: {
symbol *sym = s->data.sym;
diff --git a/sql/server/sql_parser.y b/sql/server/sql_parser.y
--- a/sql/server/sql_parser.y
+++ b/sql/server/sql_parser.y
@@ -233,7 +233,6 @@ int yydebug=1;
default
default_value
delete_stmt
-   domain_constraint_type
drop_statement
drop_table_element
exec
@@ -2155,7 +2154,7 @@ column_constraint_type:
  append_int(l, $5 );
  $$ = _symbol_create_list( SQL_FOREIGN_KEY, l); }
  /*TODO: Implement domain_constraint_type*/
- |  domain_constraint_type
+ | CHECK '(' search_condition ')' { $$ = _symbol_create_symbol(SQL_CHECK, 
$3); }
  ;
 
 table_constraint_type:
@@ -2181,7 +2180,6 @@ table_constraint_type:
  ;
 
 domain_constraint_type:
-CHECK '(' search_condition ')' { $$ = _symbol_create_symbol(SQL_CHECK, 
$3); }
  ;
 
 ident_commalist:
___
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

2024-03-27 Thread Yunus Koning via checkin-list
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()) {
-   /* trivial: nils don't match anything */
-   bat_iterator_end();
-   bat_iterator_end();
-   return nomatch(r1p, r2p, NULL, l, r, ,
-  0, false, false, __func__, t0);
+   if (!nil_matches) {
+   /* trivial: nils don't match anything */
+   bat_iterator_end();
+   bat_iterator_end();
+   return nomatch(r1p, r2p, NULL, l, r, ,
+  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()) {
-   /* trivial: nils don't match anything */
-   bat_iterator_end();
-   bat_iterator_end();
-   return nomatch(r1p, r2p, NULL, l, r, ,
-  0, false, false, __func__, t0);
+   if (!nil_matches) {
+   /* trivial: nils don't match anything */
+   bat_iterator_end();
+   bat_iterator_end();
+   return nomatch(r1p, r2p, NULL, l, r, ,
+  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();
if (lvals)
vl = VALUE(l, lo - l->hseqbase);
-   else
+   else if (BATtdensebi())
lval = (oid) ((lng) lo + loff);
nr = 0;
-   if (cmp(vl, nil) != 0) {
+   if (nil_matches || cmp(vl, nil) != 0) {
canditer_reset();
TIMEOUT_LOOP(rci.ncand, qry_ctx) {
ro = canditer_next();
if (rvals)
vr = VALUE(r, ro - r->hseqbase);
-   else
+   else if (BATtdensebi())
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, , 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, , 0, false, 
false,
   __func__, t0);
-   

MonetDB: distinct_from - merge with default

2024-03-27 Thread Yunus Koning via checkin-list
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)(_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(_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(>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(>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) {
+   GDKfree(h);
+  

MonetDB: distinct_from - add equi join test

2024-03-26 Thread Yunus Koning via checkin-list
Changeset: adc8681842bc for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/adc8681842bc
Modified Files:
sql/test/2024/Tests/distinct_from.test
Branch: distinct_from
Log Message:

add equi join test


diffs (15 lines):

diff --git a/sql/test/2024/Tests/distinct_from.test 
b/sql/test/2024/Tests/distinct_from.test
--- a/sql/test/2024/Tests/distinct_from.test
+++ b/sql/test/2024/Tests/distinct_from.test
@@ -158,3 +158,11 @@ 20
 NULL
 30
 
+
+query II rowsort
+select foo.s, bar.s from foo, bar where foo.s is not distinct from bar.s
+
+20
+20
+NULL
+NULL
___
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org


MonetDB: distinct_from - allow IS NOT DISTINCT FROM in a join co...

2024-03-22 Thread Yunus Koning via checkin-list
Changeset: a24a58b8ca90 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/a24a58b8ca90
Modified Files:
sql/server/rel_select.c
sql/server/sql_parser.y
Branch: distinct_from
Log Message:

allow IS NOT DISTINCT FROM in a join condition


diffs (113 lines):

diff --git a/sql/server/rel_select.c b/sql/server/rel_select.c
--- a/sql/server/rel_select.c
+++ b/sql/server/rel_select.c
@@ -1730,7 +1730,7 @@ rel_select_push_compare_exp_down(mvc *sq
 }
 
 static sql_rel *
-rel_compare_exp_(sql_query *query, sql_rel *rel, sql_exp *ls, sql_exp *rs, 
sql_exp *rs2, int type, int anti, int quantifier, int f, int symmetric)
+rel_compare_exp_(sql_query *query, sql_rel *rel, sql_exp *ls, sql_exp *rs, 
sql_exp *rs2, int type, int anti, int quantifier, int f, int symmetric, int 
is_semantics)
 {
mvc *sql = query->sql;
sql_exp *e = NULL;
@@ -1758,6 +1758,7 @@ rel_compare_exp_(sql_query *query, sql_r
if (rel_convert_types(sql, rel, rel, , , 1, 
type_equal_no_any) < 0)
return NULL;
e = exp_compare(sql->sa, ls, rs, type);
+   if (is_semantics) set_semantics(e);
} else {
assert(rs2);
if (rel_convert_types(sql, rel, rel, , , 1, 
type_equal_no_any) < 0)
@@ -1783,7 +1784,7 @@ rel_compare_exp_(sql_query *query, sql_r
 }
 
 static sql_rel *
-rel_compare_exp(sql_query *query, sql_rel *rel, sql_exp *ls, sql_exp *rs, char 
*compare_op, int reduce, int quantifier, int need_not, int f)
+rel_compare_exp(sql_query *query, sql_rel *rel, sql_exp *ls, sql_exp *rs, char 
*compare_op, int reduce, int quantifier, int need_not, int f, int is_semantics)
 {
mvc *sql = query->sql;
comp_type type = cmp_equal;
@@ -1816,11 +1817,11 @@ rel_compare_exp(sql_query *query, sql_re
}
type = compare_str2type(compare_op);
assert(type != cmp_filter);
-   return rel_compare_exp_(query, rel, ls, rs, NULL, type, need_not, 
quantifier, f, 0);
+   return rel_compare_exp_(query, rel, ls, rs, NULL, type, need_not, 
quantifier, f, 0, is_semantics);
 }
 
 static sql_rel *
-rel_compare(sql_query *query, sql_rel *rel, symbol *sc, symbol *lo, symbol 
*ro, char *compare_op, int f, exp_kind k, int quantifier)
+rel_compare(sql_query *query, sql_rel *rel, symbol *sc, symbol *lo, symbol 
*ro, char *compare_op, int f, exp_kind k, int quantifier, int is_semantics)
 {
mvc *sql = query->sql;
sql_exp *rs = NULL, *ls;
@@ -1884,7 +1885,7 @@ rel_compare(sql_query *query, sql_rel *r
return sql_error(sql, ERR_GROUPBY, SQLSTATE(42000) 
"SELECT: cannot use non GROUP BY column '%s.%s' in query results without an 
aggregate function", exp_relname(rs), exp_name(rs));
return sql_error(sql, ERR_GROUPBY, SQLSTATE(42000) "SELECT: 
cannot use non GROUP BY column in query results without an aggregate function");
}
-   return rel_compare_exp(query, rel, ls, rs, compare_op, k.reduce, 
quantifier, need_not, f);
+   return rel_compare_exp(query, rel, ls, rs, compare_op, k.reduce, 
quantifier, need_not, f, is_semantics);
 }
 
 static sql_exp*
@@ -2703,11 +2704,19 @@ rel_logical_exp(sql_query *query, sql_re
symbol *ro = n->next->next->data.sym;
char *compare_op = n->next->data.sval;
int quantifier = 0;
+   int is_semantics = 0;
 
if (n->next->next->next)
quantifier = n->next->next->next->data.i_val + 1;
-   assert(quantifier == 0 || quantifier == 1 || quantifier == 2);
-   return rel_compare(query, rel, sc, lo, ro, compare_op, f, ek, 
quantifier);
+   assert(quantifier == 0 || quantifier == 1 || quantifier == 2 || 
quantifier == 3 || quantifier == 4);
+
+   if (quantifier >= 3) {
+   quantifier = 0;
+   is_semantics = 1;
+   }
+
+   /* [NOT] DISTINCT FROM */
+   return rel_compare(query, rel, sc, lo, ro, compare_op, f, ek, 
quantifier, is_semantics);
}
/* Set Member ship */
case SQL_IN:
@@ -2777,7 +2786,7 @@ rel_logical_exp(sql_query *query, sql_re
(re2 = exp_check_type(sql, , rel, re2, type_equal)) 
== NULL)
return NULL;
 
-   return rel_compare_exp_(query, rel, le, re1, re2, 3, sc->token 
== SQL_NOT_BETWEEN ? 1 : 0, 0, f, symmetric);
+   return rel_compare_exp_(query, rel, le, re1, re2, 3, sc->token 
== SQL_NOT_BETWEEN ? 1 : 0, 0, f, symmetric, 0);
}
case SQL_IS_NULL:
case SQL_IS_NOT_NULL:
@@ -5457,7 +5466,7 @@ join_on_column_name(sql_query *query, sq
return sql_error(sql, ERR_AMBIGUOUS, 
SQLSTATE(42000) "NATURAL JOIN: common column name '%s' appears more than once 
in left table", rname);
 
found = 1;
-   if (!(rel = 

MonetDB: default - merge with distinct_from

2024-03-21 Thread Yunus Koning via checkin-list
Changeset: ffd1b69a0993 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/ffd1b69a0993
Branch: default
Log Message:

merge with distinct_from


diffs (266 lines):

diff --git a/sql/ChangeLog b/sql/ChangeLog
--- a/sql/ChangeLog
+++ b/sql/ChangeLog
@@ -1,6 +1,11 @@
 # ChangeLog file for sql
 # This file is updated with Maddlog
 
+* Thu Mar 21 2024 Yunus Koning 
+- Introduce IS [NOT] DISTINCT FROM syntax. The syntax allows two values
+  to be compared. The comparison always returns boolean FALSE or TRUE
+  never NULL.
+
 * Wed Mar  6 2024 Yunus Koning 
 - SQL2023 feature: Introduce UNIQUE NULLS [NOT] DISTINCT syntax which
   allows for NULLS to be treated as unique, i.e. a column with this
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
@@ -1831,8 +1831,8 @@ exp_bin(backend *be, sql_exp *e, stmt *l

   tail_type(l), tail_type(l), F_FUNC, true, true);
assert(f);
if (is_semantics(e)) {
-   if (exp_is_null(e->l) && 
exp_is_null(e->r)) {
-   s = stmt_bool(be, 
!is_anti(e));
+   if (exp_is_null(e->l) && 
exp_is_null(e->r) && (e->flag == cmp_equal || e->flag == cmp_notequal)) {
+   s = stmt_bool(be, 
e->flag == cmp_equal ? !is_anti(e): is_anti(e));
} else {
list *args = 
sa_list(sql->sa);
if (args == NULL)
diff --git a/sql/server/rel_select.c b/sql/server/rel_select.c
--- a/sql/server/rel_select.c
+++ b/sql/server/rel_select.c
@@ -2367,6 +2367,8 @@ rel_logical_value_exp(sql_query *query, 
int quantifier = 0, need_not = 0;
sql_exp *rs = NULL, *ls;
comp_type cmp_type = compare_str2type(compare_op);
+   bool is_not_distinct_from = false;
+   bool is_distinct_from = false;
 
/*
 * = ANY -> IN, <> ALL -> NOT( = ANY) -> NOT IN
@@ -2374,7 +2376,17 @@ rel_logical_value_exp(sql_query *query, 
 */
if (n->next->next->next)
quantifier = n->next->next->next->data.i_val + 1;
-   assert(quantifier == 0 || quantifier == 1 || quantifier == 2);
+   assert(quantifier == 0 || quantifier == 1 || quantifier == 2 || 
quantifier == 3 || quantifier == 4);
+
+   /* [NOT] DISTINCT FROM */
+   if (quantifier == 3) {
+   is_not_distinct_from = true;
+   quantifier = 0;
+   }
+   else if (quantifier == 4) {
+   is_distinct_from = true;
+   quantifier = 0;
+   }
 
if ((quantifier == 1 && cmp_type == cmp_equal) ||
(quantifier == 2 && cmp_type == cmp_notequal)) {
@@ -2405,6 +2417,15 @@ rel_logical_value_exp(sql_query *query, 
rs = rel_value_exp(query, rel, ro, f|sql_farg, ek);
if (!rs)
return NULL;
+
+   if (is_distinct_from || is_not_distinct_from) {
+   if (rel_convert_types(sql, rel ? *rel : NULL, rel ? 
*rel : NULL, , , 1, type_equal_no_any) < 0)
+   return NULL;
+   sql_exp* e = exp_compare(sql->sa, ls, rs, 
is_not_distinct_from?cmp_equal:cmp_notequal);
+   set_semantics(e);
+   return e;
+   }
+
if (rs->type == e_atom)
quantifier = 0;
 
diff --git a/sql/server/sql_parser.y b/sql/server/sql_parser.y
--- a/sql/server/sql_parser.y
+++ b/sql/server/sql_parser.y
@@ -3909,6 +3909,20 @@ comparison_predicate:
  append_symbol(l, $5);
  append_int(l, $3);
  $$ = _symbol_create_list(SQL_COMPARE, l ); }
+ | pred_exp IS NOT DISTINCT FROM pred_exp
+   { dlist *l = L();
+ append_symbol(l, $1);
+ append_string(l, sa_strdup(SA, "="));
+ append_symbol(l, $6);
+ append_int(l, 2);
+ $$ = _symbol_create_list(SQL_COMPARE, l ); }
+ | pred_exp IS DISTINCT FROM pred_exp
+   { dlist *l = L();
+ append_symbol(l, $1);
+ append_string(l, sa_strdup(SA, "="));
+ append_symbol(l, $5);
+ append_int(l, 3);
+ $$ = _symbol_create_list(SQL_COMPARE, l ); }
  ;
 
 between_predicate:
diff --git 

MonetDB: distinct_from - merge with default

2024-03-21 Thread Yunus Koning via checkin-list
Changeset: 8e8ccee7e3be for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/8e8ccee7e3be
Branch: distinct_from
Log Message:

merge with default


diffs (126 lines):

diff --git a/gdk/gdk_select.c b/gdk/gdk_select.c
--- a/gdk/gdk_select.c
+++ b/gdk/gdk_select.c
@@ -1206,6 +1206,9 @@ BATrange(BATiter *bi, const void *tl, co
if (tl == NULL && th == NULL)
return range_contains; /* looking for everything */
 
+   if (VIEWtparent(bi->b))
+   pb = BATdescriptor(VIEWtparent(bi->b));
+
/* keep locked while we look at the property values */
MT_lock_set(>b->theaplock);
if (bi->minpos != BUN_NONE)
@@ -1221,8 +1224,7 @@ BATrange(BATiter *bi, const void *tl, co
}
bool keep = false;  /* keep lock on parent bat? */
if (minprop == NULL || maxprop == NULL) {
-   if (VIEWtparent(bi->b) &&
-   (pb = BATdescriptor(VIEWtparent(bi->b))) != NULL) {
+   if (pb != NULL) {
MT_lock_set(>theaplock);
if (minprop == NULL && (minprop = BATgetprop_nolock(pb, 
GDK_MIN_BOUND)) != NULL) {
keep = true;
diff --git a/monetdb5/modules/atoms/Tests/All b/monetdb5/modules/atoms/Tests/All
--- a/monetdb5/modules/atoms/Tests/All
+++ b/monetdb5/modules/atoms/Tests/All
@@ -33,13 +33,3 @@ jsonrender
 
 uuid00
 strappend
-
-startswith
-endswith
-contains
-HAVE_ICONV?asciify
-startswith_join
-endswith_join
-contains_join
-
-ts_and_tstz_to_str_bug
diff --git a/monetdb5/modules/kernel/Tests/All 
b/monetdb5/modules/kernel/Tests/All
--- a/monetdb5/modules/kernel/Tests/All
+++ b/monetdb5/modules/kernel/Tests/All
@@ -3,8 +3,3 @@ TriBool
 batstr
 math
 select
-
-HAVE_ICONV?batstr_asciify
-batstr_startswith
-batstr_endswith
-batstr_contains
diff --git a/monetdb5/modules/mal/Tests/All b/monetdb5/modules/mal/Tests/All
--- a/monetdb5/modules/mal/Tests/All
+++ b/monetdb5/modules/mal/Tests/All
@@ -52,6 +52,3 @@ orderidx00
 orderidx01
 orderidx02
 orderidx04
-
-txtsim_levenshtein
-txtsim_jarowinkler
diff --git a/sql/test/strings/Tests/All b/sql/test/strings/Tests/All
new file mode 100644
--- /dev/null
+++ b/sql/test/strings/Tests/All
@@ -0,0 +1,17 @@
+startswith
+endswith
+contains
+HAVE_ICONV?asciify
+startswith_join
+endswith_join
+contains_join
+
+ts_and_tstz_to_str_bug
+
+HAVE_ICONV?batstr_asciify
+batstr_startswith
+batstr_endswith
+batstr_contains
+
+txtsim_levenshtein
+txtsim_jarowinkler
diff --git a/monetdb5/modules/atoms/Tests/asciify.test 
b/sql/test/strings/Tests/asciify.test
rename from monetdb5/modules/atoms/Tests/asciify.test
rename to sql/test/strings/Tests/asciify.test
diff --git a/monetdb5/modules/kernel/Tests/batstr_asciify.test 
b/sql/test/strings/Tests/batstr_asciify.test
rename from monetdb5/modules/kernel/Tests/batstr_asciify.test
rename to sql/test/strings/Tests/batstr_asciify.test
diff --git a/monetdb5/modules/kernel/Tests/batstr_contains.test 
b/sql/test/strings/Tests/batstr_contains.test
rename from monetdb5/modules/kernel/Tests/batstr_contains.test
rename to sql/test/strings/Tests/batstr_contains.test
diff --git a/monetdb5/modules/kernel/Tests/batstr_endswith.test 
b/sql/test/strings/Tests/batstr_endswith.test
rename from monetdb5/modules/kernel/Tests/batstr_endswith.test
rename to sql/test/strings/Tests/batstr_endswith.test
diff --git a/monetdb5/modules/kernel/Tests/batstr_startswith.test 
b/sql/test/strings/Tests/batstr_startswith.test
rename from monetdb5/modules/kernel/Tests/batstr_startswith.test
rename to sql/test/strings/Tests/batstr_startswith.test
diff --git a/monetdb5/modules/atoms/Tests/contains.test 
b/sql/test/strings/Tests/contains.test
rename from monetdb5/modules/atoms/Tests/contains.test
rename to sql/test/strings/Tests/contains.test
diff --git a/monetdb5/modules/atoms/Tests/contains_join.test 
b/sql/test/strings/Tests/contains_join.test
rename from monetdb5/modules/atoms/Tests/contains_join.test
rename to sql/test/strings/Tests/contains_join.test
diff --git a/monetdb5/modules/atoms/Tests/endswith.test 
b/sql/test/strings/Tests/endswith.test
rename from monetdb5/modules/atoms/Tests/endswith.test
rename to sql/test/strings/Tests/endswith.test
diff --git a/monetdb5/modules/atoms/Tests/endswith_join.test 
b/sql/test/strings/Tests/endswith_join.test
rename from monetdb5/modules/atoms/Tests/endswith_join.test
rename to sql/test/strings/Tests/endswith_join.test
diff --git a/monetdb5/modules/atoms/Tests/startswith.test 
b/sql/test/strings/Tests/startswith.test
rename from monetdb5/modules/atoms/Tests/startswith.test
rename to sql/test/strings/Tests/startswith.test
diff --git a/monetdb5/modules/atoms/Tests/startswith_join.test 
b/sql/test/strings/Tests/startswith_join.test
rename from monetdb5/modules/atoms/Tests/startswith_join.test
rename to sql/test/strings/Tests/startswith_join.test
diff --git a/monetdb5/modules/atoms/Tests/ts_and_tstz_to_str_bug.test 
b/sql/test/strings/Tests/ts_and_tstz_to_str_bug.test
rename from 

MonetDB: distinct_from - add test for two columns

2024-03-21 Thread Yunus Koning via checkin-list
Changeset: c15f96310f33 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/c15f96310f33
Modified Files:
sql/test/2024/Tests/distinct_from.test
Branch: distinct_from
Log Message:

add test for two columns


diffs (75 lines):

diff --git a/sql/test/2024/Tests/distinct_from.test 
b/sql/test/2024/Tests/distinct_from.test
--- a/sql/test/2024/Tests/distinct_from.test
+++ b/sql/test/2024/Tests/distinct_from.test
@@ -1,6 +1,3 @@
-statement ok
-create table foo(s) as values (10), (20), (NULL)
-
 
 query I nosort
 SELECT 10 IS NOT DISTINCT FROM 20
@@ -43,6 +40,9 @@ SELECT NULL IS NOT DISTINCT FROM NULL
 
 1
 
+statement ok
+create table foo(s) as values (10), (20), (NULL)
+
 query I nosort
 select s IS NOT DISTINCT FROM 20 FROM foo;
 
@@ -71,7 +71,6 @@ 1
 1
 0
 
-
 query I nosort
 select 20 IS NOT DISTINCT FROM s FROM foo;
 
@@ -99,3 +98,46 @@ select NULL IS DISTINCT FROM s FROM foo;
 1
 1
 0
+
+statement ok
+create table bar(s) as values (20), (30), (NULL)
+
+query  rowsort
+select foo.s, bar.s, foo.s IS DISTINCT FROM bar.s, foo.s IS NOT DISTINCT FROM 
bar.s FROM foo, bar
+
+10
+20
+1
+0
+10
+30
+1
+0
+10
+NULL
+1
+0
+20
+20
+0
+1
+20
+30
+1
+0
+20
+NULL
+1
+0
+NULL
+20
+1
+0
+NULL
+30
+1
+0
+NULL
+NULL
+0
+1
___
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org


MonetDB: distinct_from - update changelog

2024-03-21 Thread Yunus Koning via checkin-list
Changeset: 75405850de3b for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/75405850de3b
Modified Files:
sql/ChangeLog
Branch: distinct_from
Log Message:

update changelog


diffs (15 lines):

diff --git a/sql/ChangeLog b/sql/ChangeLog
--- a/sql/ChangeLog
+++ b/sql/ChangeLog
@@ -1,6 +1,11 @@
 # ChangeLog file for sql
 # This file is updated with Maddlog
 
+* Thu Mar 21 2024 Yunus Koning 
+- Introduce IS [NOT] DISTINCT FROM syntax. The syntax allows two values
+  to be compared. The comparison always returns boolean FALSE or TRUE
+  never NULL.
+
 * Wed Mar  6 2024 Yunus Koning 
 - SQL2023 feature: Introduce UNIQUE NULLS [NOT] DISTINCT syntax which
   allows for NULLS to be treated as unique, i.e. a column with this
___
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org


MonetDB: distinct_from - merge with default

2024-03-20 Thread Yunus Koning via checkin-list
Changeset: 98f7cbab8a85 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/98f7cbab8a85
Branch: distinct_from
Log Message:

merge with default


diffs (truncated from 689 to 300 lines):

diff --git a/.hgtags b/.hgtags
--- a/.hgtags
+++ b/.hgtags
@@ -822,3 +822,4 @@ 1230526af30f40eeea30fb87c47c3e414920561f
 1230526af30f40eeea30fb87c47c3e414920561f Dec2023_release
 95d8feaa1167b5ba87bd99253c3f4e62ebf528a1 Dec2023_3
 dcc8c702e685a4faf21ccf663028d1bc3d1165d1 Dec2023_5
+dcc8c702e685a4faf21ccf663028d1bc3d1165d1 Dec2023_SP1_release
diff --git a/monetdb5/ChangeLog.Dec2023 b/monetdb5/ChangeLog.Dec2023
--- a/monetdb5/ChangeLog.Dec2023
+++ b/monetdb5/ChangeLog.Dec2023
@@ -1,3 +1,7 @@
 # ChangeLog file for MonetDB5
 # This file is updated with Maddlog
 
+* Tue Mar 19 2024 Sjoerd Mullender 
+- Fixed interaction between mserver5 and remote mserver5 when only one
+  of the two has 128 bit integer support.
+
diff --git a/monetdb5/modules/mal/remote.c b/monetdb5/modules/mal/remote.c
--- a/monetdb5/modules/mal/remote.c
+++ b/monetdb5/modules/mal/remote.c
@@ -86,12 +86,14 @@
 #define RMTT_64_BITS(1<<2)
 #define RMTT_32_OIDS(0<<3)
 #define RMTT_64_OIDS(1<<3)
+#define RMTT_HGE   (1<<4)
 
 typedef struct _connection {
MT_Lock lock;   /* lock to avoid interference */
str name;   /* the handle for this 
connection */
Mapi mconn; /* the Mapi handle for 
the connection */
unsigned char type; /* binary profile of the 
connection target */
+   bool int128;/* has int128 support */
size_t nextid;  /* id counter */
struct _connection *next;   /* the next connection in the list */
 } *connection;
@@ -106,6 +108,7 @@ static MT_Lock mal_remoteLock = MT_LOCK_
 
 static connection conns = NULL;
 static unsigned char localtype = 0177;
+static bool int128 = false;
 
 static inline str RMTquery(MapiHdl *ret, const char *func, Mapi conn,
   const char *query);
@@ -297,7 +300,19 @@ RMTconnectScen(str *ret,
 #ifdef _DEBUG_MAPI_
mapi_trace(c->mconn, true);
 #endif
-
+   if (c->type != localtype && (c->type | RMTT_HGE) == localtype) {
+   /* we support hge, and for remote, we don't know */
+   msg = RMTquery(, "remote.connect", m, "x := 0:hge;");
+   if (msg) {
+   c->int128 = false;
+   } else {
+   mapi_close_handle(hdl);
+   c->int128 = true;
+   c->type |= RMTT_HGE;
+   }
+   } else if (c->type == localtype) {
+   c->int128 = int128;
+   }
MT_lock_unset(_remoteLock);
 
*ret = GDKstrdup(conn);
@@ -502,6 +517,10 @@ RMTprelude(void)
 #else
type |= RMTT_32_OIDS;
 #endif
+#ifdef HAVE_HGE
+   type |= RMTT_HGE;
+   int128 = true;
+#endif
localtype = (unsigned char) type;
 
return (MAL_SUCCEED);
@@ -570,7 +589,7 @@ typedef struct _binbat_v1 {
 } binbat;
 
 static str
-RMTinternalcopyfrom(BAT **ret, char *hdr, stream *in, bool must_flush)
+RMTinternalcopyfrom(BAT **ret, char *hdr, stream *in, bool must_flush, bool 
cint128)
 {
binbat bb = { 0, 0, 0, false, false, false, false, false, 0, 0, 0 };
char *nme = NULL;
@@ -581,6 +600,7 @@ RMTinternalcopyfrom(BAT **ret, char *hdr
 
BAT *b;
 
+   (void) cint128;
/* hdr is a JSON structure that looks like
 * {"version":1,"ttype":6,"tseqbase":0,"tailsize":4,"theapsize":0}
 * we take the binary data directly from the stream */
@@ -684,6 +704,12 @@ RMTinternalcopyfrom(BAT **ret, char *hdr
}
hdr++;
}
+#ifdef HAVE_HGE
+   if (int128 && !cint128 && bb.Ttype >= TYPE_hge)
+   bb.Ttype++;
+#else
+   (void) cint128;
+#endif
 
b = COLnew2(bb.Hseqbase, bb.Ttype, bb.size, TRANSIENT,
bb.size > 0 ? (uint16_t) (bb.tailsize / 
bb.size) : 0);
@@ -788,7 +814,7 @@ RMTget(Client cntxt, MalBlkPtr mb, MalSt
}
GDKfree(rt);
 
-   if (isaBatType(rtype) && (localtype == 0177 || localtype != c->type)) {
+   if (isaBatType(rtype) && (localtype == 0177 || (localtype != c->type && 
localtype != (c->type | RMTT_HGE {
int t;
size_t s;
ptr r;
@@ -880,7 +906,7 @@ RMTget(Client cntxt, MalBlkPtr mb, MalSt
return tmp;
}
 
-   if ((tmp = RMTinternalcopyfrom(, buf, sin, true)) != 
MAL_SUCCEED) {
+   if ((tmp = RMTinternalcopyfrom(, buf, sin, true, c->int128)) 
!= MAL_SUCCEED) {
MT_lock_unset(>lock);
return (tmp);
}
@@ -1378,7 +1404,7 @@ RMTexec(Client cntxt, MalBlkPtr mb, MalS

MonetDB: check - new branch check

2024-03-19 Thread Yunus Koning via checkin-list
Changeset: 53ee42573dfc for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/53ee42573dfc
Branch: check
Log Message:

new branch check

___
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org


MonetDB: distinct_from - merge with default

2024-03-19 Thread Yunus Koning via checkin-list
Changeset: 6bfac24cef56 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/6bfac24cef56
Branch: distinct_from
Log Message:

merge with default


diffs (truncated from 1041 to 300 lines):

diff --git a/gdk/ChangeLog.Dec2023 b/gdk/ChangeLog.Dec2023
--- a/gdk/ChangeLog.Dec2023
+++ b/gdk/ChangeLog.Dec2023
@@ -1,3 +1,7 @@
 # ChangeLog file for GDK
 # This file is updated with Maddlog
 
+* Mon Mar 18 2024 Sjoerd Mullender 
+- Fixed a couple of deadlock situations, one actually observed, one
+  never observed.
+
diff --git a/gdk/gdk.h b/gdk/gdk.h
--- a/gdk/gdk.h
+++ b/gdk/gdk.h
@@ -2372,10 +2372,10 @@ gdk_export BAT *BATsample_with_seed(BAT 
 static inline void
 TIMEOUT_ERROR(QryCtx *qc, const char *file, const char *func, int lineno)
 {
-   if (GDKexiting())
+   if (GDKexiting()) {
GDKtracer_log(file, func, lineno, M_ERROR, GDK, NULL,
  "%s\n", EXITING_MSG);
-   else {
+   } else if (qc) {
switch (qc->endtime) {
case QRY_TIMEOUT:
GDKtracer_log(file, func, lineno, M_ERROR, GDK, NULL,
diff --git a/gdk/gdk_aggr.c b/gdk/gdk_aggr.c
--- a/gdk/gdk_aggr.c
+++ b/gdk/gdk_aggr.c
@@ -208,7 +208,6 @@ dofsum(const void *restrict values, oid 
volatile flt f;
 
QryCtx *qry_ctx = MT_thread_get_qry_ctx();
-   qry_ctx = qry_ctx ? qry_ctx : &(QryCtx) {.endtime = 0};
 
/* we only deal with the two floating point types */
assert(tp1 == TYPE_flt || tp1 == TYPE_dbl);
@@ -719,7 +718,6 @@ dosum(const void *restrict values, bool 
unsigned int *restrict seen = NULL; /* bitmask for groups that we've 
seen */
 
QryCtx *qry_ctx = MT_thread_get_qry_ctx();
-   qry_ctx = qry_ctx ? qry_ctx : &(QryCtx) {.endtime = 0};
 
switch (tp2) {
case TYPE_flt:
@@ -1359,7 +1357,6 @@ doprod(const void *restrict values, oid 
unsigned int *restrict seen; /* bitmask for groups that we've seen */
 
QryCtx *qry_ctx = MT_thread_get_qry_ctx();
-   qry_ctx = qry_ctx ? qry_ctx : &(QryCtx) {.endtime = 0};
 
/* allocate bitmap for seen group ids */
seen = GDKzalloc(((ngrp + 31) / 32) * sizeof(int));
@@ -1818,7 +1815,6 @@ BATgroupavg(BAT **bnp, BAT **cntsp, BAT 
BATiter bi = {0};
 
QryCtx *qry_ctx = MT_thread_get_qry_ctx();
-   qry_ctx = qry_ctx ? qry_ctx : &(QryCtx) {.endtime = 0};
 
TRC_DEBUG_IF(ALGO) t0 = GDKusec();
 
@@ -2008,7 +2004,6 @@ BATgroupavg3(BAT **avgp, BAT **remp, BAT
oid o;
 
QryCtx *qry_ctx = MT_thread_get_qry_ctx();
-   qry_ctx = qry_ctx ? qry_ctx : &(QryCtx) {.endtime = 0};
 
if ((err = BATgroupaggrinit(b, g, e, s, , , , )) != 
NULL) {
GDKerror("%s\n", err);
@@ -2646,7 +2641,6 @@ BATgroupavg3combine(BAT *avg, BAT *rem, 
BAT *bn, *rn, *cn;
 
QryCtx *qry_ctx = MT_thread_get_qry_ctx();
-   qry_ctx = qry_ctx ? qry_ctx : &(QryCtx) {.endtime = 0};
 
if ((err = BATgroupaggrinit(avg, g, e, NULL, , , , )) 
!= NULL) {
GDKerror("%s\n", err);
@@ -3003,7 +2997,6 @@ BATcalcavg(BAT *b, BAT *s, dbl *avg, BUN
const void *restrict src;
 
QryCtx *qry_ctx = MT_thread_get_qry_ctx();
-   qry_ctx = qry_ctx ? qry_ctx : &(QryCtx) {.endtime = 0};
 
canditer_init(, b, s);
 
@@ -3090,7 +3083,6 @@ BATgroupcount(BAT *b, BAT *g, BAT *e, BA
BATiter bi = {0};
 
QryCtx *qry_ctx = MT_thread_get_qry_ctx();
-   qry_ctx = qry_ctx ? qry_ctx : &(QryCtx) {.endtime = 0};
 
TRC_DEBUG_IF(ALGO) t0 = GDKusec();
 
@@ -3263,7 +3255,6 @@ do_groupmin(oid *restrict oids, BATiter 
int (*atomcmp)(const void *, const void *);
 
QryCtx *qry_ctx = MT_thread_get_qry_ctx();
-   qry_ctx = qry_ctx ? qry_ctx : &(QryCtx) {.endtime = 0};
 
nils = ngrp;
TIMEOUT_LOOP_IDX(i, ngrp, qry_ctx)
@@ -3386,7 +3377,6 @@ do_groupmax(oid *restrict oids, BATiter 
int (*atomcmp)(const void *, const void *);
 
QryCtx *qry_ctx = MT_thread_get_qry_ctx();
-   qry_ctx = qry_ctx ? qry_ctx : &(QryCtx) {.endtime = 0};
 
nils = ngrp;
TIMEOUT_LOOP_IDX(i, ngrp, qry_ctx)
@@ -3984,7 +3974,6 @@ doBATgroupquantile(BAT *b, BAT *g, BAT *
 
size_t counter = 0;
QryCtx *qry_ctx = MT_thread_get_qry_ctx();
-   qry_ctx = qry_ctx ? qry_ctx : &(QryCtx) {.endtime = 0};
 
TRC_DEBUG_IF(ALGO) t0 = GDKusec();
 
@@ -4366,7 +4355,6 @@ calcvariance(dbl *restrict avgp, const v
dbl delta;
 
QryCtx *qry_ctx = MT_thread_get_qry_ctx();
-   qry_ctx = qry_ctx ? qry_ctx : &(QryCtx) {.endtime = 0};
 
switch (tp) {
case TYPE_bte:
@@ -4493,7 +4481,6 @@ calccovariance(const void *v1, const voi
dbl mean1 = 0, mean2 = 0, m2 = 0, delta1, delta2;
 
QryCtx *qry_ctx = MT_thread_get_qry_ctx();
-   qry_ctx = qry_ctx ? qry_ctx : &(QryCtx) {.endtime = 0};
 
 
switch (tp) {
@@ -4597,7 +4584,6 @@ BATcalccorrelation(BAT *b1, BAT 

MonetDB: distinct_from - Fix regression

2024-03-19 Thread Yunus Koning via checkin-list
Changeset: bce329ad7350 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/bce329ad7350
Modified Files:
sql/test/sys-schema/Tests/webExamplesComparisonFunctionsOperators.test
Branch: distinct_from
Log Message:

Fix regression


diffs (12 lines):

diff --git 
a/sql/test/sys-schema/Tests/webExamplesComparisonFunctionsOperators.test 
b/sql/test/sys-schema/Tests/webExamplesComparisonFunctionsOperators.test
--- a/sql/test/sys-schema/Tests/webExamplesComparisonFunctionsOperators.test
+++ b/sql/test/sys-schema/Tests/webExamplesComparisonFunctionsOperators.test
@@ -920,7 +920,7 @@ select 'db' not between SYMMETRIC 'db' a
 
 0
 
-statement error
+statement ok
 select 'a' IS DISTINCT FROM 'b' as tru
 
 query I rowsort
___
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org


MonetDB: distinct_from - fix DISTINCT FROM syntax

2024-03-18 Thread Yunus Koning via checkin-list
Changeset: 1163f668b280 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/1163f668b280
Modified Files:
sql/server/sql_parser.y
sql/test/2024/Tests/distinct_from.test
Branch: distinct_from
Log Message:

fix DISTINCT FROM syntax


diffs (148 lines):

diff --git a/sql/server/sql_parser.y b/sql/server/sql_parser.y
--- a/sql/server/sql_parser.y
+++ b/sql/server/sql_parser.y
@@ -3909,18 +3909,18 @@ comparison_predicate:
  append_symbol(l, $5);
  append_int(l, $3);
  $$ = _symbol_create_list(SQL_COMPARE, l ); }
- | pred_exp NOT DISTINCT FROM pred_exp
+ | pred_exp IS NOT DISTINCT FROM pred_exp
+   { dlist *l = L();
+ append_symbol(l, $1);
+ append_string(l, sa_strdup(SA, "="));
+ append_symbol(l, $6);
+ append_int(l, 2);
+ $$ = _symbol_create_list(SQL_COMPARE, l ); }
+ | pred_exp IS DISTINCT FROM pred_exp
{ dlist *l = L();
  append_symbol(l, $1);
  append_string(l, sa_strdup(SA, "="));
  append_symbol(l, $5);
- append_int(l, 2);
- $$ = _symbol_create_list(SQL_COMPARE, l ); }
- | pred_exp DISTINCT FROM pred_exp
-   { dlist *l = L();
- append_symbol(l, $1);
- append_string(l, sa_strdup(SA, "="));
- append_symbol(l, $4);
  append_int(l, 3);
  $$ = _symbol_create_list(SQL_COMPARE, l ); }
  ;
diff --git a/sql/test/2024/Tests/distinct_from.test 
b/sql/test/2024/Tests/distinct_from.test
--- a/sql/test/2024/Tests/distinct_from.test
+++ b/sql/test/2024/Tests/distinct_from.test
@@ -3,69 +3,69 @@ create table foo(s) as values (10), (20)
 
 
 query I nosort
-SELECT 10 NOT DISTINCT FROM 20
+SELECT 10 IS NOT DISTINCT FROM 20
 
 0
 
 query I nosort
-SELECT 10 DISTINCT FROM 20
+SELECT 10 IS DISTINCT FROM 20
 
 1
 
 
 query I nosort
-SELECT 10 DISTINCT FROM NULL
+SELECT 10 IS DISTINCT FROM NULL
 
 1
 
 query I nosort
-SELECT NULL DISTINCT FROM 20
+SELECT NULL IS DISTINCT FROM 20
 
 1
 
 query I nosort
-SELECT 10 NOT DISTINCT FROM NULL
+SELECT 10 IS NOT DISTINCT FROM NULL
 
 0
 
 query I nosort
-SELECT NULL NOT DISTINCT FROM 20
+SELECT NULL IS NOT DISTINCT FROM 20
 
 0
 
 query I nosort
-SELECT NULL DISTINCT FROM NULL
+SELECT NULL IS DISTINCT FROM NULL
 
 0
 
 query I nosort
-SELECT NULL NOT DISTINCT FROM NULL
+SELECT NULL IS NOT DISTINCT FROM NULL
 
 1
 
 query I nosort
-select s NOT DISTINCT FROM 20 FROM foo;
+select s IS NOT DISTINCT FROM 20 FROM foo;
 
 0
 1
 0
 
 query I nosort
-select s DISTINCT FROM 20 FROM foo;
+select s IS DISTINCT FROM 20 FROM foo;
 
 1
 0
 1
 
 query I nosort
-select s NOT DISTINCT FROM NULL FROM foo;
+select s IS NOT DISTINCT FROM NULL FROM foo;
 
 0
 0
 1
 
 query I nosort
-select s DISTINCT FROM NULL FROM foo;
+select s IS DISTINCT FROM NULL FROM foo;
 
 1
 1
@@ -73,28 +73,28 @@ 0
 
 
 query I nosort
-select 20 NOT DISTINCT FROM s FROM foo;
+select 20 IS NOT DISTINCT FROM s FROM foo;
 
 0
 1
 0
 
 query I nosort
-select 20 DISTINCT FROM s FROM foo;
+select 20 IS DISTINCT FROM s FROM foo;
 
 1
 0
 1
 
 query I nosort
-select NULL NOT DISTINCT FROM s FROM foo;
+select NULL IS NOT DISTINCT FROM s FROM foo;
 
 0
 0
 1
 
 query I nosort
-select NULL DISTINCT FROM s FROM foo;
+select NULL IS DISTINCT FROM s FROM foo;
 
 1
 1
___
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org


MonetDB: distinct_from - merge with default

2024-03-18 Thread Yunus Koning via checkin-list
Changeset: 28e490654c9b for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/28e490654c9b
Modified Files:
sql/server/rel_select.c
sql/server/sql_parser.y
Branch: distinct_from
Log Message:

merge with default


diffs (truncated from 6323 to 300 lines):

diff --git a/.hgtags b/.hgtags
--- a/.hgtags
+++ b/.hgtags
@@ -821,3 +821,4 @@ c9e6096e7519636a4e840c7a0c2e27cccb7dc0fe
 1230526af30f40eeea30fb87c47c3e414920561f Dec2023_1
 1230526af30f40eeea30fb87c47c3e414920561f Dec2023_release
 95d8feaa1167b5ba87bd99253c3f4e62ebf528a1 Dec2023_3
+dcc8c702e685a4faf21ccf663028d1bc3d1165d1 Dec2023_5
diff --git a/MonetDB.spec b/MonetDB.spec
--- a/MonetDB.spec
+++ b/MonetDB.spec
@@ -917,6 +917,26 @@ fi
 %endif
 
 %changelog
+* Tue Mar 12 2024 Sjoerd Mullender  - 11.49.5-20240312
+- Rebuilt.
+- GH#7390: Some MonetDB Server crashes found
+- GH#7465: Unexpected result when using `NULL` in `BETWEEN`
+
+* Fri Mar  8 2024 Sjoerd Mullender  - 11.49.5-20240312
+- gdk: The internal hash function for floating point types has been changed.
+  It is now no longer based on the bit representation, but on the value,
+  meaning that +0 and -0 (yes, they both exist in floating point) now
+  hash to the same value.
+
+* Thu Mar  7 2024 Lucas Pereira  - 
11.49.5-20240312
+- sql: performance improvement of 'startswith' and 'endswith' filter functions
+  for join operators
+
+* Wed Mar  6 2024 Sjoerd Mullender  - 11.49.5-20240312
+- clients: Fixed an issue where mclient wouldn't exit if the server it had
+  connected to exited for whatever reason while the client was waiting
+  for a query result.
+
 * Mon Mar 04 2024 Sjoerd Mullender  - 11.49.3-20240304
 - Rebuilt.
 - GH#6800: Please add information_schema (ANSI SQL norm)
diff --git a/clients/ChangeLog-Archive b/clients/ChangeLog-Archive
--- a/clients/ChangeLog-Archive
+++ b/clients/ChangeLog-Archive
@@ -1,6 +1,11 @@
 # DO NOT EDIT THIS FILE -- MAINTAINED AUTOMATICALLY
 # This file contains past ChangeLog entries
 
+* Wed Mar  6 2024 Sjoerd Mullender  - 11.49.5-20240312
+- Fixed an issue where mclient wouldn't exit if the server it had
+  connected to exited for whatever reason while the client was waiting
+  for a query result.
+
 * Tue Jun 20 2023 Sjoerd Mullender  - 11.47.3-20230622
 - The COPY INTO from file ON CLIENT was extended to also look for a
   relative path name relative to the file from which the query was read.
diff --git a/clients/ChangeLog.Dec2023 b/clients/ChangeLog.Dec2023
--- a/clients/ChangeLog.Dec2023
+++ b/clients/ChangeLog.Dec2023
@@ -1,8 +1,3 @@
 # ChangeLog file for clients
 # This file is updated with Maddlog
 
-* Wed Mar  6 2024 Sjoerd Mullender 
-- Fixed an issue where mclient wouldn't exit if the server it had
-  connected to exited for whatever reason while the client was waiting
-  for a query result.
-
diff --git a/clients/Tests/MAL-signatures-hge.test 
b/clients/Tests/MAL-signatures-hge.test
--- a/clients/Tests/MAL-signatures-hge.test
+++ b/clients/Tests/MAL-signatures-hge.test
@@ -50692,17 +50692,7 @@ str
 contains
 pattern str.contains(X_0:str, X_1:str, X_2:bit):bit 
 STRcontains;
-Check if string chaystack contains string needle, icase flag.
-str
-containsjoin
-pattern str.containsjoin(X_0:bat[:str], X_1:bat[:str], X_2:bat[:bit], 
X_3:bat[:oid], X_4:bat[:oid], X_5:bit, X_6:lng, X_7:bit):bat[:oid] 
-STRcontainsjoin1;
-The same as STRcontainsjoin, but only produce one output + icase.
-str
-containsjoin
-pattern str.containsjoin(X_0:bat[:str], X_1:bat[:str], X_2:bat[:oid], 
X_3:bat[:oid], X_4:bit, X_5:lng, X_6:bit):bat[:oid] 
-STRcontainsjoin1;
-The same as STRcontainsjoin, but only produce one output.
+Check if string haystack contains string needle, icase flag.
 str
 containsjoin
 pattern str.containsjoin(X_0:bat[:str], X_1:bat[:str], X_2:bat[:bit], 
X_3:bat[:oid], X_4:bat[:oid], X_5:bit, X_6:lng, X_7:bit) (X_8:bat[:oid], 
X_9:bat[:oid]) 
@@ -50710,10 +50700,20 @@ STRcontainsjoin;
 Join the string bat L with the bat R if L contains the string of R@with 
optional candidate lists SL and SR@The result is two aligned bats with oids of 
matching rows + icase.
 str
 containsjoin
+pattern str.containsjoin(X_0:bat[:str], X_1:bat[:str], X_2:bat[:bit], 
X_3:bat[:oid], X_4:bat[:oid], X_5:bit, X_6:lng, X_7:bit):bat[:oid] 
+STRcontainsjoin;
+The same as STRcontainsjoin, but only produce one output + icase.
+str
+containsjoin
 pattern str.containsjoin(X_0:bat[:str], X_1:bat[:str], X_2:bat[:oid], 
X_3:bat[:oid], X_4:bit, X_5:lng, X_6:bit) (X_7:bat[:oid], X_8:bat[:oid]) 
 STRcontainsjoin;
 Join the string bat L with the bat R if L contains the string of R@with 
optional candidate lists SL and SR@The result is two aligned bats with oids of 
matching rows.
 str
+containsjoin
+pattern str.containsjoin(X_0:bat[:str], X_1:bat[:str], X_2:bat[:oid], 
X_3:bat[:oid], X_4:bit, X_5:lng, X_6:bit):bat[:oid] 
+STRcontainsjoin;
+The same as STRcontainsjoin, but only produce one output.
+str
 containsselect
 pattern str.containsselect(X_0:bat[:str], X_1:bat[:oid], X_2:str, 

MonetDB: distinct_from - add tests for distinct from

2024-03-15 Thread Yunus Koning via checkin-list
Changeset: 79dc1362b568 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/79dc1362b568
Added Files:
sql/test/2024/Tests/distinct_from.test
Modified Files:
sql/test/2024/Tests/All
Branch: distinct_from
Log Message:

add tests for distinct from


diffs (112 lines):

diff --git a/sql/test/2024/Tests/All b/sql/test/2024/Tests/All
--- a/sql/test/2024/Tests/All
+++ b/sql/test/2024/Tests/All
@@ -1,1 +1,2 @@
 groupby_primary_key_project_unique_key
+distinct_from
diff --git a/sql/test/2024/Tests/distinct_from.test 
b/sql/test/2024/Tests/distinct_from.test
new file mode 100644
--- /dev/null
+++ b/sql/test/2024/Tests/distinct_from.test
@@ -0,0 +1,101 @@
+statement ok
+create table foo(s) as values (10), (20), (NULL)
+
+
+query I nosort
+SELECT 10 NOT DISTINCT FROM 20
+
+0
+
+query I nosort
+SELECT 10 DISTINCT FROM 20
+
+1
+
+
+query I nosort
+SELECT 10 DISTINCT FROM NULL
+
+1
+
+query I nosort
+SELECT NULL DISTINCT FROM 20
+
+1
+
+query I nosort
+SELECT 10 NOT DISTINCT FROM NULL
+
+0
+
+query I nosort
+SELECT NULL NOT DISTINCT FROM 20
+
+0
+
+query I nosort
+SELECT NULL DISTINCT FROM NULL
+
+0
+
+query I nosort
+SELECT NULL NOT DISTINCT FROM NULL
+
+1
+
+query I nosort
+select s NOT DISTINCT FROM 20 FROM foo;
+
+0
+1
+0
+
+query I nosort
+select s DISTINCT FROM 20 FROM foo;
+
+1
+0
+1
+
+query I nosort
+select s NOT DISTINCT FROM NULL FROM foo;
+
+0
+0
+1
+
+query I nosort
+select s DISTINCT FROM NULL FROM foo;
+
+1
+1
+0
+
+
+query I nosort
+select 20 NOT DISTINCT FROM s FROM foo;
+
+0
+1
+0
+
+query I nosort
+select 20 DISTINCT FROM s FROM foo;
+
+1
+0
+1
+
+query I nosort
+select NULL NOT DISTINCT FROM s FROM foo;
+
+0
+0
+1
+
+query I nosort
+select NULL DISTINCT FROM s FROM foo;
+
+1
+1
+0
___
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org


MonetDB: distinct_from - fix a small bug in rel_bin

2024-03-15 Thread Yunus Koning via checkin-list
Changeset: baa413524428 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/baa413524428
Modified Files:
sql/backends/monet5/rel_bin.c
Branch: distinct_from
Log Message:

fix a small bug in rel_bin


diffs (14 lines):

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
@@ -1831,8 +1831,8 @@ exp_bin(backend *be, sql_exp *e, stmt *l

   tail_type(l), tail_type(l), F_FUNC, true, true);
assert(f);
if (is_semantics(e)) {
-   if (exp_is_null(e->l) && 
exp_is_null(e->r)) {
-   s = stmt_bool(be, 
!is_anti(e));
+   if (exp_is_null(e->l) && 
exp_is_null(e->r) && (e->flag == cmp_equal || e->flag == cmp_notequal)) {
+   s = stmt_bool(be, 
e->flag == cmp_equal ? !is_anti(e): is_anti(e));
} else {
list *args = 
sa_list(sql->sa);
if (args == NULL)
___
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org


MonetDB: distinct_from - implement [NOT] DISTINCT FROM

2024-03-12 Thread Yunus Koning via checkin-list
Changeset: 6e6920aab279 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/6e6920aab279
Modified Files:
sql/server/rel_select.c
sql/server/sql_parser.y
Branch: distinct_from
Log Message:

implement [NOT] DISTINCT FROM


diffs (71 lines):

diff --git a/sql/server/rel_select.c b/sql/server/rel_select.c
--- a/sql/server/rel_select.c
+++ b/sql/server/rel_select.c
@@ -2367,6 +2367,8 @@ rel_logical_value_exp(sql_query *query, 
int quantifier = 0, need_not = 0;
sql_exp *rs = NULL, *ls;
comp_type cmp_type = compare_str2type(compare_op);
+   bool is_not_distinct_from = false;
+   bool is_distinct_from = false;
 
/*
 * = ANY -> IN, <> ALL -> NOT( = ANY) -> NOT IN
@@ -2374,7 +2376,17 @@ rel_logical_value_exp(sql_query *query, 
 */
if (n->next->next->next)
quantifier = n->next->next->next->data.i_val + 1;
-   assert(quantifier == 0 || quantifier == 1 || quantifier == 2);
+   assert(quantifier == 0 || quantifier == 1 || quantifier == 2 || 
quantifier == 3 || quantifier == 4);
+
+   /* [NOT] DISTINCT FROM */
+   if (quantifier == 3) {
+   is_not_distinct_from = true;
+   quantifier = 0;
+   }
+   else if (quantifier == 4) {
+   is_distinct_from = true;
+   quantifier = 0;
+   }
 
if ((quantifier == 1 && cmp_type == cmp_equal) ||
(quantifier == 2 && cmp_type == cmp_notequal)) {
@@ -2405,6 +2417,15 @@ rel_logical_value_exp(sql_query *query, 
rs = rel_value_exp(query, rel, ro, f|sql_farg, ek);
if (!rs)
return NULL;
+
+   if (is_distinct_from || is_not_distinct_from) {
+   if (rel_convert_types(sql, rel ? *rel : NULL, rel ? 
*rel : NULL, , , 1, type_equal_no_any) < 0)
+   return NULL;
+   sql_exp* e = exp_compare(sql->sa, ls, rs, 
is_not_distinct_from?cmp_equal:cmp_notequal);
+   set_semantics(e);
+   return e;
+   }
+
if (rs->type == e_atom)
quantifier = 0;
 
diff --git a/sql/server/sql_parser.y b/sql/server/sql_parser.y
--- a/sql/server/sql_parser.y
+++ b/sql/server/sql_parser.y
@@ -3900,6 +3900,20 @@ comparison_predicate:
  append_symbol(l, $5);
  append_int(l, $3);
  $$ = _symbol_create_list(SQL_COMPARE, l ); }
+ | pred_exp NOT DISTINCT FROM pred_exp
+   { dlist *l = L();
+ append_symbol(l, $1);
+ append_string(l, sa_strdup(SA, "="));
+ append_symbol(l, $5);
+ append_int(l, 2);
+ $$ = _symbol_create_list(SQL_COMPARE, l ); }
+ | pred_exp DISTINCT FROM pred_exp
+   { dlist *l = L();
+ append_symbol(l, $1);
+ append_string(l, sa_strdup(SA, "="));
+ append_symbol(l, $4);
+ append_int(l, 3);
+ $$ = _symbol_create_list(SQL_COMPARE, l ); }
  ;
 
 between_predicate:
___
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org


MonetDB: distinct_from - new branch distinct_from

2024-03-12 Thread Yunus Koning via checkin-list
Changeset: 53912a590330 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/53912a590330
Branch: distinct_from
Log Message:

new branch distinct_from

___
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org


MonetDB: default - merge with literal_features

2024-03-06 Thread Yunus Koning via checkin-list
Changeset: 98f0077d3b10 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/98f0077d3b10
Branch: default
Log Message:

merge with literal_features


diffs (truncated from 474 to 300 lines):

diff --git a/sql/ChangeLog b/sql/ChangeLog
--- a/sql/ChangeLog
+++ b/sql/ChangeLog
@@ -1,3 +1,12 @@
 # ChangeLog file for sql
 # This file is updated with Maddlog
 
+* Wed Mar  6 2024 Yunus Koning 
+- SQL2023 feature: Introduce UNIQUE NULLS [NOT] DISTINCT syntax which
+  allows for NULLS to be treated as unique, i.e. a column with this
+  contraint can have one NULL value at most.
+
+- SQL2023 feature: Allow project and ORDER BY expressions on
+  UNIQUE constrained columns when the primary key column is
+  used in a GROUP BY expression.
+
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
@@ -4654,7 +4654,9 @@ insert_check_ukey(backend *be, list *ins
stmt_add_column_predicate(be, c->c);
 
col = stmt_col(be, c->c, dels, dels->partition);
-   if ((k->type == ukey) && stmt_has_null(col)) {
+   if (k->type == unndkey)
+   s = stmt_uselect(be, col, cs, 
cmp_equal, s, 0, 1);
+   else if ((k->type == ukey) && 
stmt_has_null(col)) {
stmt *nn = stmt_selectnonil(be, col, s);
s = stmt_uselect(be, col, cs, 
cmp_equal, nn, 0, 0);
} else {
@@ -4679,7 +4681,7 @@ insert_check_ukey(backend *be, list *ins
list_append(lje, col);
list_append(rje, cs);
}
-   s = releqjoin(be, lje, rje, NULL, 1 /* hash used */, 0, 
0);
+   s = releqjoin(be, lje, rje, NULL, 1 /* hash used */, 0, 
k->type == unndkey? 1: 0);
s = stmt_result(be, s, 0);
}
s = stmt_binop(be, stmt_aggr(be, s, NULL, NULL, cnt, 1, 0, 1), 
stmt_atom_lng(be, 0), NULL, ne);
@@ -4743,12 +4745,12 @@ insert_check_ukey(backend *be, list *ins
s = stmt_project(be, nn, s);
}
if (h->nrcols) {
-   s = stmt_join(be, s, h, 0, cmp_equal, 0, 0, false);
+   s = stmt_join(be, s, h, 0, cmp_equal, 0, k->type == 
unndkey? 1: 0, false);
/* s should be empty */
s = stmt_result(be, s, 0);
s = stmt_aggr(be, s, NULL, NULL, cnt, 1, 0, 1);
} else {
-   s = stmt_uselect(be, s, h, cmp_equal, NULL, 0, 0);
+   s = stmt_uselect(be, s, h, cmp_equal, NULL, 0, k->type 
== unndkey? 1: 0);
/* s should be empty */
s = stmt_aggr(be, s, NULL, NULL, cnt, 1, 0, 1);
}
@@ -4855,7 +4857,7 @@ sql_insert_key(backend *be, list *insert
 *  insert values
 *  insert fkey/pkey index
 */
-   if (k->type == pkey || k->type == ukey) {
+   if (k->type == pkey || k->type == ukey || k->type == unndkey) {
return insert_check_ukey(be, inserts, k, idx_inserts);
} else {/* foreign keys */
return insert_check_fkey(be, inserts, k, idx_inserts, pin);
diff --git a/sql/include/sql_catalog.h b/sql/include/sql_catalog.h
--- a/sql/include/sql_catalog.h
+++ b/sql/include/sql_catalog.h
@@ -523,8 +523,9 @@ typedef struct sql_subfunc {
 
 typedef enum key_type {
pkey,
-   ukey,
-   fkey
+   ukey, /* default behavior is that NULLS are distinct, e.g. there can be 
multiple null values in a column with regular UNIQUE constraint */
+   fkey,
+   unndkey /* NULLS are not distinct, i.e. NULLS act as regular values for 
uniqueness checks */
 } key_type;
 
 typedef struct sql_kc {
diff --git a/sql/server/rel_schema.c b/sql/server/rel_schema.c
--- a/sql/server/rel_schema.c
+++ b/sql/server/rel_schema.c
@@ -327,6 +327,9 @@ column_constraint_name(mvc *sql, symbol 
case SQL_UNIQUE:
suffix = "unique";
break;
+   case SQL_UNIQUE_NULLS_NOT_DISTINCT:
+   suffix = "nndunique";
+   break;
case SQL_PRIMARY_KEY:
suffix = "pkey";
break;
@@ -368,8 +371,9 @@ column_constraint_type(mvc *sql, const c
}
switch (s->token) {
case SQL_UNIQUE:
+   case SQL_UNIQUE_NULLS_NOT_DISTINCT:
case SQL_PRIMARY_KEY: {
-   key_type kt = (s->token == SQL_UNIQUE) ? ukey : pkey;
+   key_type kt = (s->token == SQL_UNIQUE) ? ukey : (s->token == 
SQL_UNIQUE_NULLS_NOT_DISTINCT) ? unndkey : pkey;
 

MonetDB: literal_features - Add ChangeLog entry.

2024-03-06 Thread Yunus Koning via checkin-list
Changeset: 9c6a085c9b6c for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/9c6a085c9b6c
Modified Files:
sql/ChangeLog
Branch: literal_features
Log Message:

Add ChangeLog entry.


diffs (16 lines):

diff --git a/sql/ChangeLog b/sql/ChangeLog
--- a/sql/ChangeLog
+++ b/sql/ChangeLog
@@ -1,3 +1,12 @@
 # ChangeLog file for sql
 # This file is updated with Maddlog
 
+* Wed Mar  6 2024 Yunus Koning 
+- SQL2023 feature: Introduce UNIQUE NULLS [NOT] DISTINCT syntax which
+  allows for NULLS to be treated as unique, i.e. a column with this
+  contraint can have one NULL value at most.
+
+- SQL2023 feature: Allow project and ORDER BY expressions on
+  UNIQUE constrained columns when the primary key column is
+  used in a GROUP BY expression.
+
___
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org


MonetDB: literal_features - merge with default

2024-03-05 Thread Yunus Koning via checkin-list
Changeset: e6c5993ce41c for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/e6c5993ce41c
Modified Files:
sql/server/rel_schema.c
Branch: literal_features
Log Message:

merge with default


diffs (truncated from 840 to 300 lines):

diff --git a/.hgtags b/.hgtags
--- a/.hgtags
+++ b/.hgtags
@@ -820,3 +820,4 @@ c9e6096e7519636a4e840c7a0c2e27cccb7dc0fe
 c9e6096e7519636a4e840c7a0c2e27cccb7dc0fe Jun2023_SP3_release
 1230526af30f40eeea30fb87c47c3e414920561f Dec2023_1
 1230526af30f40eeea30fb87c47c3e414920561f Dec2023_release
+95d8feaa1167b5ba87bd99253c3f4e62ebf528a1 Dec2023_3
diff --git a/ChangeLog-Archive b/ChangeLog-Archive
--- a/ChangeLog-Archive
+++ b/ChangeLog-Archive
@@ -1,6 +1,12 @@
 # DO NOT EDIT THIS FILE -- MAINTAINED AUTOMATICALLY
 # This file contains past ChangeLog entries
 
+* Thu Jan 11 2024 Sjoerd Mullender  - 11.49.3-20240304
+- The copyright for the MonetDB software has been transferred to the newly
+  established MonetDB Foundation, a not-for-profit foundation with the
+  express goal of furthering the MonetDB database system.  The license
+  for the software does not change: MonetDB remains fully open source.
+
 * Fri Dec  1 2023 Sjoerd Mullender  - 11.49.1-20231221
 - All binary packages are now signed with a new key with key fingerprint
   DBCE 5625 94D7 1959 7B54  CE85 3F1A D47F 5521 A603.
diff --git a/MonetDB.spec b/MonetDB.spec
--- a/MonetDB.spec
+++ b/MonetDB.spec
@@ -91,7 +91,7 @@ Group: Applications/Databases
 License: MPL-2.0
 URL: https://www.monetdb.org/
 BugURL: https://github.com/MonetDB/MonetDB/issues
-Source: 
https://www.monetdb.org/downloads/sources/Dec2023/%{name}-%{version}.tar.bz2
+Source: 
https://www.monetdb.org/downloads/sources/Dec2023-SP1/%{name}-%{version}.tar.bz2
 
 # The Fedora packaging document says we need systemd-rpm-macros for
 # the _unitdir and _tmpfilesdir macros to exist; however on RHEL 7
@@ -917,6 +917,69 @@ fi
 %endif
 
 %changelog
+* Mon Mar 04 2024 Sjoerd Mullender  - 11.49.3-20240304
+- Rebuilt.
+- GH#6800: Please add information_schema (ANSI SQL norm)
+- GH#7152: Occasional dbfarm corruption upon database restart
+- GH#7412: MonetDB server crashes in `vscanf`
+- GH#7415: MonetDB server crashes in `HEAP_malloc`
+- GH#7416: MonetDB server crashes in `atom_get_int`
+- GH#7417: MonetDB server crashes in `trimchars`.
+- GH#7418: MonetDB server crashes in `bind_col_exp`
+- GH#7420: Performance issue with lower(string)
+- GH#7425: The last statement, execution error, is a false positive?
+- GH#7426: Unexpected result for INNER JOIN with IS NOT NULL
+- GH#7428: Unexpected result when using BETWEEN operator
+- GH#7429: Unexpected result when using `CASE WHEN`
+- GH#7430: Unexpected result when using `AND` and `IS NOT NULL`
+- GH#7431: [bug] Error code found, please confirm
+- GH#7432: MonetDB server crashes in `dameraulevenshtein`
+- GH#7433: MonetDB server crashes in `exp_atom`
+- GH#7434: MonetDB server crashes in `exp_bin`
+- GH#7435: MonetDB server crashes in `exp_copy`
+- GH#7436: MonetDB server crashes in `exp_ref`
+- GH#7437: MonetDB server crashes in `exp_values_set_supertype`
+- GH#7438: MonetDB server crashes in `exps_bind_column`
+- GH#7439: MonetDB server crashes in `exps_card`
+- GH#7440: MonetDB server crashes in `gc_col`
+- GH#7441: MonetDB server crashes in `is_column_unique`
+- GH#7442: MonetDB server crashes in `mat_join2`
+- GH#7443: MonetDB server crashes in `merge_table_prune_and_unionize`
+- GH#7444: [bug] the table cannot be created because the reserved word is
+  incorrectly set
+- GH#7447: Unexpected result when using `BETWEEN` in `INNER JOIN`
+- GH#7448: Unexpected result when using `AND`/`OR` chain
+- GH#7450: Unexpected result when `CREATE VIEW` with `WHERE NULL`
+- GH#7451: Unexpected result when using `BETWEEN` and `CAST`
+- GH#7453: Cannot recover an msqldump
+- GH#7455: Unexpected result when using `BETWEEN` with `BOOLEAN` values
+- GH#7456: Crash when `INNER JOIN` with `VIEW`
+- GH#7457: Unexpected result when using `AND` with `INTEGER`
+- GH#7458: Unexpected result when using `SIGN`
+- GH#7461: Crash by potentially use of bad escape characters
+- GH#7462: Crash when using `BETWEEN AND`
+
+* Fri Mar  1 2024 Sjoerd Mullender  - 11.49.3-20240304
+- gdk: Fixed a regression where bats weren't always cleaned up when they
+  weren't needed anymore.  In particular, after a DELETE FROM table query
+  without a WHERE clause (which deletes all rows from the table), the
+  bats for the table get replaced by new ones, and the old, now unused,
+  bats weren't removed from the database.
+
+* Mon Jan 15 2024 Sjoerd Mullender  - 11.49.3-20240304
+- geom: We switched over to using the reentrant interface of the geos library.
+  This fixed a number of bugs that would occur sporadically.
+
+* Mon Jan 15 2024 Sjoerd Mullender  - 11.49.3-20240304
+- sql: The function json.isvalid(json) incorrectly returned true if the
+  argument was null.  It should return null.
+
+* Thu Jan 11 2024 Sjoerd Mullender  - 11.49.3-20240304
+- MonetDB: The 

MonetDB: literal_features - Add tests

2024-03-05 Thread Yunus Koning via checkin-list
Changeset: 89d7ec68f10a for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/89d7ec68f10a
Added Files:
sql/test/2024/Tests/All
sql/test/2024/Tests/groupby_primary_key_project_unique_key.test
Branch: literal_features
Log Message:

Add tests


diffs (74 lines):

diff --git a/sql/test/2024/Tests/All b/sql/test/2024/Tests/All
new file mode 100644
--- /dev/null
+++ b/sql/test/2024/Tests/All
@@ -0,0 +1,1 @@
+groupby_primary_key_project_unique_key
diff --git a/sql/test/2024/Tests/groupby_primary_key_project_unique_key.test 
b/sql/test/2024/Tests/groupby_primary_key_project_unique_key.test
new file mode 100644
--- /dev/null
+++ b/sql/test/2024/Tests/groupby_primary_key_project_unique_key.test
@@ -0,0 +1,63 @@
+statement ok
+CREATE TABLE IF NOT EXISTS product (
+   product_id int PRIMARY KEY,
+   product_name varchar,
+   product_code varchar UNIQUE
+)
+
+
+statement ok
+CREATE TABLE IF NOT EXISTS product_part (
+   product_id int,
+   part_id int,
+   num int,
+   PRIMARY KEY (product_id, part_id)
+)
+
+
+statement ok
+insert into product values
+(1, 'telephone1', 'telepone1'),
+(2, 'telephone2', 'telepone2'),
+(3, 'telephone3', NULL),
+(4, 'telephone4', NULL)
+
+
+statement ok
+insert into product_part values
+(1, 10, 100),
+(1, 20, 200),
+(2, 10, 100),
+(2, 20, 200),
+(2, 30, 300),
+(3, 10, 100),
+(4, 10, 100),
+(4, 20, 200),
+(4, 30, 300)
+
+
+query II nosort
+SELECT product.product_id, sum(product_part.num) as sum_num
+FROM product JOIN product_part ON product.product_id = product_part.product_id
+GROUP BY product.product_id
+ORDER BY product.product_code, product.product_id
+
+3
+100
+4
+600
+1
+300
+2
+600
+
+statement error
+SELECT product.product_id, sum(product_part.num) as sum_num
+FROM
+(SELECT * FROM product UNION ALL VALUES (1, 'telephone5', 
'telephone5')) AS product 
+JOIN
+product_part
+ON product.product_id = product_part.product_id
+GROUP BY product.product_id
+ORDER BY product.product_code, product.product_id
+
___
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org


MonetDB: literal_features - do less work

2024-03-01 Thread Yunus Koning via checkin-list
Changeset: c4ed4853fb79 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/c4ed4853fb79
Modified Files:
sql/server/rel_select.c
Branch: literal_features
Log Message:

do less work


diffs (34 lines):

diff --git a/sql/server/rel_select.c b/sql/server/rel_select.c
--- a/sql/server/rel_select.c
+++ b/sql/server/rel_select.c
@@ -1260,19 +1260,23 @@ bool group_by_pk_project_uk_cond(mvc* sq
if (uki->columns->cnt == 1) {
/* for now only check simple 
case where unique key is a single column*/
sql_column* ukc = ((sql_kc 
*)uki->columns->h->data)->c;
-   if (strcmp(exp->alias.name, 
ukc->base.name) == 0)
+   if (strcmp(exp->alias.name, 
ukc->base.name) == 0) {
allow = true;
+   break;
+   }
}
}
}
}
 
-   /* sufficiency condition: abort if relation contains union 
subrelation
-* because it may break functional dependency between pk and uk 
*/
-   visitor v = {.sql=sql};
-   rel_visitor_topdown(, inner, _union);
-   if (v.data)
-   allow = false;
+   if (allow) {
+   /* sufficiency condition: abort if relation contains 
union subrelation
+   * because it may break functional dependency between pk 
and uk */
+   visitor v = {.sql=sql};
+   rel_visitor_topdown(, inner, _union);
+   if (v.data)
+   allow = false;
+   }
}
 
return allow;
___
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org


MonetDB: literal_features - merge with default

2024-03-01 Thread Yunus Koning via checkin-list
Changeset: 40841b1e3dd9 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/40841b1e3dd9
Branch: literal_features
Log Message:

merge with default


diffs (truncated from 2024 to 300 lines):

diff --git a/gdk/gdk_heap.c b/gdk/gdk_heap.c
--- a/gdk/gdk_heap.c
+++ b/gdk/gdk_heap.c
@@ -217,6 +217,7 @@ HEAPalloc(Heap *h, size_t nitems, size_t
return GDK_FAIL;
}
GDKfree(nme);
+   TRC_DEBUG(HEAP, "%s %zu %p (mmap)\n", h->filename, size, 
h->base);
}
h->newstorage = h->storage;
return GDK_SUCCEED;
diff --git a/geom/monetdb5/geom_atoms.c b/geom/monetdb5/geom_atoms.c
--- a/geom/monetdb5/geom_atoms.c
+++ b/geom/monetdb5/geom_atoms.c
@@ -272,8 +272,8 @@ wkbFROMSTR_withSRID(const char *geomWKT,
 {
GEOSGeom geosGeometry = NULL;   /* The geometry object that is parsed 
from the src string. */
GEOSWKTReader *WKT_reader;
-   const char *polyhedralSurface = "POLYHEDRALSURFACE";
-   const char *multiPolygon = "MULTIPOLYGON";
+   static const char polyhedralSurface[] = "POLYHEDRALSURFACE";
+   static const char multiPolygon[] = "MULTIPOLYGON";
char *geomWKT_new = NULL;
size_t parsedCharacters = 0;
 
diff --git a/monetdb5/modules/atoms/str.c b/monetdb5/modules/atoms/str.c
--- a/monetdb5/modules/atoms/str.c
+++ b/monetdb5/modules/atoms/str.c
@@ -111,7 +111,7 @@
  */
 
 /* These tables were generated from the Unicode 13.0.0 spec. */
-const struct UTF8_lower_upper {
+static const struct UTF8_lower_upper {
const unsigned int from, to;
 } UTF8_toUpper[] = {   /* code points with non-null uppercase 
conversion */
{0x0061, 0x0041,},
diff --git a/monetdb5/modules/mal/Tests/qgram.maltest 
b/monetdb5/modules/mal/Tests/qgram.maltest
--- a/monetdb5/modules/mal/Tests/qgram.maltest
+++ b/monetdb5/modules/mal/Tests/qgram.maltest
@@ -36,27 +36,27 @@ query IT rowsort
 io.print(b)
 
 0
-##h@
+##hä
 1
-#h@l
+#häl
 10
-r@@$
+rłð$
 11
-@@$$
+łð$$
 2
-h@ll
+häll
 3
-@ll@
+ällö
 4
-ll@ 
+llö 
 5
-l@ w
+lö w
 6
-@ w@
+ö wø
 7
- w@r
+ wør
 8
-w@r@
+wørł
 9
-@r@@
+ørłð
 
diff --git a/sql/backends/monet5/UDF/pyapi3/Tests/pyloader3_05.test 
b/sql/backends/monet5/UDF/pyapi3/Tests/pyloader3_05.test
--- a/sql/backends/monet5/UDF/pyapi3/Tests/pyloader3_05.test
+++ b/sql/backends/monet5/UDF/pyapi3/Tests/pyloader3_05.test
@@ -54,9 +54,6 @@ 33
 33.00
 42
 42.00
-@
-@
-@
 hello
 hello
 hello
@@ -64,6 +61,9 @@ hello
 hello
 hello
 hello
+Ö
+Ö
+Ö
 
 statement ok
 DROP TABLE pyloader05table
diff --git a/sql/benchmarks/tpcds/Tests/one.test.in 
b/sql/benchmarks/tpcds/Tests/one.test.in
--- a/sql/benchmarks/tpcds/Tests/one.test.in
+++ b/sql/benchmarks/tpcds/Tests/one.test.in
@@ -4616,7 +4616,7 @@ with customer_total_return as
   ,c_last_review_date,ctr_total_return
 limit 100
 
-1300 values hashing to 4b80e4995150e5b42229a363bb57dd07
+1300 values hashing to 46f76e63ac60a7b540f258c4ad0fbfdb
 
 query TI rowsort
 -- query 31
diff --git 
a/sql/test/BugDay_2005-10-06_2.9.3/Tests/accents_in_strings.SF-926709.test 
b/sql/test/BugDay_2005-10-06_2.9.3/Tests/accents_in_strings.SF-926709.test
--- a/sql/test/BugDay_2005-10-06_2.9.3/Tests/accents_in_strings.SF-926709.test
+++ b/sql/test/BugDay_2005-10-06_2.9.3/Tests/accents_in_strings.SF-926709.test
@@ -14,7 +14,7 @@ query IT rowsort
 SELECT * FROM bugtest
 
 1
-Andr@
+André
 1
 test
 
diff --git a/sql/test/BugTracker-2009/Tests/utf8_bug.SF-2822855.test 
b/sql/test/BugTracker-2009/Tests/utf8_bug.SF-2822855.test
--- a/sql/test/BugTracker-2009/Tests/utf8_bug.SF-2822855.test
+++ b/sql/test/BugTracker-2009/Tests/utf8_bug.SF-2822855.test
@@ -19,15 +19,15 @@ select a, length(a) AS len from utf8len
 
 0
 1
-@
+€
 1
-@
+€
 1
 
 query T rowsort
 select 'Liever €uro' as "Liever euro"
 
-Liever @uro
+Liever €uro
 
 statement ok
 drop table utf8len
diff --git a/sql/test/BugTracker-2014/Tests/BOM-in-string.Bug-3641.test 
b/sql/test/BugTracker-2014/Tests/BOM-in-string.Bug-3641.test
--- a/sql/test/BugTracker-2014/Tests/BOM-in-string.Bug-3641.test
+++ b/sql/test/BugTracker-2014/Tests/BOM-in-string.Bug-3641.test
@@ -6,5 +6,5 @@ select '  '
 query T rowsort
 select '  '
 
-  @
+  
 
diff --git a/sql/test/BugTracker-2015/Tests/import-non-ascii.Bug-3864.test 
b/sql/test/BugTracker-2015/Tests/import-non-ascii.Bug-3864.test
--- a/sql/test/BugTracker-2015/Tests/import-non-ascii.Bug-3864.test
+++ b/sql/test/BugTracker-2015/Tests/import-non-ascii.Bug-3864.test
@@ -16,9 +16,9 @@ query IT rowsort
 select * from varcharsize5
 
 1
-@
+不要让早把
 1
-@
+不要让早把
 
 statement ok
 rollback
diff --git a/sql/test/BugTracker-2017/Tests/splitpart.Bug-6194.test 
b/sql/test/BugTracker-2017/Tests/splitpart.Bug-6194.test
--- a/sql/test/BugTracker-2017/Tests/splitpart.Bug-6194.test
+++ b/sql/test/BugTracker-2017/Tests/splitpart.Bug-6194.test
@@ -1,5 +1,5 @@
 query T rowsort
 select splitpart('100-ača' , '-', 2)
 
-a@a
+ača
 
diff --git 

MonetDB: literal_features - factor out code and check multiple u...

2024-03-01 Thread Yunus Koning via checkin-list
Changeset: 43a0834f3796 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/43a0834f3796
Modified Files:
sql/server/rel_select.c
Branch: literal_features
Log Message:

factor out code and check multiple unique keys


diffs (115 lines):

diff --git a/sql/server/rel_select.c b/sql/server/rel_select.c
--- a/sql/server/rel_select.c
+++ b/sql/server/rel_select.c
@@ -1226,6 +1226,59 @@ sql_rel* find_union(visitor *v, sql_rel 
return rel;
 }
 
+static inline
+bool group_by_pk_project_uk_cond(mvc* sql, sql_rel* inner, sql_exp* exp,const 
char* sname, const char* tname) {
+   sql_table* t = find_table_or_view_on_scope(sql, NULL, sname, tname, 
"SELECT", false);
+   bool allow = false;
+   if (t) {
+   sql_idx* pki = NULL;
+   list *ukil = sa_list(sql->sa);
+
+   for (node * n = ol_first_node(t->idxs); n; n = n->next) {
+   sql_idx *i = n->data;
+   switch (i->key->type) {
+   case pkey:
+   pki = i;
+   continue;
+   case ukey:
+   case unndkey:
+   list_append(ukil, i);
+   continue;
+   default:
+   continue;
+   }
+   }
+   if (pki && pki->columns->cnt == 1 &&  ((list*) inner->r)->cnt 
== 1) {
+   /* for now only check simple case where primary key and 
group by expression is a single column*/
+   sql_exp* gbe = ((list*) inner->r)->h->data;
+   assert(gbe->type == e_column);
+   sql_column* pkc = ((sql_kc *)pki->columns->h->data)->c;
+   if (strcmp(gbe->alias.name, pkc->base.name) == 0) {
+   node *n;
+   for (n = ukil->h; n; n = n->next){
+   sql_idx* uki = n->data;
+   if (uki->columns->cnt == 1) {
+   /* for now only check simple 
case where unique key is a single column*/
+   sql_column* ukc = ((sql_kc 
*)uki->columns->h->data)->c;
+   if (strcmp(exp->alias.name, 
ukc->base.name) == 0)
+   allow = true;
+   }
+   }
+   }
+   }
+
+   /* sufficiency condition: abort if relation contains union 
subrelation
+* because it may break functional dependency between pk and uk 
*/
+   visitor v = {.sql=sql};
+   rel_visitor_topdown(, inner, _union);
+   if (v.data)
+   allow = false;
+   }
+
+   return allow;
+
+}
+
 static sql_exp *
 rel_column_ref(sql_query *query, sql_rel **rel, symbol *column_r, int f)
 {
@@ -1422,48 +1475,9 @@ rel_column_ref(sql_query *query, sql_rel
}
if (!exp) {
if (inner && !is_sql_aggr(f) && is_groupby(inner->op) 
&& inner->l && (exp = rel_bind_column3(sql, inner->l, sname, tname, cname, f))) 
{
-   sql_table* t = find_table_or_view_on_scope(sql, 
NULL, sname, tname, "SELECT", false);
-   bool check_pk_with_uk = false;
-   if (t) {
-   sql_idx* pki = NULL;
-   sql_idx* uki = NULL;
-   for (node * n = ol_first_node(t->idxs); 
n; n = n->next) {
-   sql_idx *i = n->data;
-
-   switch (i->key->type) {
-   case pkey:
-   pki = i;
-   continue;
-   case ukey:
-   case unndkey:
-   uki = i;
-   continue;
-   default:
-   continue;
-   }
-   }
-
-   if (uki && pki) {
-   if (pki->columns->cnt == 1 && 
uki->columns->cnt == 1 && ((list*) inner->r)->cnt == 1) {
-   sql_column* pkc = 
((sql_kc *)pki->columns->h->data)->c;
-   

MonetDB: literal_features - if union operator in plan, invalidat...

2024-02-29 Thread Yunus Koning via checkin-list
Changeset: 2a2f8910191d for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/2a2f8910191d
Modified Files:
sql/server/rel_select.c
Branch: literal_features
Log Message:

if union operator in plan, invalidate pk_uk_alignment


diffs (30 lines):

diff --git a/sql/server/rel_select.c b/sql/server/rel_select.c
--- a/sql/server/rel_select.c
+++ b/sql/server/rel_select.c
@@ -1219,6 +1219,13 @@ set_dependent_( sql_rel *r)
set_dependent(r);
 }
 
+static
+sql_rel* find_union(visitor *v, sql_rel *rel) {
+   if (rel->op == op_union)
+   v->data = rel;
+   return rel;
+}
+
 static sql_exp *
 rel_column_ref(sql_query *query, sql_rel **rel, symbol *column_r, int f)
 {
@@ -1448,6 +1455,12 @@ rel_column_ref(sql_query *query, sql_rel

check_pk_with_uk = true;
}
}
+   if (check_pk_with_uk) {
+   visitor v = {.sql=sql};
+   rel_visitor_topdown(, inner, 
_union);
+   if (v.data)
+   check_pk_with_uk = 
false;
+   }
}
 
if (check_pk_with_uk) {
___
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org


MonetDB: literal_features - merge with default

2024-02-27 Thread Yunus Koning via checkin-list
Changeset: fdb40ac745a4 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/fdb40ac745a4
Modified Files:
sql/server/rel_select.c
Branch: literal_features
Log Message:

merge with default


diffs (truncated from 1275 to 300 lines):

diff --git a/clients/Tests/exports.stable.out b/clients/Tests/exports.stable.out
--- a/clients/Tests/exports.stable.out
+++ b/clients/Tests/exports.stable.out
@@ -1728,7 +1728,6 @@ int mnstr_writeShtArray(stream *restrict
 int mnstr_writeStr(stream *restrict s, const char *restrict val);
 stream *open_rastream(const char *filename);
 stream *open_rstream(const char *filename);
-stream *open_urlstream(const char *url);
 stream *open_wastream(const char *filename);
 stream *open_wstream(const char *filename);
 stream *openssl_rstream(const char *hostname, BIO *bio);
diff --git a/clients/examples/C/CMakeLists.txt 
b/clients/examples/C/CMakeLists.txt
--- a/clients/examples/C/CMakeLists.txt
+++ b/clients/examples/C/CMakeLists.txt
@@ -46,7 +46,8 @@ add_executable(streamcat
 target_link_libraries(streamcat
   PRIVATE
   monetdb_config_header
-  stream)
+  stream
+  $<$:CURL::libcurl>)
 
 add_executable(testcondvar
   testcondvar.c)
diff --git a/clients/examples/C/streamcat.c b/clients/examples/C/streamcat.c
--- a/clients/examples/C/streamcat.c
+++ b/clients/examples/C/streamcat.c
@@ -436,6 +436,75 @@ opener_rastream(char *filename)
return s;
 }
 
+#ifdef HAVE_CURL
+#include 
+
+#ifndef CURL_WRITEFUNC_ERROR
+#define CURL_WRITEFUNC_ERROR 0
+#endif
+
+static size_t
+write_callback(char *buffer, size_t size, size_t nitems, void *userp)
+{
+   stream *s = userp;
+
+   /* size is expected to always be 1 */
+
+   ssize_t sz = mnstr_write(s, buffer, size, nitems);
+   if (sz < 0)
+   return CURL_WRITEFUNC_ERROR; /* indicate failure to library */
+   return (size_t) sz * size;
+}
+
+static stream *
+open_urlstream(const char *url)
+{
+   CURL *handle;
+   stream *s;
+   CURLcode ret;
+   char errbuf[CURL_ERROR_SIZE];
+
+   s = buffer_wastream(NULL, url);
+   if (s == NULL) {
+   return NULL;
+   }
+
+   if ((handle = curl_easy_init()) == NULL) {
+   mnstr_destroy(s);
+   return NULL;
+   }
+
+   errbuf[0] = 0;
+
+   if ((ret = curl_easy_setopt(handle, CURLOPT_ERRORBUFFER, errbuf)) != 
CURLE_OK ||
+   (ret = curl_easy_setopt(handle, CURLOPT_URL, url)) != CURLE_OK ||
+   (ret = curl_easy_setopt(handle, CURLOPT_WRITEDATA, s)) != CURLE_OK 
||
+   (ret = curl_easy_setopt(handle, CURLOPT_VERBOSE, 0)) != CURLE_OK ||
+   (ret = curl_easy_setopt(handle, CURLOPT_NOSIGNAL, 1)) != CURLE_OK ||
+   (ret = curl_easy_setopt(handle, CURLOPT_FAILONERROR, 1)) != 
CURLE_OK ||
+   (ret = curl_easy_setopt(handle, CURLOPT_WRITEFUNCTION, 
write_callback)) != CURLE_OK ||
+   (ret = curl_easy_perform(handle)) != CURLE_OK) {
+   curl_easy_cleanup(handle);
+   mnstr_destroy(s);
+   if (errbuf[0])
+   fprintf(stderr, "%s\n", errbuf);
+   else
+   fprintf(stderr, "%s\n", curl_easy_strerror(ret));
+   return NULL;
+   }
+   curl_easy_cleanup(handle);
+   (void) mnstr_get_buffer(s); /* switch to read-only */
+   return s;
+}
+#else
+static stream *
+open_urlstream(const char *url)
+{
+   (void) url;
+   return NULL;
+}
+#endif
+
 static stream *
 opener_urlstream(char *url)
 {
diff --git a/clients/mapiclient/CMakeLists.txt 
b/clients/mapiclient/CMakeLists.txt
--- a/clients/mapiclient/CMakeLists.txt
+++ b/clients/mapiclient/CMakeLists.txt
@@ -54,6 +54,7 @@ target_link_libraries(mclient
   mapi
   stream
   $<$:Readline::Readline>
+  $<$:CURL::libcurl>
   $<$:Iconv::Iconv>
   $<$:${GETOPT_LIB}>)
 
diff --git a/clients/mapiclient/mclient.c b/clients/mapiclient/mclient.c
--- a/clients/mapiclient/mclient.c
+++ b/clients/mapiclient/mclient.c
@@ -3072,10 +3072,74 @@ doFile(Mapi mid, stream *fp, bool useins
return errseen;
 }
 
+#ifdef HAVE_CURL
+#include 
+
+#ifndef CURL_WRITEFUNC_ERROR
+#define CURL_WRITEFUNC_ERROR 0
+#endif
+
+static size_t
+write_callback(char *buffer, size_t size, size_t nitems, void *userp)
+{
+   stream *s = userp;
+
+   /* size is expected to always be 1 */
+
+   ssize_t sz = mnstr_write(s, buffer, size, nitems);
+   if (sz < 0)
+   return CURL_WRITEFUNC_ERROR; /* indicate failure to library */
+   return (size_t) sz * size;
+}
+
+static stream *
+open_urlstream(const char *url, char *errbuf)
+{
+   CURL *handle;
+   stream *s;
+   CURLcode ret;
+
+   s = buffer_wastream(NULL, url);
+   if (s == NULL) {
+   snprintf(errbuf, CURL_ERROR_SIZE, "could not allocate memory");
+   return NULL;
+   }
+
+   if ((handle = curl_easy_init()) == NULL) {
+   mnstr_destroy(s);
+   snprintf(errbuf, 

MonetDB: literal_features - rudimentary check for pk-uk pair in ...

2024-02-27 Thread Yunus Koning via checkin-list
Changeset: 63e038204127 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/63e038204127
Modified Files:
sql/server/rel_select.c
Branch: literal_features
Log Message:

rudimentary check for pk-uk pair in group by


diffs (57 lines):

diff --git a/sql/server/rel_select.c b/sql/server/rel_select.c
--- a/sql/server/rel_select.c
+++ b/sql/server/rel_select.c
@@ -1414,8 +1414,51 @@ rel_column_ref(sql_query *query, sql_rel
}
}
if (!exp) {
-   if (inner && !is_sql_aggr(f) && is_groupby(inner->op) 
&& inner->l && (exp = rel_bind_column3(sql, inner->l, sname, tname, cname, f)))
-   return sql_error(sql, ERR_NOTFOUND, 
SQLSTATE(42000) "SELECT: cannot use non GROUP BY column '%s.%s' in query 
results without an aggregate function", tname, cname);
+   if (inner && !is_sql_aggr(f) && is_groupby(inner->op) 
&& inner->l && (exp = rel_bind_column3(sql, inner->l, sname, tname, cname, f))) 
{
+   sql_table* t = find_table_or_view_on_scope(sql, 
NULL, sname, tname, "SELECT", false);
+   bool check_pk_with_uk = false;
+   if (t) {
+   sql_idx* pki = NULL;
+   sql_idx* uki = NULL;
+   for (node * n = ol_first_node(t->idxs); 
n; n = n->next) {
+   sql_idx *i = n->data;
+
+   switch (i->key->type) {
+   case pkey:
+   pki = i;
+   continue;
+   case ukey:
+   case unndkey:
+   uki = i;
+   continue;
+   default:
+   continue;
+   }
+   }
+
+   if (uki && pki) {
+   if (pki->columns->cnt == 1 && 
uki->columns->cnt == 1 && ((list*) inner->r)->cnt == 1) {
+   sql_column* pkc = 
((sql_kc *)pki->columns->h->data)->c;
+   sql_column* ukc = 
((sql_kc *)uki->columns->h->data)->c;
+   (void) pkc;
+   (void) ukc;
+   sql_exp* gbe = ((list*) 
inner->r)->h->data;
+   assert(gbe->type == 
e_column);
+   if 
(strcmp(gbe->alias.name, pkc->base.name) == 0 && strcmp(exp->alias.name, 
ukc->base.name) == 0)
+   
check_pk_with_uk = true;
+   }
+   }
+   }
+
+   if (check_pk_with_uk) {
+   sql->session->status = 0;
+   sql->errstr[0] = 0;
+   exp->card = CARD_AGGR;
+   list_append(inner->exps, exp);
+   }
+   else
+   return sql_error(sql, ERR_NOTFOUND, 
SQLSTATE(42000) "SELECT: cannot use non GROUP BY column '%s.%s' in query 
results without an aggregate function", tname, cname);
+   }
}
 
if (!exp)
___
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org


MonetDB: literal_features - Merge with default

2024-02-21 Thread Yunus Koning via checkin-list
Changeset: 60e5746a185a for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/60e5746a185a
Modified Files:
sql/backends/monet5/rel_bin.c
sql/include/sql_catalog.h
sql/server/rel_schema.c
sql/server/sql_parser.y
sql/server/sql_partition.c
sql/server/sql_tokens.h
Branch: literal_features
Log Message:

Merge with default


diffs (truncated from 121999 to 300 lines):

diff --git a/.bumpversion.cfg b/.bumpversion.cfg
--- a/.bumpversion.cfg
+++ b/.bumpversion.cfg
@@ -1,5 +1,5 @@
 [bumpversion]
-current_version = 11.48.0
+current_version = 11.50.0
 commit = False
 tag = False
 
diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml
--- a/.github/workflows/linux.yml
+++ b/.github/workflows/linux.yml
@@ -43,7 +43,7 @@ jobs:
 runs-on: ${{ matrix.os }}
 steps:
   - name: Checkout
-uses: actions/checkout@v3
+uses: actions/checkout@v4
 with:
   ref: ${{ github.ref }}
 
@@ -129,7 +129,7 @@ jobs:
   - name: Tar files
 run: tar -cvf mtests.tar mTests
   - name: Publish mtest results
-uses: actions/upload-artifact@v3
+uses: actions/upload-artifact@v4
 with:
   name: mtest-${{ github.sha }}-${{ matrix.os }}-${{ matrix.c_compiler 
}}
   path: mtests.tar
diff --git a/.hgtags b/.hgtags
--- a/.hgtags
+++ b/.hgtags
@@ -815,3 +815,8 @@ 6f88424ebfd9d82c072cf21d89070e04321983da
 6f88424ebfd9d82c072cf21d89070e04321983da Jun2023_SP2_release
 e6eb06773c17035954ac5d001cfe1f09ff3425cc Jun2023_13
 5683fd900f28d65ad7c98d1ed1efd992023a7fa4 Jun2023_15
+c5b17681b55e6ca155db28be59913699e561502a Dec2023_root
+c9e6096e7519636a4e840c7a0c2e27cccb7dc0fe Jun2023_17
+c9e6096e7519636a4e840c7a0c2e27cccb7dc0fe Jun2023_SP3_release
+1230526af30f40eeea30fb87c47c3e414920561f Dec2023_1
+1230526af30f40eeea30fb87c47c3e414920561f Dec2023_release
diff --git a/CMakeLists.txt b/CMakeLists.txt
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -5,7 +5,9 @@
 # License, v. 2.0.  If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 #
-# Copyright 1997 - July 2008 CWI, August 2008 - 2023 MonetDB B.V.
+# Copyright 2024 MonetDB Foundation;
+# Copyright August 2008 - 2023 MonetDB B.V.;
+# Copyright 1997 - July 2008 CWI.
 #]]
 
 cmake_minimum_required(VERSION 3.12)
diff --git a/ChangeLog b/ChangeLog
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,20 +1,3 @@
 # ChangeLog file for devel
 # This file is updated with Maddlog
 
-* Mon Oct 30 2023 Sjoerd Mullender 
-- The ranges of merge partitions are now pushed down into the low
-  level GDK operations, giving them a handle to sometimes execute more
-  efficiently.
-
-* Thu Jul 27 2023 Niels Nes 
-- Removed the PYTHON MAP external language option, as after a fork the
-  synchronization primitives could be in any state, leading to deadlocks.
-  During the upgrade function definitions will fallback to the normal
-  PYTHON language option.
-
-* Mon Jul 17 2023 Panagiotis Koutsourakis 
-- Implemented direct masking for strimp construction. The strimps
-  datastructure now keeps an array of 65K 64-bit integers that is zero
-  everywhere except at the indexes that correspond to header pairs. The
-  entry for the nth pair in order has the nth bit of the bitstring
-  on. These can be used to quickly construct bitstrings.
diff --git a/ChangeLog-Archive b/ChangeLog-Archive
--- a/ChangeLog-Archive
+++ b/ChangeLog-Archive
@@ -1,6 +1,28 @@
 # DO NOT EDIT THIS FILE -- MAINTAINED AUTOMATICALLY
 # This file contains past ChangeLog entries
 
+* Fri Dec  1 2023 Sjoerd Mullender  - 11.49.1-20231221
+- All binary packages are now signed with a new key with key fingerprint
+  DBCE 5625 94D7 1959 7B54  CE85 3F1A D47F 5521 A603.
+
+* Mon Oct 30 2023 Sjoerd Mullender  - 11.49.1-20231221
+- The ranges of merge partitions are now pushed down into the low
+  level GDK operations, giving them a handle to sometimes execute more
+  efficiently.
+
+* Thu Jul 27 2023 Niels Nes  - 11.49.1-20231221
+- Removed the PYTHON MAP external language option, as after a fork the
+  synchronization primitives could be in any state, leading to deadlocks.
+  During the upgrade function definitions will fallback to the normal
+  PYTHON language option.
+
+* Mon Jul 17 2023 Panagiotis Koutsourakis  - 
11.49.1-20231221
+- Implemented direct masking for strimp construction. The strimps
+  datastructure now keeps an array of 65K 64-bit integers that is zero
+  everywhere except at the indexes that correspond to header pairs. The
+  entry for the nth pair in order has the nth bit of the bitstring
+  on. These can be used to quickly construct bitstrings.
+
 * Fri Sep 29 2023 Sjoerd Mullender  - 11.47.11-20230929
 - Fixed an installation issue on Debian and Ubuntu introduced in the
   last build.
diff --git a/ChangeLog b/ChangeLog.Dec2023
copy from ChangeLog
copy to ChangeLog.Dec2023
--- a/ChangeLog
+++ b/ChangeLog.Dec2023
@@ -1,20 +1,3 @@
 # ChangeLog file for devel
 # 

MonetDB: default - remove redundant if-scope

2023-11-13 Thread Yunus Koning via checkin-list
Changeset: c5b17681b55e for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/c5b17681b55e
Modified Files:
sql/server/rel_exp.c
Branch: default
Log Message:

remove redundant if-scope


diffs (68 lines):

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
@@ -2579,38 +2579,36 @@ exps_bind_column2(list *exps, const char
if (exps) {
node *en;
 
-   if (exps) {
-   if (!exps->ht && list_length(exps) > HASH_MIN_SIZE) {
-   exps->ht = hash_new(exps->sa, 
list_length(exps), (fkeyvalue)_key);
-   if (exps->ht == NULL)
-   return res;
-
-   for (en = exps->h; en; en = en->next ) {
-   sql_exp *e = en->data;
-   if (e->alias.name) {
-   int key = exp_key(e);
-
-   if (hash_add(exps->ht, key, e) 
== NULL)
-   return res;
-   }
+   if (!exps->ht && list_length(exps) > HASH_MIN_SIZE) {
+   exps->ht = hash_new(exps->sa, list_length(exps), 
(fkeyvalue)_key);
+   if (exps->ht == NULL)
+   return res;
+
+   for (en = exps->h; en; en = en->next ) {
+   sql_exp *e = en->data;
+   if (e->alias.name) {
+   int key = exp_key(e);
+
+   if (hash_add(exps->ht, key, e) == NULL)
+   return res;
}
}
-   if (exps->ht) {
-   int key = hash_key(cname);
-   sql_hash_e *he = 
exps->ht->buckets[key&(exps->ht->size-1)];
-
-   for (; he; he = he->chain) {
-   sql_exp *e = he->value;
-
-   if (e && e->alias.name && 
e->alias.rname && strcmp(e->alias.name, cname) == 0 && strcmp(e->alias.rname, 
rname) == 0) {
-   if (res && multiple)
-   *multiple = 1;
-   if (!res)
-   res = e;
-   }
+   }
+   if (exps->ht) {
+   int key = hash_key(cname);
+   sql_hash_e *he = 
exps->ht->buckets[key&(exps->ht->size-1)];
+
+   for (; he; he = he->chain) {
+   sql_exp *e = he->value;
+
+   if (e && e->alias.name && e->alias.rname && 
strcmp(e->alias.name, cname) == 0 && strcmp(e->alias.rname, rname) == 0) {
+   if (res && multiple)
+   *multiple = 1;
+   if (!res)
+   res = e;
}
-   return res;
}
+   return res;
}
for (en = exps->h; en; en = en->next ) {
sql_exp *e = en->data;
___
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org


MonetDB: literal_features - merge with default

2023-11-13 Thread Yunus Koning via checkin-list
Changeset: 4c591abef122 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/4c591abef122
Branch: literal_features
Log Message:

merge with default


diffs (truncated from 7976 to 300 lines):

diff --git a/.hgtags b/.hgtags
--- a/.hgtags
+++ b/.hgtags
@@ -814,3 +814,4 @@ 1efa83c6409769d13b2ee30e497d5f7ab42fa955
 6f88424ebfd9d82c072cf21d89070e04321983da Jun2023_11
 6f88424ebfd9d82c072cf21d89070e04321983da Jun2023_SP2_release
 e6eb06773c17035954ac5d001cfe1f09ff3425cc Jun2023_13
+5683fd900f28d65ad7c98d1ed1efd992023a7fa4 Jun2023_15
diff --git a/MonetDB.spec b/MonetDB.spec
--- a/MonetDB.spec
+++ b/MonetDB.spec
@@ -867,6 +867,17 @@ fi
 %endif
 
 %changelog
+* Thu Nov 09 2023 Sjoerd Mullender  - 11.47.15-20231109
+- Rebuilt.
+- GH#7410: SIGSEGV cause database corruption
+
+* Tue Nov  7 2023 Sjoerd Mullender  - 11.47.15-20231109
+- gdk: When saving the SQL catalog during a low-level commit, we should
+  only save the part of the catalog that corresponds to the part of the
+  write-ahead log that has been processed.  What we did was save more,
+  which resulted in the catalog containing references to tables and
+  columns whose disk presence is otherwise only in the write-ahead log.
+
 * Fri Nov 03 2023 Sjoerd Mullender  - 11.47.13-20231103
 - Rebuilt.
 - GH#7300: Implement missing standard SQL DATE and TIMESTAMP functions
diff --git a/clients/Tests/exports.stable.out b/clients/Tests/exports.stable.out
--- a/clients/Tests/exports.stable.out
+++ b/clients/Tests/exports.stable.out
@@ -730,9 +730,10 @@ msettings_error msetting_set_named(msett
 const char *msetting_string(const msettings *mp, mparm parm);
 long msettings_connect_binary(const msettings *mp);
 const char *msettings_connect_certhash_digits(const msettings *mp);
+const char *msettings_connect_clientcert(const msettings *mp);
+const char *msettings_connect_clientkey(const msettings *mp);
 long msettings_connect_port(const msettings *mp);
 bool msettings_connect_scan(const msettings *mp);
-const char *msettings_connect_sockdir(const msettings *mp);
 const char *msettings_connect_tcp(const msettings *mp);
 enum msetting_tls_verify msettings_connect_tls_verify(const msettings *mp);
 const char *msettings_connect_unix(const msettings *mp);
diff --git a/clients/examples/C/testsfile.c b/clients/examples/C/testsfile.c
--- a/clients/examples/C/testsfile.c
+++ b/clients/examples/C/testsfile.c
@@ -235,6 +235,10 @@ handle_expect_command(const char *locati
return expect_string(location, MP_UNKNOWN, 
msettings_connect_certhash_digits, value);
if (strcmp("connect_binary", key) == 0)
return expect_long(location, MP_UNKNOWN, 
msettings_connect_binary, value);
+   if (strcmp("connect_clientkey", key) == 0)
+   return expect_string(location, MP_UNKNOWN, 
msettings_connect_clientkey, value);
+   if (strcmp("connect_clientcert", key) == 0)
+   return expect_string(location, MP_UNKNOWN, 
msettings_connect_clientcert, value);
 
const mparm parm = mparm_parse(key);
if (parm == MP_UNKNOWN) {
diff --git a/clients/examples/python/mclient-python3.py 
b/clients/examples/python/mclient-python3.py
--- a/clients/examples/python/mclient-python3.py
+++ b/clients/examples/python/mclient-python3.py
@@ -65,7 +65,7 @@ def main() :
 line = fi.readline()
 if encoding != 'utf-8':
 prompt = str(prompt, 'utf-8').encode(encoding, 'replace')
-while line and line != "\q\n":
+while line and line != "\\q\n":
 if encoding != 'utf-8':
 line = str(line, encoding).encode('utf-8')
 res = s.cmd('s' + line)
diff --git a/clients/mapiclient/mclient.1 b/clients/mapiclient/mclient.1
--- a/clients/mapiclient/mclient.1
+++ b/clients/mapiclient/mclient.1
@@ -212,7 +212,7 @@ The possible values are
 .BR expanded ,
 .BR x ,
 .BR csv ,
-.BR csv-noquote ,
+.BR csv\-noquote ,
 .BR tab ,
 .BR raw ,
 .BR xml ,
@@ -221,7 +221,7 @@ and
 .BR rowcount .
 .B csv
 is comma-separated values;
-.B csv-noquote
+.B csv\-noquote
 is comma-separated values without escaping any quotes;
 .B tab
 is tab-separated values;
@@ -248,7 +248,7 @@ is a variation on
 where only the number of affected rows is printed.
 Normal \fBcsv\fP and \fBtab\fP formatting will use double quotes
 around any fields that contain double quotes, white space or the
-separator.  The \fBcsv-noquote\fP format will prevent that and dump
+separator.  The \fBcsv\-noquote\fP format will prevent that and dump
 the contents of the field without any interpretation.
 In addition to plain \fBcsv\fP, two other forms are possible.
 \fBcsv=\fP\fIc\fP uses \fIc\fP as column separator; \fBcsv+\fP\fIc\fP
@@ -539,7 +539,7 @@ in the above query can also be a URL.  I
 .IR e . g .,
 .IR https://www.example.org/dumpdata.csv .
 .PP
-See 
https://www.monetdb.org/documentation/user-guide/sql-manual/data-loading/copy-from/
+See 
https://www.monetdb.org/documentation/user\-guide/sql\-manual/data\-loading/copy\-from/
 for more information about the COPY 

MonetDB: literal_features - use 'nndunique' suffix for instantia...

2023-11-09 Thread Yunus Koning via checkin-list
Changeset: 203dd9ac1149 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/203dd9ac1149
Modified Files:
sql/server/rel_schema.c
sql/server/sql_partition.c
Branch: literal_features
Log Message:

use 'nndunique' suffix for instantiated UNIQUE NULLS NOT DISTINCT keys


diffs (25 lines):

diff --git a/sql/server/rel_schema.c b/sql/server/rel_schema.c
--- a/sql/server/rel_schema.c
+++ b/sql/server/rel_schema.c
@@ -325,6 +325,9 @@ column_constraint_name(mvc *sql, symbol 
case SQL_UNIQUE:
suffix = "unique";
break;
+   case SQL_UNIQUE_NULLS_NOT_DISTINCT:
+   suffix = "nndunique";
+   break;
case SQL_PRIMARY_KEY:
suffix = "pkey";
break;
diff --git a/sql/server/sql_partition.c b/sql/server/sql_partition.c
--- a/sql/server/sql_partition.c
+++ b/sql/server/sql_partition.c
@@ -53,7 +53,7 @@ str
 sql_partition_validate_key(mvc *sql, sql_table *nt, sql_key *k, const char* op)
 {
if (k->type != fkey) {
-   const char *keys = (k->type == pkey) ? "primary" : "unique";
+   const char *keys = (k->type == pkey) ? "primary" : k->type == 
unndkey ? "nndunique" :  "unique";
assert(k->type == pkey || k->type == ukey || k->type == 
unndkey);
 
if (isPartitionedByColumnTable(nt)) {
___
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org


MonetDB: literal_features - add tests for various unique constra...

2023-11-07 Thread Yunus Koning via checkin-list
Changeset: 82cfc16811b2 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/82cfc16811b2
Added Files:
sql/test/2023/Tests/unique_nulls_distinct.test
Modified Files:
sql/test/2023/Tests/All
Branch: literal_features
Log Message:

add tests for various unique constraints


diffs (136 lines):

diff --git a/sql/test/2023/Tests/All b/sql/test/2023/Tests/All
--- a/sql/test/2023/Tests/All
+++ b/sql/test/2023/Tests/All
@@ -1,3 +1,4 @@
 literals
 btrim
 any_value
+unique_nulls_distinct
diff --git a/sql/test/2023/Tests/unique_nulls_distinct.test 
b/sql/test/2023/Tests/unique_nulls_distinct.test
new file mode 100644
--- /dev/null
+++ b/sql/test/2023/Tests/unique_nulls_distinct.test
@@ -0,0 +1,123 @@
+
+statement ok
+CREATE TABLE und1 (i1 int, i2 int, UNIQUE (i1, i2))
+
+statement ok
+CREATE TABLE und2 (i1 int, i2 int, UNIQUE NULLS DISTINCT (i1, i2))
+
+statement ok
+CREATE TABLE unnd1 (i1 int, i2 int, UNIQUE NULLS NOT DISTINCT (i1, i2))
+
+statement ok
+INSERT INTO und1 VALUES (NULL, 10)
+
+statement ok
+INSERT INTO und1 VALUES (NULL, 10), (NULL, 10)
+
+statement ok
+INSERT INTO und1 VALUES (20, 10)
+
+statement error
+INSERT INTO und1 VALUES (20, 10)
+
+statement error
+INSERT INTO und1 VALUES (30, 10), (30, 10)
+
+statement ok
+INSERT INTO und2 VALUES (NULL, 10)
+
+statement ok
+INSERT INTO und2 VALUES (NULL, 10), (NULL, 10)
+
+statement ok
+INSERT INTO und2 VALUES (20, 10)
+
+statement error
+INSERT INTO und2 VALUES (20, 10)
+
+statement error
+INSERT INTO und2 VALUES (30, 10), (30, 10)
+
+statement error
+INSERT INTO unnd1 VALUES (NULL, 10), (NULL, 10)
+
+statement ok
+INSERT INTO unnd1 VALUES (NULL, 10)
+
+statement error
+INSERT INTO unnd1 VALUES (NULL, 10)
+
+statement ok
+INSERT INTO unnd1 VALUES (20, 10)
+
+statement error
+INSERT INTO unnd1 VALUES (20, 10)
+
+statement error
+INSERT INTO unnd1 VALUES (30, 10), (30, 10)
+
+statement ok
+CREATE TABLE und3 (i1 int UNIQUE)
+
+statement ok
+CREATE TABLE und4 (i1 int UNIQUE NULLS DISTINCT )
+
+statement ok
+CREATE TABLE unnd2 (i1 int UNIQUE NULLS NOT DISTINCT)
+
+statement ok
+INSERT INTO und3 VALUES (NULL)
+
+statement ok
+INSERT INTO und3 VALUES (NULL), (NULL)
+
+statement ok
+INSERT INTO und3 VALUES (10)
+
+statement error
+INSERT INTO und3 VALUES (10)
+
+statement error
+INSERT INTO und3 VALUES (10), (20)
+
+statement error
+INSERT INTO und3 VALUES (30), (30)
+
+statement ok
+INSERT INTO und4 VALUES (NULL)
+
+statement ok
+INSERT INTO und4 VALUES (NULL), (NULL)
+
+statement ok
+INSERT INTO und4 VALUES (10)
+
+statement error
+INSERT INTO und4 VALUES (10)
+
+statement error
+INSERT INTO und4 VALUES (10), (20)
+
+statement error
+INSERT INTO und4 VALUES (30), (30)
+
+statement error
+INSERT INTO unnd2 VALUES (NULL), (NULL)
+
+statement ok
+INSERT INTO unnd2 VALUES (NULL)
+
+statement error
+INSERT INTO unnd2 VALUES (NULL)
+
+statement ok
+INSERT INTO unnd2 VALUES (10)
+
+statement error
+INSERT INTO unnd2 VALUES (10)
+
+statement error
+INSERT INTO unnd2 VALUES (10), (20)
+
+statement error
+INSERT INTO unnd2 VALUES (30), (30)
___
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org


MonetDB: literal_features - Also introduce explicit UNIQUE NULLS...

2023-11-07 Thread Yunus Koning via checkin-list
Changeset: c096265d9f8b for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/c096265d9f8b
Modified Files:
sql/server/sql_parser.y
Branch: literal_features
Log Message:

Also introduce explicit UNIQUE NULLS DISTINCT syntax


diffs (20 lines):

diff --git a/sql/server/sql_parser.y b/sql/server/sql_parser.y
--- a/sql/server/sql_parser.y
+++ b/sql/server/sql_parser.y
@@ -2144,6 +2144,7 @@ column_constraint_type:
 NOT sqlNULL{ $$ = _symbol_create( SQL_NOT_NULL, NULL); }
  |  sqlNULL{ $$ = _symbol_create( SQL_NULL, NULL); }
  |  UNIQUE { $$ = _symbol_create( SQL_UNIQUE, NULL ); }
+ |  UNIQUE NULLS DISTINCT  { $$ = _symbol_create( SQL_UNIQUE, NULL ); }
  |  UNIQUE NULLS NOT DISTINCT  { $$ = _symbol_create( 
SQL_UNIQUE_NULLS_NOT_DISTINCT, NULL ); }
  |  PRIMARY KEY{ $$ = _symbol_create( SQL_PRIMARY_KEY, NULL ); }
  |  REFERENCES qname opt_column_list opt_match opt_ref_action
@@ -2161,6 +2162,8 @@ column_constraint_type:
 table_constraint_type:
 UNIQUE column_commalist_parens
{ $$ = _symbol_create_list( SQL_UNIQUE, $2); }
+ |  UNIQUE NULLS DISTINCT column_commalist_parens
+   { $$ = _symbol_create_list( SQL_UNIQUE, $4); }
  |  UNIQUE NULLS NOT DISTINCT column_commalist_parens
{ $$ = _symbol_create_list( 
SQL_UNIQUE_NULLS_NOT_DISTINCT, $5); }
  |  PRIMARY KEY column_commalist_parens
___
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org


MonetDB: literal_features - SQL23: introduce UNIQUE NULLS NOT DI...

2023-11-07 Thread Yunus Koning via checkin-list
Changeset: f1b3e33b1168 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/f1b3e33b1168
Modified Files:
sql/backends/monet5/rel_bin.c
sql/include/sql_catalog.h
sql/server/rel_schema.c
sql/server/sql_parser.y
sql/server/sql_partition.c
sql/server/sql_tokens.h
Branch: literal_features
Log Message:

SQL23: introduce UNIQUE NULLS NOT DISTINCT constraint


diffs (138 lines):

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
@@ -4643,7 +4643,9 @@ insert_check_ukey(backend *be, list *ins
stmt_add_column_predicate(be, c->c);
 
col = stmt_col(be, c->c, dels, dels->partition);
-   if ((k->type == ukey) && stmt_has_null(col)) {
+   if (k->type == unndkey)
+   s = stmt_uselect(be, col, cs, 
cmp_equal, s, 0, 1);
+   else if ((k->type == ukey) && 
stmt_has_null(col)) {
stmt *nn = stmt_selectnonil(be, col, s);
s = stmt_uselect(be, col, cs, 
cmp_equal, nn, 0, 0);
} else {
@@ -4668,7 +4670,7 @@ insert_check_ukey(backend *be, list *ins
list_append(lje, col);
list_append(rje, cs);
}
-   s = releqjoin(be, lje, rje, NULL, 1 /* hash used */, 0, 
0);
+   s = releqjoin(be, lje, rje, NULL, 1 /* hash used */, 0, 
k->type == unndkey? 1: 0);
s = stmt_result(be, s, 0);
}
s = stmt_binop(be, stmt_aggr(be, s, NULL, NULL, cnt, 1, 0, 1), 
stmt_atom_lng(be, 0), NULL, ne);
@@ -4732,12 +4734,12 @@ insert_check_ukey(backend *be, list *ins
s = stmt_project(be, nn, s);
}
if (h->nrcols) {
-   s = stmt_join(be, s, h, 0, cmp_equal, 0, 0, false);
+   s = stmt_join(be, s, h, 0, cmp_equal, 0, k->type == 
unndkey? 1: 0, false);
/* s should be empty */
s = stmt_result(be, s, 0);
s = stmt_aggr(be, s, NULL, NULL, cnt, 1, 0, 1);
} else {
-   s = stmt_uselect(be, s, h, cmp_equal, NULL, 0, 0);
+   s = stmt_uselect(be, s, h, cmp_equal, NULL, 0, k->type 
== unndkey? 1: 0);
/* s should be empty */
s = stmt_aggr(be, s, NULL, NULL, cnt, 1, 0, 1);
}
@@ -4844,7 +4846,7 @@ sql_insert_key(backend *be, list *insert
 *  insert values
 *  insert fkey/pkey index
 */
-   if (k->type == pkey || k->type == ukey) {
+   if (k->type == pkey || k->type == ukey || k->type == unndkey) {
return insert_check_ukey(be, inserts, k, idx_inserts);
} else {/* foreign keys */
return insert_check_fkey(be, inserts, k, idx_inserts, pin);
diff --git a/sql/include/sql_catalog.h b/sql/include/sql_catalog.h
--- a/sql/include/sql_catalog.h
+++ b/sql/include/sql_catalog.h
@@ -524,8 +524,9 @@ typedef struct sql_subfunc {
 
 typedef enum key_type {
pkey,
-   ukey,
-   fkey
+   ukey, /* default behavior is that NULLS are distinct, e.g. there can be 
multiple null values in a column with regular UNIQUE constraint */
+   fkey,
+   unndkey /* NULLS are not distinct, i.e. NULLS act as regular values for 
uniqueness checks */
 } key_type;
 
 typedef struct sql_kc {
diff --git a/sql/server/rel_schema.c b/sql/server/rel_schema.c
--- a/sql/server/rel_schema.c
+++ b/sql/server/rel_schema.c
@@ -366,8 +366,9 @@ column_constraint_type(mvc *sql, const c
}
switch (s->token) {
case SQL_UNIQUE:
+   case SQL_UNIQUE_NULLS_NOT_DISTINCT:
case SQL_PRIMARY_KEY: {
-   key_type kt = (s->token == SQL_UNIQUE) ? ukey : pkey;
+   key_type kt = (s->token == SQL_UNIQUE) ? ukey : (s->token == 
SQL_UNIQUE_NULLS_NOT_DISTINCT) ? unndkey : pkey;
sql_key *k;
const char *ns = name;
 
@@ -828,8 +829,9 @@ table_constraint_type(mvc *sql, const ch
 
switch (s->token) {
case SQL_UNIQUE:
+   case SQL_UNIQUE_NULLS_NOT_DISTINCT:
case SQL_PRIMARY_KEY: {
-   key_type kt = (s->token == SQL_PRIMARY_KEY ? pkey : ukey);
+   key_type kt = (s->token == SQL_PRIMARY_KEY ? pkey : s->token == 
SQL_UNIQUE ? ukey : unndkey);
dnode *nms = s->data.lval->h;
sql_key *k;
const char *ns = name;
diff --git a/sql/server/sql_parser.y b/sql/server/sql_parser.y
--- a/sql/server/sql_parser.y
+++ b/sql/server/sql_parser.y
@@ -2144,6 +2144,7 @@ 

MonetDB: literal_features - merge with default

2023-11-07 Thread Yunus Koning via checkin-list
Changeset: e274dae813b9 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/e274dae813b9
Branch: literal_features
Log Message:

merge with default


diffs (truncated from 696 to 300 lines):

diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml
--- a/.github/workflows/linux.yml
+++ b/.github/workflows/linux.yml
@@ -16,7 +16,6 @@ jobs:
 strategy:
   fail-fast: false  # don't stop other jobs
   matrix:
-branch: [ master ]
 os: [ ubuntu-latest, macos-latest, windows-latest ]
 c_compiler: [ gcc, clang, cl ]
 include:
@@ -42,13 +41,11 @@ jobs:
   - os: ubuntu-latest
 c_compiler: cl
 runs-on: ${{ matrix.os }}
-env:
-  CTEST: ${{ runner.os == 'Windows' && 'RUN_TESTS' || 'test' }}
 steps:
   - name: Checkout
 uses: actions/checkout@v3
 with:
-  ref: ${{ matrix.branch }}
+  ref: ${{ github.ref }}
 
   - name: install pymonetdb cryptography
 run: pip3 install pymonetdb cryptography
@@ -106,13 +103,22 @@ jobs:
   - name: ctest 
 run: |
   cd build 
-  cmake --build . --target ${{ CTEST }}
+  cmake --build . --target ${{ runner.os == 'Windows' && 'RUN_TESTS' 
|| 'test' }}
+if: runner.os != 'Windows'
 
   - name: mtest 
 run: |
   PATH=$HOME/MDB/bin:$PATH $HOME/MDB/bin/Mtest.py -r --debug=0 --ci 
--no-html --TSTTRGBASE=.
 if: runner.os != 'Windows'
 
+  - name: ctest 
+shell: pwsh
+run: |
+  $env:PATH = 
'C:\MDB\lib;C:\MDB\lib\monetdb5;C:\MDB\bin;C:\vcpkg\installed\x64-windows\bin;C:\vcpkg\installed\x64-windows\debug\bin;'
 + $env:PATH
+  cd build 
+  cmake --build . --target ${{ runner.os == 'Windows' && 'RUN_TESTS' 
|| 'test' }}
+if: runner.os == 'Windows'
+
   - name: mtest 
 shell: pwsh
 run: |
@@ -125,5 +131,5 @@ jobs:
   - name: Publish mtest results
 uses: actions/upload-artifact@v3
 with:
-  name: mtest-${{ matrix.branch }}-${{ matrix.os }}-${{ 
matrix.c_compiler }}
+  name: mtest-${{ github.sha }}-${{ matrix.os }}-${{ matrix.c_compiler 
}}
   path: mtests.tar
diff --git a/sql/backends/monet5/sql_gencode.c 
b/sql/backends/monet5/sql_gencode.c
--- a/sql/backends/monet5/sql_gencode.c
+++ b/sql/backends/monet5/sql_gencode.c
@@ -354,7 +354,8 @@ static int
Client c = MCgetClient(m->clientid);
MalBlkPtr curBlk = 0;
InstrPtr curInstr = 0, p, o;
-   sqlid table_id = prp->id;
+   tid_uri *tu = ((list*)prp->value.pval)->h->data;
+   sqlid table_id = tu->id;
node *n;
int i, q, v, res = -1, added_to_cache = 0, *lret, *rret;
size_t len = 1024, nr, pwlen = 0;
@@ -389,6 +390,7 @@ static int
 
sql_table *rt = sql_trans_find_table(m->session->tr, table_id);
const char *uri = mapiuri_uri(rt->query, m->sa);
+   assert(strcmp(tu->uri, uri) == 0);
if (!rt) {
sql_error(m, 10, SQLSTATE(HY013) MAL_MALLOC_FAIL);
goto cleanup;
@@ -928,8 +930,12 @@ static int
Symbol symbackup = c->curprg;
exception_buffer ebsave = m->sa->eb;
 
-   if (prp->id == 0) {
-   sql_error(m, 003, SQLSTATE(42000) "Missing property on the 
input relation");
+   if (list_empty(prp->value.pval)) {
+   sql_error(m, 003, SQLSTATE(42000) "Missing REMOTE property on 
the input relation");
+   goto bailout;
+   }
+   if (list_length(prp->value.pval) != 1) {
+   sql_error(m, 003, SQLSTATE(42000) "REMOTE property on the input 
relation is NOT unique");
goto bailout;
}
if (strlen(mod) >= IDLENGTH) {
diff --git a/sql/server/rel_distribute.c b/sql/server/rel_distribute.c
--- a/sql/server/rel_distribute.c
+++ b/sql/server/rel_distribute.c
@@ -15,6 +15,12 @@
 #include "rel_remote.h"
 #include "sql_privileges.h"
 
+typedef struct rmt_prop_state {
+   int depth;
+   prop* rmt;
+   sql_rel* orig;
+} rps;
+
 static int
 has_remote_or_replica( sql_rel *rel )
 {
@@ -66,7 +72,7 @@ has_remote_or_replica( sql_rel *rel )
 }
 
 static sql_rel *
-rewrite_replica(mvc *sql, list *exps, sql_table *t, sql_table *p, int 
remote_prop)
+do_replica_rewrite(mvc *sql, list *exps, sql_table *t, sql_table *p, int 
remote_prop)
 {
node *n, *m;
sql_rel *r = rel_basetable(sql, p, t->base.name);
@@ -96,11 +102,15 @@ rewrite_replica(mvc *sql, list *exps, sq
 
/* set_remote() */
if (remote_prop && p && isRemote(p)) {
-   sqlid id = p->base.id;
-   char *local_name = sa_strconcat(sql->sa, sa_strconcat(sql->sa, 
p->s->base.name, "."), p->base.name);
-   prop *p = r->p = prop_create(sql->sa, PROP_REMOTE, r->p);
-   p->id = id;
-   p->value.pval = local_name;
+   list *uris = sa_list(sql->sa);
+   tid_uri *tu = SA_NEW(sql->sa, 

MonetDB: literal_features - merge with default

2023-11-07 Thread Yunus Koning via checkin-list
Changeset: b21b6ac059ba for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/b21b6ac059ba
Branch: literal_features
Log Message:

merge with default


diffs (truncated from 22292 to 300 lines):

diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml
--- a/.github/workflows/linux.yml
+++ b/.github/workflows/linux.yml
@@ -3,7 +3,6 @@ name: MonetDB build and test
 on:
   push:
 branches: 
-  - '*'
   - 'branches/*'
   pull_request:
   # Allows you to run this workflow manually from the Actions tab
@@ -18,40 +17,113 @@ jobs:
   fail-fast: false  # don't stop other jobs
   matrix:
 branch: [ master ]
-os: [ ubuntu-latest, macos-latest ]
+os: [ ubuntu-latest, macos-latest, windows-latest ]
+c_compiler: [ gcc, clang, cl ]
+include:
+  - os: windows-latest
+c_compiler: cl
+  - os: macos-latest
+c_compiler: clang
+  - os: macos-latest
+c_compiler: gcc-12
+  - os: ubuntu-latest
+c_compiler: gcc
+  - os: ubuntu-latest
+c_compiler: clang
+exclude:
+  - os: windows-latest
+c_compiler: gcc
+  - os: windows-latest
+c_compiler: clang
+  - os: macos-latest
+c_compiler: cl
+  - os: macos-latest
+c_compiler: gcc
+  - os: ubuntu-latest
+c_compiler: cl
 runs-on: ${{ matrix.os }}
+env:
+  CTEST: ${{ runner.os == 'Windows' && 'RUN_TESTS' || 'test' }}
 steps:
   - name: Checkout
 uses: actions/checkout@v3
 with:
   ref: ${{ matrix.branch }}
 
+  - name: install pymonetdb cryptography
+run: pip3 install pymonetdb cryptography
+
   - name: make MonetDB on linux
 run: |
   mkdir build
   cd build 
-  cmake ..  -DCMAKE_INSTALL_PREFIX=$HOME/${{ matrix.branch }} 
-DPY3INTEGRATION=OFF -DCMAKE_BUILD_TYPE=Release -DASSERT=OFF -DRINTEGRATION=OFF
+  cmake ..  \
+-DCMAKE_INSTALL_PREFIX=$HOME/MDB \
+-DPY3INTEGRATION=OFF \
+-DRINTEGRATION=OFF \
+-DCMAKE_BUILD_TYPE=Release \
+-DASSERT=OFF \
+-DCMAKE_C_COMPILER=${{ matrix.c_compiler }} \
+-DCMAKE_SUMMARY=ON
   make install -j3
 if: runner.os == 'Linux'
-  -
-name: brew packages
+
+  - name: brew packages
 run: brew install bison
 if: runner.os == 'macOS'
+
   - name: make MonetDB on macos
 run: |
   mkdir build
   cd build 
-  cmake ..  -DCMAKE_INSTALL_PREFIX=$HOME/${{ matrix.branch }} 
-DPY3INTEGRATION=OFF -DCMAKE_BUILD_TYPE=Release -DASSERT=OFF -DRINTEGRATION=OFF 
 \
--DBISON_EXECUTABLE=/usr/local/opt/bison/bin/bison
+  cmake .. \
+-DCMAKE_INSTALL_PREFIX=$HOME/MDB \
+-DPY3INTEGRATION=OFF \
+-DRINTEGRATION=OFF  \
+-DCMAKE_BUILD_TYPE=Release \
+-DASSERT=OFF \
+-DCMAKE_C_COMPILER=${{ matrix.c_compiler }} \
+-DBISON_EXECUTABLE=/usr/local/opt/bison/bin/bison \
+-DCMAKE_SUMMARY=ON
   make install -j3
 if: runner.os == 'macOS'
+
+  - name: choco packages
+run: |
+  choco install winflexbison3
+  vcpkg install libiconv bzip2 libxml2 pcre zlib getopt 
+if: runner.os == 'Windows'
+
+  - name: make MonetDB on Windows
+shell: pwsh
+run: |
+  mkdir build
+  cd build 
+  cmake ..  -DCMAKE_INSTALL_PREFIX=C:\MDB 
-DCMAKE_TOOLCHAIN_FILE=C:\vcpkg\scripts\buildsystems\vcpkg.cmake 
-DPY3INTEGRATION=OFF -DRINTEGRATION=OFF  -DCMAKE_BUILD_TYPE=Release 
-DASSERT=OFF -DCMAKE_C_COMPILER=${{ matrix.c_compiler }}  -DCMAKE_SUMMARY=ON
+  cmake --build . --target install
+if: runner.os == 'Windows'
+
   - name: ctest 
 run: |
   cd build 
-  cmake --build . --target test
-  #-
-  #uses: actions/upload-artifact@v3
-  #name: Publish Linux binary wheels
-  #with:
-  #name: monetdbe-linux-wheel-${{ matrix.branch }}-${{ 
matrix.python-version }}
-  #path: dist/*.whl
+  cmake --build . --target ${{ CTEST }}
+
+  - name: mtest 
+run: |
+  PATH=$HOME/MDB/bin:$PATH $HOME/MDB/bin/Mtest.py -r --debug=0 --ci 
--no-html --TSTTRGBASE=.
+if: runner.os != 'Windows'
+
+  - name: mtest 
+shell: pwsh
+run: |
+  $env:PATH = 
'C:\MDB\lib;C:\MDB\lib\monetdb5;C:\MDB\bin;C:\vcpkg\installed\x64-windows\bin;C:\vcpkg\installed\x64-windows\debug\bin;'
 + $env:PATH
+  python C:\MDB\bin\Mtest.py -r --debug=0 --ci --no-html --TSTTRGBASE=.
+if: runner.os == 'Windows'
+
+  - name: Tar files
+run: tar -cvf mtests.tar mTests
+  - name: Publish mtest results
+uses: actions/upload-artifact@v3
+with:
+

MonetDB: literal_features - remove obsolete upgrade code

2023-10-19 Thread Yunus Koning via checkin-list
Changeset: 8190c83b02ae for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/8190c83b02ae
Modified Files:
sql/backends/monet5/sql_upgrades.c
Branch: literal_features
Log Message:

remove obsolete upgrade code


diffs (30 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
@@ -6012,26 +6012,6 @@ sql_update_default(Client c, mvc *sql, s
output = NULL;
}
 
-
-   /* 49_strings.sql */
-   sql_find_subtype(, "string", 0, 0);
-   if (sql_bind_func(sql, s->base.name, "btrim", , , F_FUNC, true) 
== NULL) {
-   sql->session->status = 0; /* if the function was not found 
clean the error */
-   sql->errstr[0] = '\0';
-   const char *cmds =
-   "create function sys.btrim(x string)\n"
-   "returns string external name str.trim;\n"
-   "grant execute on function btrim(string) to public;\n"
-
-   "create function sys.btrim(x string, y string)\n"
-   "returns string external name str.trim2;\n"
-   "grant execute on function btrim(string, string) to public;\n"
-   ;
-   printf("Running database upgrade commands:\n%s\n", cmds);
-   fflush(stdout);
-   err = SQLstatementIntern(c, cmds, "update", true, false, NULL);
-   }
-
/* 91_information_schema.sql */
info = mvc_bind_schema(sql, "information_schema");
if (info == NULL) {
___
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org


MonetDB: literal_features - approve convert tests

2023-10-19 Thread Yunus Koning via checkin-list
Changeset: 143153489a2e for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/143153489a2e
Modified Files:
sql/test/BugTracker-2016/Tests/convert-function-test-hge.Bug-3460.test
sql/test/BugTracker-2016/Tests/convert-function-test.Bug-3460.test
Branch: literal_features
Log Message:

approve convert tests


diffs (truncated from 1066 to 300 lines):

diff --git 
a/sql/test/BugTracker-2016/Tests/convert-function-test-hge.Bug-3460.test 
b/sql/test/BugTracker-2016/Tests/convert-function-test-hge.Bug-3460.test
--- a/sql/test/BugTracker-2016/Tests/convert-function-test-hge.Bug-3460.test
+++ b/sql/test/BugTracker-2016/Tests/convert-function-test-hge.Bug-3460.test
@@ -424,8 +424,29 @@ 0
 1
 1
 
-statement error
+query IT rowsort
 SELECT v, convert(v, varchar) from T_hugeint
+
+-1
+-1
+-127
+-127
+-2147483647
+-2147483647
+-32767
+-32767
+0
+0
+1
+1
+127
+127
+2147483647
+2147483647
+32767
+32767
+NULL
+NULL
 
 query IT rowsort
 SELECT v, convert(v, varchar(16)) from T_hugeint
@@ -935,8 +956,29 @@ 0
 1
 1
 
-statement error
+query IT rowsort
 SELECT v, cast(v as varchar) from T_hugeint
+
+-1
+-1
+-127
+-127
+-2147483647
+-2147483647
+-32767
+-32767
+0
+0
+1
+1
+127
+127
+2147483647
+2147483647
+32767
+32767
+NULL
+NULL
 
 query IT rowsort
 SELECT v, cast(v as varchar(16)) from T_hugeint
diff --git a/sql/test/BugTracker-2016/Tests/convert-function-test.Bug-3460.test 
b/sql/test/BugTracker-2016/Tests/convert-function-test.Bug-3460.test
--- a/sql/test/BugTracker-2016/Tests/convert-function-test.Bug-3460.test
+++ b/sql/test/BugTracker-2016/Tests/convert-function-test.Bug-3460.test
@@ -159,8 +159,19 @@ t
 NULL
 NULL
 
-statement error
+query IT rowsort
 SELECT v, convert(v, varchar) from T_BOOLEAN
+
+0
+false
+0
+false
+1
+true
+1
+true
+NULL
+NULL
 
 query IT rowsort
 SELECT v, convert(v, varchar(6)) from T_BOOLEAN
@@ -371,8 +382,19 @@ t
 NULL
 NULL
 
-statement error
+query IT rowsort
 SELECT v, cast(v as varchar) from T_BOOLEAN
+
+0
+false
+0
+false
+1
+true
+1
+true
+NULL
+NULL
 
 query IT rowsort
 SELECT v, cast(v as varchar(6)) from T_BOOLEAN
@@ -552,8 +574,21 @@ SELECT v, convert(v, decimal(15,3)) from
 statement error
 SELECT v, convert(v, char) from T_blob where v between '11' and '11'
 
-statement error
+query TT rowsort
 SELECT v, convert(v, varchar) from T_blob
+
+(empty)
+(empty)
+00
+00
+0123456789
+0123456789
+11
+11
+A0B2C3D4F5
+A0B2C3D4F5
+NULL
+NULL
 
 query TT rowsort
 SELECT v, convert(v, varchar(16)) from T_blob
@@ -706,8 +741,21 @@ SELECT v, cast(v as decimal(15,3)) from 
 statement error
 SELECT v, cast(v as char) from T_blob where v between '11' and '11'
 
-statement error
+query TT rowsort
 SELECT v, cast(v as varchar) from T_blob
+
+(empty)
+(empty)
+00
+00
+0123456789
+0123456789
+11
+11
+A0B2C3D4F5
+A0B2C3D4F5
+NULL
+NULL
 
 query TT rowsort
 SELECT v, cast(v as varchar(16)) from T_blob
@@ -1108,8 +1156,21 @@ 0
 1
 1
 
-statement error
+query IT rowsort
 SELECT v, convert(v, varchar) from T_tinyint
+
+-1
+-1
+-127
+-127
+0
+0
+1
+1
+127
+127
+NULL
+NULL
 
 query IT rowsort
 SELECT v, convert(v, varchar(6)) from T_tinyint
@@ -1475,8 +1536,21 @@ 0
 1
 1
 
-statement error
+query IT rowsort
 SELECT v, cast(v as varchar) from T_tinyint
+
+-1
+-1
+-127
+-127
+0
+0
+1
+1
+127
+127
+NULL
+NULL
 
 query IT rowsort
 SELECT v, cast(v as varchar(6)) from T_tinyint
@@ -1928,8 +2002,25 @@ 0
 1
 1
 
-statement error
+query IT rowsort
 SELECT v, convert(v, varchar) from T_smallint
+
+-1
+-1
+-127
+-127
+-32767
+-32767
+0
+0
+1
+1
+127
+127
+32767
+32767
+NULL
+NULL
 
 query IT rowsort
 SELECT v, convert(v, varchar(6)) from T_smallint
@@ -2369,8 +2460,25 @@ 0
 1
 1
 
-statement error
+query IT rowsort
 SELECT v, cast(v as varchar) from T_smallint
+
+-1
+-1
+-127
+-127
+-32767
+-32767
+0
+0
+1
+1
+127
+127
+32767
+32767
+NULL
+NULL
 
 query IT rowsort
 SELECT v, cast(v as varchar(6)) from T_smallint
@@ -2894,8 +3002,29 @@ 0
 1
 1
 
-statement error
+query IT rowsort
 SELECT v, convert(v, varchar) from T_int
+
+-1
+-1
+-127
+-127
+-2147483647
+-2147483647
+-32767
+-32767
+0
+0
+1
+1
+127
+127
+2147483647
+2147483647
+32767
+32767
+NULL
+NULL
 
 query IT rowsort
 SELECT v, convert(v, varchar(16)) from T_int
@@ -3405,8 +3534,29 @@ 0
 1
 1
 
-statement error
+query IT rowsort
 SELECT v, cast(v as varchar) from T_int
+
+-1
+-1
+-127
+-127
+-2147483647
___
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org


MonetDB: literal_features - move TRIM including new OVER syntax ...

2023-10-18 Thread Yunus Koning via checkin-list
Changeset: 1007e9b740c4 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/1007e9b740c4
Modified Files:
sql/common/sql_types.c
sql/scripts/49_strings.sql
sql/server/sql_parser.y
sql/server/sql_scan.c
Branch: literal_features
Log Message:

move TRIM including new OVER syntax to parser and sql_types function rename of 
'trim' to 'btrim'


diffs (112 lines):

diff --git a/sql/common/sql_types.c b/sql/common/sql_types.c
--- a/sql/common/sql_types.c
+++ b/sql/common/sql_types.c
@@ -1513,8 +1513,8 @@ sqltypeinit( sql_allocator *sa)
sql_create_func(sa, "ucase", "str", "toUpper", FALSE, FALSE, 
INOUT, 0, *t, 1, *t);
sql_create_func(sa, "lower", "str", "toLower", FALSE, FALSE, 
INOUT, 0, *t, 1, *t);
sql_create_func(sa, "lcase", "str", "toLower", FALSE, FALSE, 
INOUT, 0, *t, 1, *t);
-   sql_create_func(sa, "trim", "str", "trim", FALSE, FALSE, INOUT, 
0, *t, 1, *t);
-   sql_create_func(sa, "trim", "str", "trim2", FALSE, FALSE, 
INOUT, 0, *t, 2, *t, *t);
+   sql_create_func(sa, "btrim", "str", "trim", FALSE, FALSE, 
INOUT, 0, *t, 1, *t);
+   sql_create_func(sa, "btrim", "str", "trim2", FALSE, FALSE, 
INOUT, 0, *t, 2, *t, *t);
sql_create_func(sa, "ltrim", "str", "ltrim", FALSE, FALSE, 
INOUT, 0, *t, 1, *t);
sql_create_func(sa, "ltrim", "str", "ltrim2", FALSE, FALSE, 
INOUT, 0, *t, 2, *t, *t);
sql_create_func(sa, "rtrim", "str", "rtrim", FALSE, FALSE, 
INOUT, 0, *t, 1, *t);
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
@@ -57,11 +57,3 @@ 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 function sys.btrim(x string)
-returns string external name str.trim;
-grant execute on function btrim(string) to public;
-
-create function sys.btrim(x string, y string)
-returns string external name str.trim2;
-grant execute on function btrim(string, string) to public;
diff --git a/sql/server/sql_parser.y b/sql/server/sql_parser.y
--- a/sql/server/sql_parser.y
+++ b/sql/server/sql_parser.y
@@ -698,7 +698,7 @@ int yydebug=1;
 %left  ALL ANY NOT_BETWEEN BETWEEN NOT_IN sqlIN NOT_EXISTS EXISTS 
NOT_LIKE LIKE NOT_ILIKE ILIKE OR SOME
 %left  AND
 %left  COMPARISON /* <> < > <= >= */
-%left  '+' '-' '&' '|' '^' LEFT_SHIFT RIGHT_SHIFT LEFT_SHIFT_ASSIGN 
RIGHT_SHIFT_ASSIGN CONCATSTRING SUBSTRING TROM POSITION SPLIT_PART
+%left  '+' '-' '&' '|' '^' LEFT_SHIFT RIGHT_SHIFT LEFT_SHIFT_ASSIGN 
RIGHT_SHIFT_ASSIGN CONCATSTRING SUBSTRING TRIM POSITION SPLIT_PART
 %left  '*' '/' '%'
 %left UMINUS
 %left  '~'
@@ -4507,14 +4507,14 @@ opt_brackets:
  ;
 
 opt_trim_type:
-   /* empty */ { $$ = "btrim"; }
+   /* empty */ { $$ = NULL; }
   | LEADING {$$ = "ltrim"; }
   | TRAILING {$$ = "rtrim"; }
   | BOTH {$$ = "btrim"; }
   ;
 
 opt_trim_characters:
-   /* empty */ { $$ = " "; }
+   /* empty */ { $$ = NULL; }
   | string {$$ = $1; }
   ;
 
@@ -4584,19 +4584,38 @@ string_funcs:
  append_symbol(ops, $7);
  append_list(l, ops);
  $$ = _symbol_create_list( SQL_NOP, l ); }
-| TROM '(' opt_trim_type opt_trim_characters FROM scalar_exp  ')'
+| TRIM '(' opt_trim_type opt_trim_characters FROM scalar_exp  ')'
{ dlist *l = L();
+ if ( $3 == NULL && $4 == NULL ) {
+   sqlformaterror(m, SQLSTATE(2000) "%s", "trim 
specification or trim characters need to be specified preceding FROM in TRIM");
+   YYABORT;
+ }
  append_list(l,
-   append_string(L(), sa_strdup(SA, $3)));
+   append_string(L(), sa_strdup(SA, 
$3?$3:"btrim")));
append_int(l, FALSE); /* ignore distinct */
  append_symbol(l, $6);
 
- char* s = $4;
+ char* s = $4?$4:" ";
  int len = UTF8_strlen(s);
  sql_subtype t;
  sql_find_subtype(, "char", len, 0 );
  append_symbol(l, _newAtomNode( _atom_string(, s)));
  $$ = _symbol_create_list( SQL_BINOP, l ); }
+| TRIM '(' scalar_exp ',' scalar_exp  ')'
+   { dlist *l = L();
+ append_list(l,
+   append_string(L(), sa_strdup(SA, "btrim")));
+   append_int(l, FALSE); /* ignore distinct */
+ append_symbol(l, $3);
+ append_symbol(l, $5);
+ $$ = _symbol_create_list( 

MonetDB: literal_features - introduce TRIM function

2023-10-18 Thread Yunus Koning via checkin-list
Changeset: 483ff65ad9c5 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/483ff65ad9c5
Modified Files:
sql/server/sql_parser.y
sql/server/sql_scan.c
Branch: literal_features
Log Message:

introduce TRIM function


diffs (82 lines):

diff --git a/sql/server/sql_parser.y b/sql/server/sql_parser.y
--- a/sql/server/sql_parser.y
+++ b/sql/server/sql_parser.y
@@ -423,6 +423,8 @@ int yydebug=1;
opt_null_string
opt_to_savepoint
opt_uescape
+   opt_trim_type
+   opt_trim_characters
opt_using
opt_XML_attribute_name
restricted_ident
@@ -696,7 +698,7 @@ int yydebug=1;
 %left  ALL ANY NOT_BETWEEN BETWEEN NOT_IN sqlIN NOT_EXISTS EXISTS 
NOT_LIKE LIKE NOT_ILIKE ILIKE OR SOME
 %left  AND
 %left  COMPARISON /* <> < > <= >= */
-%left  '+' '-' '&' '|' '^' LEFT_SHIFT RIGHT_SHIFT LEFT_SHIFT_ASSIGN 
RIGHT_SHIFT_ASSIGN CONCATSTRING SUBSTRING POSITION SPLIT_PART
+%left  '+' '-' '&' '|' '^' LEFT_SHIFT RIGHT_SHIFT LEFT_SHIFT_ASSIGN 
RIGHT_SHIFT_ASSIGN CONCATSTRING SUBSTRING TROM POSITION SPLIT_PART
 %left  '*' '/' '%'
 %left UMINUS
 %left  '~'
@@ -723,6 +725,7 @@ SQLCODE SQLERROR UNDER WHENEVER
 %token PATH PRIMARY PRIVILEGES
 %token PUBLIC REFERENCES SCHEMA SET AUTO_COMMIT
 %token RETURN
+%token LEADING TRAILING BOTH
 
 %token ALTER ADD TABLE COLUMN TO UNIQUE VALUES VIEW WHERE WITH WITHOUT
 %token sqlDATE TIME TIMESTAMP INTERVAL
@@ -4503,6 +4506,18 @@ opt_brackets:
  | '(' ')' { $$ = 1; }
  ;
 
+opt_trim_type:
+   /* empty */ { $$ = "btrim"; }
+  | LEADING {$$ = "ltrim"; }
+  | TRAILING {$$ = "rtrim"; }
+  | BOTH {$$ = "btrim"; }
+  ;
+
+opt_trim_characters:
+   /* empty */ { $$ = " "; }
+  | string {$$ = $1; }
+  ;
+
 string_funcs:
 SUBSTRING '(' scalar_exp FROM scalar_exp FOR scalar_exp ')'
{ dlist *l = L();
@@ -4569,6 +4584,19 @@ string_funcs:
  append_symbol(ops, $7);
  append_list(l, ops);
  $$ = _symbol_create_list( SQL_NOP, l ); }
+| TROM '(' opt_trim_type opt_trim_characters FROM scalar_exp  ')'
+   { dlist *l = L();
+ append_list(l,
+   append_string(L(), sa_strdup(SA, $3)));
+   append_int(l, FALSE); /* ignore distinct */
+ append_symbol(l, $6);
+
+ char* s = $4;
+ int len = UTF8_strlen(s);
+ sql_subtype t;
+ sql_find_subtype(, "char", len, 0 );
+ append_symbol(l, _newAtomNode( _atom_string(, s)));
+ $$ = _symbol_create_list( SQL_BINOP, l ); }
  ;
 
 column_exp_commalist:
diff --git a/sql/server/sql_scan.c b/sql/server/sql_scan.c
--- a/sql/server/sql_scan.c
+++ b/sql/server/sql_scan.c
@@ -351,6 +351,10 @@ scanner_init_keywords(void)
failed += keywords_insert("POSITION", POSITION);
failed += keywords_insert("SUBSTRING", SUBSTRING);
failed += keywords_insert("SPLIT_PART", SPLIT_PART);
+   failed += keywords_insert("TROM", TROM);
+   failed += keywords_insert("LEADING", LEADING);
+   failed += keywords_insert("TRAILING", TRAILING);
+   failed += keywords_insert("BOTH", BOTH);
 
failed += keywords_insert("CASE", CASE);
failed += keywords_insert("WHEN", WHEN);
___
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org


MonetDB: literal_features - add any_value test

2023-10-13 Thread Yunus Koning via checkin-list
Changeset: 54c54e40204e for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/54c54e40204e
Added Files:
sql/test/2023/Tests/any_value.test
Modified Files:
sql/test/2023/Tests/All
Branch: literal_features
Log Message:

add any_value test


diffs (41 lines):

diff --git a/sql/test/2023/Tests/All b/sql/test/2023/Tests/All
--- a/sql/test/2023/Tests/All
+++ b/sql/test/2023/Tests/All
@@ -1,2 +1,3 @@
 literals
 btrim
+any_value
diff --git a/sql/test/2023/Tests/any_value.test 
b/sql/test/2023/Tests/any_value.test
new file mode 100644
--- /dev/null
+++ b/sql/test/2023/Tests/any_value.test
@@ -0,0 +1,29 @@
+statement ok   

+CREATE TABLE foo(i, j) AS VALUES (10, 1), (20, 2), (30, 1), (20, 2), (40, 1);
+
+query I rowsort
   
+SELECT any_value(i) FROM foo;
+
+10
+
+query II rowsort   

+SELECT any_value(i), j FROM foo GROUP BY j;
+
+10
+1
+20
+2
+
+query II rowsort   

+SELECT i, any_value(i) OVER (ORDER BY i) FROM foo;
+
+10
+10
+20
+10
+20
+10
+30
+10
+40
+10
___
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org


MonetDB: literal_features - SQL23 feature: introduce 'any_value'...

2023-10-13 Thread Yunus Koning via checkin-list
Changeset: 511a3736ad40 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/511a3736ad40
Modified Files:
sql/common/sql_types.c
Branch: literal_features
Log Message:

SQL23 feature: introduce 'any_value' aggregate/window function
(for now just 'min' alias)


diffs (19 lines):

diff --git a/sql/common/sql_types.c b/sql/common/sql_types.c
--- a/sql/common/sql_types.c
+++ b/sql/common/sql_types.c
@@ -937,6 +937,7 @@ sqltypeinit( sql_allocator *sa)
/* needed for indices/clusters oid(schema.table,val) returns 
max(head(schema.table))+1 */
sql_create_func(sa, "rowid", "calc", "rowid", TRUE, TRUE, SCALE_NONE, 
0, OID, 3, ANY, STR, STR);
sql_create_aggr(sa, "min", "aggr", "min", FALSE, FALSE, ANY, 1, ANY);
+   sql_create_aggr(sa, "any_value", "aggr", "min", FALSE, FALSE, ANY, 1, 
ANY);
sql_create_aggr(sa, "max", "aggr", "max", FALSE, FALSE, ANY, 1, ANY);
sql_create_func(sa, "sql_min", "calc", "min", FALSE, FALSE, SCALE_FIX, 
0, ANY, 2, ANY, ANY);
sql_create_func(sa, "sql_max", "calc", "max", FALSE, FALSE, SCALE_FIX, 
0, ANY, 2, ANY, ANY);
@@ -1095,6 +1096,7 @@ sqltypeinit( sql_allocator *sa)
 
sql_create_analytic(sa, "count", "sql", "count", FALSE, SCALE_NONE, 
LNG, 2, ANY, BIT);
sql_create_analytic(sa, "min", "sql", "min", FALSE, SCALE_NONE, ANY, 1, 
ANY);
+   sql_create_analytic(sa, "any_value", "sql", "min", FALSE, SCALE_NONE, 
ANY, 1, ANY);
sql_create_analytic(sa, "max", "sql", "max", FALSE, SCALE_NONE, ANY, 1, 
ANY);
 
/* analytical sum for numerical and decimals */
___
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org


MonetDB: literal_features - SQL23 feature: add btrim as an alias...

2023-10-12 Thread Yunus Koning via checkin-list
Changeset: 3fbc357091a2 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/3fbc357091a2
Added Files:
sql/test/2023/Tests/btrim.test
Modified Files:
sql/backends/monet5/sql_upgrades.c
sql/scripts/49_strings.sql
sql/test/2023/Tests/All
Branch: literal_features
Log Message:

SQL23 feature: add btrim as an alias to trim


diffs (63 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
@@ -6012,6 +6012,26 @@ sql_update_default(Client c, mvc *sql, s
output = NULL;
}
 
+
+   /* 49_strings.sql */
+   sql_find_subtype(, "string", 0, 0);
+   if (sql_bind_func(sql, s->base.name, "btrim", , , F_FUNC, true) 
== NULL) {
+   sql->session->status = 0; /* if the function was not found 
clean the error */
+   sql->errstr[0] = '\0';
+   const char *cmds =
+   "create function sys.btrim(x string)\n"
+   "returns string external name str.trim;\n"
+   "grant execute on function btrim(string) to public;\n"
+
+   "create function sys.btrim(x string, y string)\n"
+   "returns string external name str.trim2;\n"
+   "grant execute on function btrim(string, string) to public;\n"
+   ;
+   printf("Running database upgrade commands:\n%s\n", cmds);
+   fflush(stdout);
+   err = SQLstatementIntern(c, cmds, "update", true, false, NULL);
+   }
+
/* 91_information_schema.sql */
info = mvc_bind_schema(sql, "information_schema");
if (info == NULL) {
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
@@ -57,3 +57,11 @@ 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 function sys.btrim(x string)
+returns string external name str.trim;
+grant execute on function btrim(string) to public;
+
+create function sys.btrim(x string, y string)
+returns string external name str.trim2;
+grant execute on function btrim(string, string) to public;
diff --git a/sql/test/2023/Tests/All b/sql/test/2023/Tests/All
--- a/sql/test/2023/Tests/All
+++ b/sql/test/2023/Tests/All
@@ -1,1 +1,2 @@
 literals
+btrim
diff --git a/sql/test/2023/Tests/btrim.test b/sql/test/2023/Tests/btrim.test
new file mode 100644
--- /dev/null
+++ b/sql/test/2023/Tests/btrim.test
@@ -0,0 +1,7 @@
+
+query TTT rowsort
+SELECT btrim('   abc   '), btrim('abcdd', 'd'), btrim('dededeedabcedeed', 
'de');
+
+abc
+abc
+abc
___
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org


  1   2   >