MonetDB: default - Merge with Aug2024 branch.

2024-09-26 Thread Sjoerd Mullender via checkin-list
Changeset: 23bf643b6a72 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/23bf643b6a72
Modified Files:
gdk/gdk.h
gdk/gdk_bbp.c
sql/backends/monet5/rel_bin.c
sql/storage/store.c
Branch: default
Log Message:

Merge with Aug2024 branch.


diffs (truncated from 514 to 300 lines):

diff --git a/gdk/gdk.h b/gdk/gdk.h
--- a/gdk/gdk.h
+++ b/gdk/gdk.h
@@ -744,7 +744,6 @@ typedef struct {
 /* assert that atom width is power of 2, i.e., width == 1twidth < SIZEOF_VAR_T) {
-   size_t taillen = strlen(path) - 1;
-   char tailsave = path[taillen];
-   path[taillen] = 0;
-   if (MT_stat(path, &statb) < 0) {
-   GDKsyserror("cannot stat file 
%s%c or %s (expected size %zu)\n",
-   path, tailsave, 
path, b->theap->free);
-   GDKfree(path);
-   return GDK_FAIL;
-   }
-   } else
-#endif
-   {
-   GDKsyserror("cannot stat file %s 
(expected size %zu)\n",
-   path, b->theap->free);
-   GDKfree(path);
-   return GDK_FAIL;
-   }
+   GDKsyserror("cannot stat file %s (expected size 
%zu)\n",
+   path, b->theap->free);
+   GDKfree(path);
+   return GDK_FAIL;
}
if ((size_t) statb.st_size < b->theap->free) {
GDKerror("file %s too small (expected %zu, 
actual %zu)\n", path, b->theap->free, (size_t) statb.st_size);
@@ -1007,8 +991,7 @@ BBPheader(FILE *fp, int *lineno, bat *bb
bbpversion != GDKLIBRARY_STATUS &&
bbpversion != GDKLIBRARY_JSON &&
bbpversion != GDKLIBRARY_HSIZE &&
-   bbpversion != GDKLIBRARY_HASHASH &&
-   bbpversion != GDKLIBRARY_TAILN) {
+   bbpversion != GDKLIBRARY_HASHASH) {
TRC_CRITICAL(GDK, "incompatible BBP version: expected 0%o, got 
0%o. "
 "This database was probably created by a %s 
version of MonetDB.",
 GDKLIBRARY, bbpversion,
@@ -1424,56 +1407,6 @@ fixhashash(bat *hashbats, bat nhashbats)
 }
 #endif
 
-#ifdef GDKLIBRARY_TAILN
-static gdk_return
-movestrbats(void)
-{
-   for (bat bid = 1, nbat = (bat) ATOMIC_GET(&BBPsize); bid < nbat; bid++) 
{
-   BAT *b = BBP_desc(bid);
-   if (b->batCacheid == 0) {
-   /* not a valid BAT */
-   continue;
-   }
-   if (b->ttype != TYPE_str || b->twidth == SIZEOF_VAR_T || 
b->batCount == 0)
-   continue;
-   char *oldpath = GDKfilepath(0, BATDIR, 
BBP_physical(b->batCacheid), "tail");
-   char *newpath = GDKfilepath(0, BATDIR, b->theap->filename, 
NULL);
-   int ret = -1;
-   if (oldpath != NULL && newpath != NULL) {
-   struct stat oldst, newst;
-   bool oldexist = MT_stat(oldpath, &oldst) == 0;
-   bool newexist = MT_stat(newpath, &newst) == 0;
-   if (newexist) {
-   if (oldexist) {
-   if (oldst.st_mtime > newst.st_mtime) {
-   GDKerror("both %s and %s exist 
with %s unexpectedly newer: manual intervention required\n", oldpath, newpath, 
oldpath);
-   ret = -1;
-   } else {
-   GDKwarning("both %s and %s 
exist, removing %s\n", oldpath, newpath, oldpath);
-   ret = MT_remove(oldpath);
-   }
-   } else {
-   /* already good */
-   ret = 0;
-   }
-   } else if (oldexist) {
-   TRC_DEBUG(IO_, "rename %s to %s\n", oldpath, 
newpath);
-   ret = MT_rename(oldpath, newpath);
-   } else {
-   /* neither file exists: may be ok, but
-* will be checked later */
-   ret = 0;
-   }
- 

MonetDB: Aug2024 - Improve the violation message for CHECK const...

2024-09-26 Thread Martin van Dinther via checkin-list
Changeset: 9d958e0f96ea for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/9d958e0f96ea
Modified Files:
sql/backends/monet5/rel_bin.c
sql/test/2024/Tests/check.test
sql/test/BugConstraints/Tests/3335_check_no_error.test
sql/test/BugConstraints/Tests/3568_check_not_enforced.test
sql/test/BugConstraints/Tests/check_constraints.test
Branch: Aug2024
Log Message:

Improve the violation message for CHECK constraints by including the check sql 
expression and adding the schema name to the constraint name.


diffs (229 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
@@ -5189,7 +5189,7 @@ sql_insert_check(backend *be, sql_key *k
sql_subfunc *cnt = sql_bind_func(sql, "sys", "count", 
sql_bind_localtype("void"), NULL, F_AGGR, true, true);
s = stmt_uselect(be, column(be, s), stmt_bool(be, 0), cmp_equal, NULL, 
0, 1);
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);
+   char *msg = sa_message(sql->sa, SQLSTATE(40002) "INSERT INTO: violated 
constraint '%s.%s' CHECK(%s)", key->t->s->base.name, key->base.name, 
exp->comment);
(void)stmt_exception(be, s, msg, 1);
 }
 
@@ -6209,7 +6209,7 @@ sql_update_check(backend *be, stmt **upd
sql_subfunc *cnt = sql_bind_func(sql, "sys", "count", 
sql_bind_localtype("void"), NULL, F_AGGR, true, true);
s = stmt_uselect(be, column(be, s), stmt_bool(be, 0), 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);
+   char *msg = sa_message(sql->sa, SQLSTATE(40002) "UPDATE: violated 
constraint '%s.%s' CHECK(%s)", key->t->s->base.name, key->base.name, 
exp->comment);
(void)stmt_exception(be, s, msg, 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
@@ -4,19 +4,19 @@ create table foo (i int CHECK (i > 0), j
 statement ok
 insert into foo values (1,10), (2, 20), (3, 30)
 
-statement error 40002!UPDATE: CHECK constraint violated: foo_j_check
+statement error 40002!UPDATE: violated constraint 'sys.foo_j_check' CHECK(j > 
0)
 update foo set j = -30 where i = 3
 
-statement error 40002!UPDATE: CHECK constraint violated: foo_j_check
+statement error 40002!UPDATE: violated constraint 'sys.foo_j_check' CHECK(j > 
0)
 update foo set j = -j
 
-statement error 40002!INSERT INTO: CHECK constraint violated: foo_j_check
+statement error 40002!INSERT INTO: violated constraint 'sys.foo_j_check' 
CHECK(j > 0)
 insert into foo values (4, -40)
 
 statement ok
 insert into foo select * from foo
 
-statement error 40002!INSERT INTO: CHECK constraint violated: foo_j_check
+statement error 40002!INSERT INTO: violated constraint 'sys.foo_j_check' 
CHECK(j > 0)
 insert into foo select 4, -40
 
 statement ok
@@ -25,16 +25,16 @@ drop table foo
 statement ok
 create table bar (i int, j int, constraint check_i_j CHECK (i < j))
 
-statement error 40002!INSERT INTO: CHECK constraint violated: check_i_j
+statement error 40002!INSERT INTO: violated constraint 'sys.check_i_j' CHECK(i 
< j)
 insert into bar values (30, 20)
 
 statement ok
 insert into bar values (10,20), (20, 30), (30, 40)
 
-statement error 40002!UPDATE: CHECK constraint violated: check_i_j
+statement error 40002!UPDATE: violated constraint 'sys.check_i_j' CHECK(i < j)
 update bar set i = 50 where i = 30
 
-statement error 40002!UPDATE: CHECK constraint violated: check_i_j
+statement error 40002!UPDATE: violated constraint 'sys.check_i_j' CHECK(i < j)
 update bar set i = 50, j = 40 where i = 30
 
 statement ok
@@ -54,16 +54,16 @@ create table t3335(x integer check(x > 0
 statement ok
 insert into t3335 values(1)
 
-statement error 40002!INSERT INTO: CHECK constraint violated: t3335_x_check
+statement error 40002!INSERT INTO: violated constraint 'sys.t3335_x_check' 
CHECK(x > 0 and x < 2)
 insert into t3335 values(0)
 
-statement error 40002!INSERT INTO: CHECK constraint violated: t3335_x_check
+statement error 40002!INSERT INTO: violated constraint 'sys.t3335_x_check' 
CHECK(x > 0 and x < 2)
 insert into t3335 values(2)
 
-statement error 40002!INSERT INTO: CHECK constraint violated: t3335_x_check
+statement error 40002!INSERT INTO: violated constraint 'sys.t3335_x_check' 
CHECK(x > 0 and x < 2)
 insert into t3335 values(-1)
 
-statement error 40002!INSERT INTO: CHECK constraint violated: t3335_x_check
+statement error 40002!INSERT INTO: violated constraint 'sys.t3335_x_check' 
CHECK(x > 0 and x < 2)
 insert into t3335 values(3)
 
 statement ok
@@ -72,13 +72,13 @@ drop table t3335
 statement ok
 create table bar(i int, j int check (i < 10))
 
-statement error 40002!INSERT INT

MonetDB: Aug2024 - Update the sql ChangeLog regarding the change...

2024-09-26 Thread Martin van Dinther via checkin-list
Changeset: 2c55a9a7239d for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/2c55a9a7239d
Modified Files:
sql/ChangeLog.Aug2024
Branch: Aug2024
Log Message:

Update the sql ChangeLog regarding the changed CHECK contraint violation 
message.


diffs (14 lines):

diff --git a/sql/ChangeLog.Aug2024 b/sql/ChangeLog.Aug2024
--- a/sql/ChangeLog.Aug2024
+++ b/sql/ChangeLog.Aug2024
@@ -1,6 +1,10 @@
 # ChangeLog file for sql
 # This file is updated with Maddlog
 
+* Thu Sep 26 2024 Martin van Dinther 
+- Improved the violation message of CHECK constraints when violated. It
+  now includes the schema name of the constraint and the check clause.
+
 * Fri Aug 23 2024 Joeri van Ruth 
 - Increase the buffer size used by hot snapshot from 64kiB to 1MiB,
   and make it configurable through setting 'hot_snapshot_buffer_size'.
___
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org


MonetDB: resource_management - fix failing ctest

2024-09-26 Thread svetlin via checkin-list
Changeset: 2be7c40f0258 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/2be7c40f0258
Modified Files:
sql/backends/monet5/sql_scenario.c
tools/monetdbe/monetdbe.c
Branch: resource_management
Log Message:

fix failing ctest


diffs (33 lines):

diff --git a/sql/backends/monet5/sql_scenario.c 
b/sql/backends/monet5/sql_scenario.c
--- a/sql/backends/monet5/sql_scenario.c
+++ b/sql/backends/monet5/sql_scenario.c
@@ -1570,7 +1570,6 @@ SQLparser_body(Client c, backend *be)
 
if (be->q) {
int res = 0;
-   be->result_id = be->q->id;
if (!err && (res = mvc_export_prepare(be, 
c->fdout)) < 0) {
msg = createException(PARSE, 
"SQLparser", SQLSTATE(45000) "Export operation failed: %s", 
mvc_export_error(be, c->fdout, res));
err = 1;
@@ -1578,7 +1577,10 @@ SQLparser_body(Client c, backend *be)
if (err) {
be->q->name = NULL; /* later remove 
cleanup from mal from qc code */
qc_delete(m->qc, be->q);
+   be->q = NULL;
}
+   if (be->q)
+   be->result_id = be->q->id;
be->q = NULL;
}
if (err)
diff --git a/tools/monetdbe/monetdbe.c b/tools/monetdbe/monetdbe.c
--- a/tools/monetdbe/monetdbe.c
+++ b/tools/monetdbe/monetdbe.c
@@ -1722,6 +1722,7 @@ monetdbe_bind(monetdbe_statement *stmt, 
return stmt_internal->mdbe->msg;
}
VALset(&stmt_internal->data[i], tpe, val);
+   // FIX this leaks no free for val
} else {
VALset(&stmt_internal->data[i], tpe, data);
}
___
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org


MonetDB: Aug2024 - When initializing the internal data structure...

2024-09-26 Thread Sjoerd Mullender via checkin-list
Changeset: 1ed641208c99 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/1ed641208c99
Modified Files:
sql/storage/store.c
Branch: Aug2024
Log Message:

When initializing the internal data structures, sub-sort on column number 
instead of id.
Semantically, we should sort on column number, but in practice, these
orderings should always be the same.  However, I have seen one database
in which this is not the case.


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
@@ -1376,7 +1376,7 @@ load_trans(sql_trans* tr)
NULL, NULL,
find_sql_column(systables, "schema_id"), /* order also 
on schema_id */
find_sql_column(syscols, "table_id"),
-   find_sql_column(syscols, "id"), NULL);
+   find_sql_column(syscols, "number"), NULL);
 
res_table *rt_idx = store->table_api.table_orderby(tr, sysidx,
find_sql_column(sysidx, "table_id"),
___
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org