MonetDB: balanced_union - Compile without having to comment out ...

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

Compile without having to comment out half the file


diffs (12 lines):

diff --git a/sql/server/rel_optimize_proj.c b/sql/server/rel_optimize_proj.c
--- a/sql/server/rel_optimize_proj.c
+++ b/sql/server/rel_optimize_proj.c
@@ -1422,6 +1422,8 @@ bind_optimize_unions_bottomup(visitor *v
int flag = v->sql->sql_optimizer;
return gp->opt_level == 1 && gp->cnt[op_munion] && (flag & 
optimize_unions_bottomup)
   ? rel_optimize_munions_bottomup : NULL;
+   // TODO: remove the next return
+   return rel_optimize_unions_bottomup;
 }
 
 
___
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org


MonetDB: balanced_union - Fixes plans in Bug-2606 tests

2024-05-03 Thread stefanos mavros via checkin-list
Changeset: 4126ca52dcdd for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/4126ca52dcdd
Modified Files:

sql/test/BugTracker-2010/Tests/ORDER_BY_over_UNION_EXCEPT_INTERSECT.Bug-2606.test
Branch: balanced_union
Log Message:

Fixes plans in Bug-2606 tests


diffs (102 lines):

diff --git 
a/sql/test/BugTracker-2010/Tests/ORDER_BY_over_UNION_EXCEPT_INTERSECT.Bug-2606.test
 
b/sql/test/BugTracker-2010/Tests/ORDER_BY_over_UNION_EXCEPT_INTERSECT.Bug-2606.test
--- 
a/sql/test/BugTracker-2010/Tests/ORDER_BY_over_UNION_EXCEPT_INTERSECT.Bug-2606.test
+++ 
b/sql/test/BugTracker-2010/Tests/ORDER_BY_over_UNION_EXCEPT_INTERSECT.Bug-2606.test
@@ -77,8 +77,8 @@ project (
 | | project (
 | | | table("sys"."t2606b") [ "t2606b"."a" NOT NULL UNIQUE ]
 | | ) [ "t2606b"."a" NOT NULL UNIQUE as "%2"."a" ]
-| ) [ "%1"."a" NOT NULL UNIQUE as "%5"."a" ]
-) [ "%5"."a" NOT NULL UNIQUE ] [ "%5"."a" ASC NOT NULL UNIQUE ]
+| ) [ "%1"."a" NOT NULL UNIQUE as "%4"."a" ]
+) [ "%4"."a" NOT NULL UNIQUE ] [ "%4"."a" ASC NOT NULL UNIQUE ]
 
 query I rowsort
select * from t2606a   union   select * from t2606b   order by a
@@ -104,8 +104,8 @@ project (
 | | project (
 | | | table("sys"."t2606b") [ "t2606b"."a" NOT NULL UNIQUE ]
 | | ) [ "t2606b"."a" NOT NULL UNIQUE as "%2"."a" ]
-| ) [ "%1"."a" NOT NULL UNIQUE as "%5"."a" ]
-) [ "%5"."a" NOT NULL UNIQUE ] [ "%5"."a" ASC NOT NULL UNIQUE ]
+| ) [ "%1"."a" NOT NULL UNIQUE as "%4"."a" ]
+) [ "%4"."a" NOT NULL UNIQUE ] [ "%4"."a" ASC NOT NULL UNIQUE ]
 
 query I rowsort
  ( select * from t2606a   union   select * from t2606b ) order by a
@@ -131,8 +131,8 @@ project (
 | | project (
 | | | table("sys"."t2606b") [ "t2606b"."a" NOT NULL UNIQUE ]
 | | ) [ "t2606b"."a" NOT NULL UNIQUE as "%2"."a" ]
-| ) [ "%1"."a" NOT NULL UNIQUE as "%5"."a" ]
-) [ "%5"."a" NOT NULL UNIQUE ] [ "%5"."a" ASC NOT NULL UNIQUE ]
+| ) [ "%1"."a" NOT NULL UNIQUE as "%4"."a" ]
+) [ "%4"."a" NOT NULL UNIQUE ] [ "%4"."a" ASC NOT NULL UNIQUE ]
 
 query I rowsort
  ( select * from t2606a ) union ( select * from t2606b ) order by a
@@ -158,8 +158,8 @@ project (
 | | project (
 | | | table("sys"."t2606b") [ "t2606b"."a" NOT NULL UNIQUE ]
 | | ) [ "t2606b"."a" NOT NULL UNIQUE as "%2"."a" ]
-| ) [ "%1"."a" NOT NULL UNIQUE as "%5"."a" ]
-) [ "%5"."a" NOT NULL UNIQUE ] [ "%5"."a" ASC NOT NULL UNIQUE ]
+| ) [ "%1"."a" NOT NULL UNIQUE as "%4"."a" ]
+) [ "%4"."a" NOT NULL UNIQUE ] [ "%4"."a" ASC NOT NULL UNIQUE ]
 
 query I rowsort
select * from t2606a   except   select * from t2606b   order by a
@@ -179,8 +179,8 @@ project (
 | | project (
 | | | table("sys"."t2606b") [ "t2606b"."a" NOT NULL UNIQUE ]
 | | ) [ "t2606b"."a" NOT NULL UNIQUE as "%2"."a" ]
-| ) [ "%1"."a" NOT NULL UNIQUE as "%5"."a" ]
-) [ "%5"."a" NOT NULL UNIQUE ] [ "%5"."a" ASC NOT NULL UNIQUE ]
+| ) [ "%1"."a" NOT NULL UNIQUE as "%4"."a" ]
+) [ "%4"."a" NOT NULL UNIQUE ] [ "%4"."a" ASC NOT NULL UNIQUE ]
 
 query I rowsort
  ( select * from t2606a   except   select * from t2606b ) order by a
@@ -200,8 +200,8 @@ project (
 | | project (
 | | | table("sys"."t2606b") [ "t2606b"."a" NOT NULL UNIQUE ]
 | | ) [ "t2606b"."a" NOT NULL UNIQUE as "%2"."a" ]
-| ) [ "%1"."a" NOT NULL UNIQUE as "%5"."a" ]
-) [ "%5"."a" NOT NULL UNIQUE ] [ "%5"."a" ASC NOT NULL UNIQUE ]
+| ) [ "%1"."a" NOT NULL UNIQUE as "%4"."a" ]
+) [ "%4"."a" NOT NULL UNIQUE ] [ "%4"."a" ASC NOT NULL UNIQUE ]
 
 query I rowsort
  ( select * from t2606a ) except ( select * from t2606b ) order by a
@@ -221,8 +221,8 @@ project (
 | | project (
 | | | table("sys"."t2606b") [ "t2606b"."a" NOT NULL UNIQUE ]
 | | ) [ "t2606b"."a" NOT NULL UNIQUE as "%2"."a" ]
-| ) [ "%1"."a" NOT NULL UNIQUE as "%5"."a" ]
-) [ "%5"."a" NOT NULL UNIQUE ] [ "%5"."a" ASC NOT NULL UNIQUE ]
+| ) [ "%1"."a" NOT NULL UNIQUE as "%4"."a" ]
+) [ "%4"."a" NOT NULL UNIQUE ] [ "%4"."a" ASC NOT NULL UNIQUE ]
 
 query I rowsort
select * from t2606a   intersect   select * from t2606b   order by a
@@ -242,8 +242,8 @@ project (
 | | project (
 | | | table("sys"."t2606b") [ "t2606b"."a" NOT NULL UNIQUE ]
 | | ) [ "t2606b"."a" NOT NULL UNIQUE as "%2"."a" ]
-| ) [ "%1"."a" NOT NULL UNIQUE as "%5"."a" ]
-) [ "%5"."a" NOT NULL UNIQUE ] [ "%5"."a" ASC NOT NULL UNIQUE ]
+| ) [ "%1"."a" NOT NULL UNIQUE as "%4"."a" ]
+) [ "%4"."a" NOT NULL UNIQUE ] [ "%4"."a" ASC NOT NULL UNIQUE ]
 
 query I rowsort
  ( select * from t2606a   intersect   select * from t2606b ) order by a
@@ -263,8 +263,8 @@ project (
 | | project (
 | | | table("sys"."t2606b") [ "t2606b"."a" NOT NULL UNIQUE ]
 | | ) [ "t2606b"."a" NOT NULL UNIQUE as "%2"."a" ]
-| ) [ "%1"."a" NOT NULL UNIQUE as "%5"."a" ]
-) [ "%5"."a" NOT NULL UNIQUE ] [ "%5"."a" ASC NOT NULL UNIQUE ]
+| ) [ "%1"."a" NOT NULL UNIQUE as "%4"."a" ]
+) [ "%4"."a" NOT NULL UNIQUE ] [ "%4"."a" ASC NOT NULL UNIQUE ]
 
 query I rowsort
  ( select * from t2606a ) intersect ( select * from t2606b ) order by a
___
checkin-list mailing list -- 

MonetDB: balanced_union - Enables rel_optimize_unions_topdown by...

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

Enables rel_optimize_unions_topdown by default


diffs (30 lines):

diff --git a/sql/server/rel_optimize_proj.c b/sql/server/rel_optimize_proj.c
--- a/sql/server/rel_optimize_proj.c
+++ b/sql/server/rel_optimize_proj.c
@@ -1404,6 +1404,7 @@ rel_optimize_unions_bottomup(visitor *v,
 static sql_rel *
 rel_optimize_munions_bottomup_(visitor *v, sql_rel *rel)
 {
+   // TODO: implement rel_remove_munion_partitions
rel = rel_merge_munion(v, rel);
return rel;
 }
@@ -3685,6 +3686,7 @@ static sql_rel *
 rel_optimize_unions_topdown_(visitor *v, sql_rel *rel)
 {
rel = rel_push_project_down_union(v, rel);
+   // TODO: implement rel_push_join_down_munion
rel = rel_push_join_down_union(v, rel);
return rel;
 }
@@ -3700,9 +3702,7 @@ run_optimizer
 bind_optimize_unions_topdown(visitor *v, global_props *gp)
 {
(void) v;
-   // TODO: remove this and default to munion
-   int op = mvc_debug_on(v->sql, 32) ? gp->cnt[op_munion] : 
gp->cnt[op_union];
-   return gp->opt_level == 1 && op ? rel_optimize_unions_topdown : NULL;
+   return gp->opt_level == 1 && gp->cnt[op_munion] ? 
rel_optimize_unions_topdown : NULL;
 }
 
 
___
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org


MonetDB: balanced_union - Removes leftover return

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

Removes leftover return


diffs (12 lines):

diff --git a/sql/server/rel_optimize_proj.c b/sql/server/rel_optimize_proj.c
--- a/sql/server/rel_optimize_proj.c
+++ b/sql/server/rel_optimize_proj.c
@@ -1421,8 +1421,6 @@ bind_optimize_unions_bottomup(visitor *v
int flag = v->sql->sql_optimizer;
return gp->opt_level == 1 && gp->cnt[op_munion] && (flag & 
optimize_unions_bottomup)
   ? rel_optimize_munions_bottomup : NULL;
-   return gp->opt_level == 1 && gp->cnt[op_union] && (flag & 
optimize_unions_bottomup)
-  ? rel_optimize_unions_bottomup : NULL;
 }
 
 
___
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org


MonetDB: ascii-flag - Some more UTF-8 stuff.

2024-05-03 Thread Sjoerd Mullender via checkin-list
Changeset: e764818e0173 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/e764818e0173
Modified Files:
clients/mapiclient/mclient.c
Branch: ascii-flag
Log Message:

Some more UTF-8 stuff.


diffs (truncated from 313 to 300 lines):

diff --git a/clients/mapiclient/mclient.c b/clients/mapiclient/mclient.c
--- a/clients/mapiclient/mclient.c
+++ b/clients/mapiclient/mclient.c
@@ -103,9 +103,6 @@ typedef int64_t timertype;
 
 static timertype t0, t1;   /* used for timing */
 
-#define UTF8BOM"\xEF\xBB\xBF"  /* UTF-8 encoding of Unicode 
BOM */
-#define UTF8BOMLENGTH  3   /* length of above */
-
 /* Pagination and simple ASCII-based rendering is provided for SQL
  * sessions. The result set size is limited by the cache size of the
  * Mapi Library. It is sufficiently large to accommodate most result
@@ -173,6 +170,53 @@ static char *nullstring = default_nullst
 #include 
 #include "mhelp.h"
 
+/* The code starting here, and up to and including the function decode
+ * below are copyright Bjoern Hoehrmann per the below notice.
+ *
+ * The function decode provides a fast way to check for valid UTF-8
+ * sequences and returns the value of the codepoint as well.  */
+
+// Copyright (c) 2008-2009 Bjoern Hoehrmann 
+// See http://bjoern.hoehrmann.de/utf-8/decoder/dfa/ for details.
+
+#define UTF8_ACCEPT 0
+#define UTF8_REJECT 12
+
+static const uint8_t utf8d[] = {
+   // The first part of the table maps bytes to character classes that
+   // to reduce the size of the transition table and create bitmasks.
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,  0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,  0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,  0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,  0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,  9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,
+7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,  7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
+8,8,2,2,2,2,2,2,2,2,2,2,2,2,2,2,  2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
+   10,3,3,3,3,3,3,3,3,3,3,3,3,4,3,3, 11,6,6,6,5,8,8,8,8,8,8,8,8,8,8,8,
+
+   // The second part is a transition table that maps a combination
+   // of a state of the automaton and a character class to a state.
+0,12,24,36,60,96,84,12,12,12,48,72, 
12,12,12,12,12,12,12,12,12,12,12,12,
+   12, 0,12,12,12,12,12, 0,12, 0,12,12, 
12,24,12,12,12,12,12,24,12,24,12,12,
+   12,12,12,12,12,12,12,24,12,12,12,12, 
12,24,12,12,12,12,12,12,12,24,12,12,
+   12,12,12,12,12,12,12,36,12,36,12,12, 
12,36,12,12,12,12,12,36,12,36,12,12,
+   12,36,12,12,12,12,12,12,12,12,12,12,
+};
+
+static inline uint32_t
+decode(uint32_t *state, uint32_t *codep, uint32_t byte)
+{
+   uint32_t type = utf8d[byte];
+
+   *codep = (*state != UTF8_ACCEPT) ?
+   (byte & 0x3fu) | (*codep << 6) :
+   (0xff >> type) & (byte);
+
+   *state = utf8d[256 + *state + type];
+   return *state;
+}
+/* end code copyright by Bjoern Hoehrmann */
+
 static timertype
 gettime(void)
 {
@@ -590,69 +634,32 @@ static size_t
 utf8strlenmax(char *s, char *e, size_t max, char **t)
 {
size_t len = 0, len0 = 0;
-   int c;
-   int n;
char *t0 = s;
 
assert(max == 0 || t != NULL);
if (s == NULL)
return 0;
-   c = 0;
-   n = 0;
-   while (*s != 0 && (e == NULL || s < e)) {
-   if (*s == '\n') {
-   assert(n == 0);
-   if (max) {
-   *t = s;
-   return len;
+
+   uint32_t state = 0, codepoint = 0;
+   while (*s && (e == NULL || s < e)) {
+   switch (decode(, , (uint8_t) *s++)) {
+   case UTF8_ACCEPT:
+   if (codepoint == '\n') {
+   if (max) {
+   *t = s;
+   return len;
+   }
+   len++;
+   } else if (codepoint == '\t') {
+   len++;  /* rendered as single 
space */
+   } else if (codepoint <= 0x1F || codepoint == 0177) {
+   len += 4;   /* control, rendered as 
"\\%03o" */
+   } else if (0x80 <= codepoint && codepoint <= 0x9F) {
+   len += 6;   /* control, rendered as 
"u\\%04x" */
+   } else {
+   /* charwidth() returning -1 is caught by the 
above */
+   len += charwidth(codepoint);
}
-   len++;
-   n = 0;
-   } else if (*s == '\t') {
-   assert(n == 0);
-   len++;  /* rendered as single space */

MonetDB: balanced_union - Fixes expected plan from rtrim_bug test

2024-05-03 Thread stefanos mavros via checkin-list
Changeset: 2f7383141123 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/2f7383141123
Modified Files:
sql/test/bugs/Tests/rtrim_bug.test
Branch: balanced_union
Log Message:

Fixes expected plan from rtrim_bug test


diffs (16 lines):

diff --git a/sql/test/bugs/Tests/rtrim_bug.test 
b/sql/test/bugs/Tests/rtrim_bug.test
--- a/sql/test/bugs/Tests/rtrim_bug.test
+++ b/sql/test/bugs/Tests/rtrim_bug.test
@@ -53,8 +53,10 @@ project (
 | | | ) [ ("sys"."length"("t1"."m" NOT NULL UNIQUE) NOT NULL) > (int(31) "1") ]
 | | ) [ "t1"."m" NOT NULL UNIQUE, "sys"."rtrim"("t1"."m" NOT NULL UNIQUE) NOT 
NULL as "%5"."%5" ],
 | | project (
-| | | table("sys"."t1") [ "t1"."m" NOT NULL UNIQUE ]
-| | ) [ "sys"."rtrim"("t1"."m" NOT NULL UNIQUE) NOT NULL as "%4"."%4" ]
+| | | project (
+| | | | table("sys"."t1") [ "t1"."m" NOT NULL UNIQUE ]
+| | | ) [ "sys"."rtrim"("t1"."m" NOT NULL UNIQUE) NOT NULL as "%1"."%1" ]
+| | ) [ "%1"."%1" NOT NULL as "%4"."%4" ]
 | ) [ ("%5"."%5" NOT NULL) = ("%4"."%4" NOT NULL) ]
 ) [ "sys"."length"("t1"."m" NOT NULL UNIQUE) NOT NULL as "data_length", 
"t1"."m" NOT NULL UNIQUE as "data_value" ]
 
___
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org


MonetDB: balanced_union - Fixes plan of sqlancer test

2024-05-03 Thread stefanos mavros via checkin-list
Changeset: 683a8b9d086f for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/683a8b9d086f
Modified Files:
sql/test/SQLancer/Tests/sqlancer17.test
Branch: balanced_union
Log Message:

Fixes plan of sqlancer test


diffs (12 lines):

diff --git a/sql/test/SQLancer/Tests/sqlancer17.test 
b/sql/test/SQLancer/Tests/sqlancer17.test
--- a/sql/test/SQLancer/Tests/sqlancer17.test
+++ b/sql/test/SQLancer/Tests/sqlancer17.test
@@ -80,7 +80,7 @@ project (
 | | | | ) [ ("%6"."%6" NOT NULL) ! <= (tinyint(3) "1") ! <= ("%6"."%6" NOT 
NULL), (tinyint(3) "3") <= ("%6"."%6" NOT NULL) <= (tinyint(3) "5") ]
 | | | ) [ "%6"."%6" NOT NULL as "v0"."vc0" ]
 | | ) [ "v0"."vc0" NOT NULL ]
-| ) [ "sys"."sql_max"(tinyint(1) "1", tinyint(1) "1") NOT NULL as "v20"."vc0" ]
+| ) [ "sys"."sql_max"(tinyint(1) "1", tinyint(1) "1") NOT NULL as "%17"."%17" ]
 ) [ tinyint(1) "1" ]
 
 statement ok
___
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org


MonetDB: ascii-flag - Ignore rest of line after write error in i...

2024-05-03 Thread Sjoerd Mullender via checkin-list
Changeset: dce9b89338b2 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/dce9b89338b2
Modified Files:
clients/mapiclient/iconv-stream.h
sql/test/emptydb/Tests/check.stable.out
sql/test/mapi/Tests/utf8test.SQL.py
Branch: ascii-flag
Log Message:

Ignore rest of line after write error in iconv + some small fixes.


diffs (160 lines):

diff --git a/clients/mapiclient/iconv-stream.h 
b/clients/mapiclient/iconv-stream.h
--- a/clients/mapiclient/iconv-stream.h
+++ b/clients/mapiclient/iconv-stream.h
@@ -3,7 +3,8 @@
 struct ic_priv_t {
stream *s;
iconv_t cd;
-   bool eof;
+   bool eof:1;
+   bool err:1;
size_t buflen;
char buffer[BUFSIZ];
 };
@@ -22,7 +23,7 @@ ic_read(void *restrict private, void *re
while (outbytesleft > 0 && !ic->eof) {
if (ic->buflen == sizeof(ic->buffer)) {
/* ridiculously long multibyte sequence, return error */
-   fprintf(stderr, "multibyte sequence too long");
+   fprintf(stderr, "multibyte sequence too long\n");
return -1;
}
 
@@ -37,12 +38,12 @@ ic_read(void *restrict private, void *re
ic->eof = true;
if (ic->buflen > 0) {
/* incomplete input */
-   fprintf(stderr, "incomplete input");
+   fprintf(stderr, "incomplete input\n");
return -1;
}
if (iconv(ic->cd, NULL, NULL, , ) 
== (size_t) -1) {
/* some error occurred */
-   fprintf(stderr, "iconv reported an error");
+   fprintf(stderr, "iconv reported an error\n");
return -1;
}
goto exit_func; /* double break */
@@ -56,7 +57,7 @@ ic_read(void *restrict private, void *re
if (iconv(ic->cd, , , , ) 
== (size_t) -1) {
switch (errno) {
case EILSEQ:
-   fprintf(stderr, "invalid multibyte sequence");
+   fprintf(stderr, "invalid multibyte sequence\n");
return -1;
case EINVAL:
/* incomplete multibyte sequence encountered */
@@ -67,7 +68,7 @@ ic_read(void *restrict private, void *re
 * the buffer */
goto exit_func;
default:
-   fprintf(stderr, "iconv reported an error");
+   fprintf(stderr, "iconv reported an error\n");
return -1;
}
}
@@ -100,8 +101,17 @@ ic_write(void *restrict private, const v
char *bf = NULL;
 
if (ic == NULL) {
-   fprintf(stderr, "stream already ended");
-   goto bailout;
+   fprintf(stderr, "stream already ended\n");
+   return -1;
+   }
+
+   if (ic->err) {
+   for (size_t i = 0; i < inbytesleft; i++)
+   if (inbuf[i] == '\n') {
+   ic->err = false;
+   break;
+   }
+   return -1;
}
 
/* if unconverted data from a previous call remains, add it to
@@ -110,12 +120,12 @@ ic_write(void *restrict private, const v
bf = malloc(ic->buflen + inbytesleft);
if (bf == NULL) {
/* cannot allocate memory */
-   fprintf(stderr, "out of memory");
+   fprintf(stderr, "out of memory\n");
goto bailout;
}
memcpy(bf, ic->buffer, ic->buflen);
memcpy(bf + ic->buflen, buf, inbytesleft);
-   buf = bf;
+   inbuf = bf;
inbytesleft += ic->buflen;
ic->buflen = 0;
}
@@ -127,7 +137,7 @@ ic_write(void *restrict private, const v
switch (errno) {
case EILSEQ:
/* invalid multibyte sequence encountered */
-   fprintf(stderr, "invalid multibyte sequence");
+   fprintf(stderr, "invalid multibyte sequence\n");
goto bailout;
case EINVAL:
/* incomplete multibyte sequence
@@ -135,7 +145,7 @@ ic_write(void *restrict private, const v
 * converted */
if (outbytesleft < sizeof(ic->buffer) &&
mnstr_write(ic->s, ic->buffer, 1, 

MonetDB: ascii-flag - Tell streamcat where to find iconv.

2024-05-03 Thread Sjoerd Mullender via checkin-list
Changeset: 547ae0132fe5 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/547ae0132fe5
Modified Files:
clients/examples/C/CMakeLists.txt
Branch: ascii-flag
Log Message:

Tell streamcat where to find iconv.


diffs (20 lines):

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
@@ -45,13 +45,15 @@ add_executable(streamcat
 
 target_include_directories(streamcat
   PRIVATE
+  $<$:${CMAKE_REQUIRED_INCLUDES}>
   ../../mapiclient)
 
 target_link_libraries(streamcat
   PRIVATE
   monetdb_config_header
   stream
-  $<$:CURL::libcurl>)
+  $<$:CURL::libcurl>
+  $<$:Iconv::Iconv>)
 
 add_executable(testcondvar
   testcondvar.c)
___
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org


MonetDB: ascii-flag - Merge with default branch.

2024-05-03 Thread Sjoerd Mullender via checkin-list
Changeset: 2a557cc30013 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/2a557cc30013
Modified Files:
gdk/gdk_bat.c
gdk/gdk_bbp.c
Branch: ascii-flag
Log Message:

Merge with default branch.


diffs (truncated from 2467 to 300 lines):

diff --git a/.hgtags b/.hgtags
--- a/.hgtags
+++ b/.hgtags
@@ -825,3 +825,4 @@ dcc8c702e685a4faf21ccf663028d1bc3d1165d1
 dcc8c702e685a4faf21ccf663028d1bc3d1165d1 Dec2023_SP1_release
 d656785f49ee62c19705722aa6b7c171904c64d5 Dec2023_7
 d656785f49ee62c19705722aa6b7c171904c64d5 Dec2023_SP2_release
+9a694c41042503a22d6c92aeab5bc4ca1912b62e Dec2023_9
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-SP2/%{name}-%{version}.tar.bz2
+Source: 
https://www.monetdb.org/downloads/sources/Dec2023-SP3/%{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
@@ -916,6 +916,25 @@ fi
 %endif
 
 %changelog
+* Thu May 02 2024 Sjoerd Mullender  - 11.49.9-20240502
+- Rebuilt.
+- GH#7422: Aggregate functions with variadic arguments
+- GH#7472: MonetDB server crashes in `tail_type`
+- GH#7473: MonetDB server crashes in `SQLunionfunc`
+- GH#7478: MonetDB server crashes in `exp_equal`
+- GH#7496: Query on view fails to produce a resultset. Assertion triggered
+  in rel2bin_select.
+- GH#7499: create schema + set schema inside a transaction that is rolled
+  back causes the connection to be aborted
+- GH#7501: files remain in backup causing problems at restart
+- GH#7503: MonetDB server crashes using `WHEN MATCHED THEN UPDATE`
+- GH#7504: possible deadlock when a bat is made persistent when it is also
+  getting unloaded
+- GH#7506: MonetDB Dec2023-SP2 crashes at `rel_value_exp2`
+- GH#7507: BBPextend: ERROR: trying to extend BAT pool beyond the limit
+  (16384)
+- GH#7508: MonetDB Dec2023-SP2 crashes at `exp_ref`
+
 * Tue Apr 09 2024 Sjoerd Mullender  - 11.49.7-20240409
 - Rebuilt.
 - GH#7469: Crash when using `CONTAINS`
diff --git a/clients/mapilib/mapi.c b/clients/mapilib/mapi.c
--- a/clients/mapilib/mapi.c
+++ b/clients/mapilib/mapi.c
@@ -1777,6 +1777,11 @@ mapi_new(msettings *settings)
Mapi mid;
static ATOMIC_TYPE index = ATOMIC_VAR_INIT(0);
 
+   if (!ATOMIC_TAS(_initialized)) {
+   if (mnstr_init() < 0)
+   return NULL;
+   }
+
mid = malloc(sizeof(*mid));
if (mid == NULL)
return NULL;
@@ -1885,11 +1890,6 @@ mapi_mapiuri(const char *url, const char
 {
Mapi mid;
 
-   if (!ATOMIC_TAS(_initialized)) {
-   if (mnstr_init() < 0)
-   return NULL;
-   }
-
mid = mapi_new(NULL);
if (mid == NULL)
return NULL;
@@ -1944,11 +1944,6 @@ mapi_mapi(const char *host, int port, co
 {
Mapi mid;
 
-   if (!ATOMIC_TAS(_initialized)) {
-   if (mnstr_init() < 0)
-   return NULL;
-   }
-
mid = mapi_new(NULL);
if (mid == NULL)
return NULL;
diff --git a/cmake/monetdb-versions.cmake b/cmake/monetdb-versions.cmake
--- a/cmake/monetdb-versions.cmake
+++ b/cmake/monetdb-versions.cmake
@@ -44,19 +44,19 @@ set(MONETDB_VERSION "${MONETDB_VERSION_M
 # common/options and common/utils)
 set(GDK_VERSION_MAJOR "28")
 set(GDK_VERSION_MINOR "1")
-set(GDK_VERSION_PATCH "2")
+set(GDK_VERSION_PATCH "3")
 set(GDK_VERSION 
"${GDK_VERSION_MAJOR}.${GDK_VERSION_MINOR}.${GDK_VERSION_PATCH}")
 
 # version of the MAPI library (subdirectory clients/mapilib)
 set(MAPI_VERSION_MAJOR "26")
 set(MAPI_VERSION_MINOR "2")
-set(MAPI_VERSION_PATCH "1")
+set(MAPI_VERSION_PATCH "2")
 set(MAPI_VERSION 
"${MAPI_VERSION_MAJOR}.${MAPI_VERSION_MINOR}.${MAPI_VERSION_PATCH}")
 
 # version of the MONETDB5 library (subdirectory monetdb5, not including extras 
or sql)
 set(MONETDB5_VERSION_MAJOR "35")
 set(MONETDB5_VERSION_MINOR "0")
-set(MONETDB5_VERSION_PATCH "3")
+set(MONETDB5_VERSION_PATCH "4")
 set(MONETDB5_VERSION 
"${MONETDB5_VERSION_MAJOR}.${MONETDB5_VERSION_MINOR}.${MONETDB5_VERSION_PATCH}")
 
 # version of the MONETDBE library (subdirectory tools/monetdbe)
@@ -74,5 +74,5 @@ set(STREAM_VERSION "${STREAM_VERSION_MAJ
 # version of the SQL library (subdirectory sql)
 set(SQL_VERSION_MAJOR "14")
 set(SQL_VERSION_MINOR "1")
-set(SQL_VERSION_PATCH "3")
+set(SQL_VERSION_PATCH "4")
 set(SQL_VERSION 
"${SQL_VERSION_MAJOR}.${SQL_VERSION_MINOR}.${SQL_VERSION_PATCH}")
diff --git a/common/utils/GenerateVersionHeader.cmake 
b/common/utils/GenerateVersionHeader.cmake
--- a/common/utils/GenerateVersionHeader.cmake
+++ b/common/utils/GenerateVersionHeader.cmake
@@ -18,34 +18,34 @@ elseif(EXISTS "${DIR}/.hg")
   find_package(Hg)
   if(HG_FOUND)
 message("hg 

MonetDB: ascii-flag - Move iconv support out of stream library s...

2024-05-03 Thread Sjoerd Mullender via checkin-list
Changeset: 104cf6f8b939 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/104cf6f8b939
Added Files:
clients/mapiclient/iconv-stream.h
Removed Files:
common/stream/iconv_stream.c
Modified Files:
clients/Tests/exports.stable.out
clients/examples/C/streamcat.c
clients/mapiclient/CMakeLists.txt
clients/mapiclient/mclient.c
common/stream/CMakeLists.txt
common/stream/monetdb-stream.pc.in
common/stream/stdio_stream.c
common/stream/stream.h
common/stream/stream_internal.h
testing/CMakeLists.txt
testing/Mtest.py.in
Branch: ascii-flag
Log Message:

Move iconv support out of stream library so that mserver doesn't carry it 
around.


diffs (truncated from 1051 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
@@ -1680,8 +1680,6 @@ FILE *getFile(stream *s);
 int getFileNo(stream *s);
 size_t getFileSize(stream *s);
 stream *gz_stream(stream *inner, int preset);
-stream *iconv_rstream(stream *restrict ss, const char *restrict charset, const 
char *restrict name);
-stream *iconv_wstream(stream *restrict ss, const char *restrict charset, const 
char *restrict name);
 bool isa_block_stream(const stream *s);
 stream *lz4_stream(stream *inner, int preset);
 stream *mapi_request_download(const char *filename, bool binary, bstream *rs, 
stream *ws);
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
@@ -473,6 +473,40 @@ opener_wastream(char *filename)
 }
 
 
+#ifdef HAVE_ICONV
+#include "iconv-stream.h"
+#else
+static stream *
+iconv_rstream(stream *restrict ss, const char *restrict charset, const char 
*restrict name)
+{
+   if (ss == NULL || charset == NULL || name == NULL)
+   return NULL;
+   if (ss->isutf8 ||
+   strcmp(charset, "utf-8") == 0 ||
+   strcmp(charset, "UTF-8") == 0 ||
+   strcmp(charset, "UTF8") == 0)
+   return ss;
+
+   fprintf(stderr, "ICONV support has been left out of this MonetDB");
+   return NULL;
+}
+
+static stream *
+iconv_wstream(stream *restrict ss, const char *restrict charset, const char 
*restrict name)
+{
+   if (ss == NULL || charset == NULL || name == NULL)
+   return NULL;
+   if (ss->isutf8 ||
+   strcmp(charset, "utf-8") == 0 ||
+   strcmp(charset, "UTF-8") == 0 ||
+   strcmp(charset, "UTF8") == 0)
+   return ss;
+
+   fprintf(stderr, "ICONV support has been left out of this MonetDB");
+   return NULL;
+}
+#endif
+
 static stream *
 wrapper_read_iconv(stream *s, char *enc)
 {
diff --git a/clients/mapiclient/CMakeLists.txt 
b/clients/mapiclient/CMakeLists.txt
--- a/clients/mapiclient/CMakeLists.txt
+++ b/clients/mapiclient/CMakeLists.txt
@@ -39,10 +39,12 @@ target_sources(mclient
   ReadlineTools.h
   mhelp.c
   mhelp.h
+  iconv-stream.h
   curl-stream.h)
 
 target_include_directories(mclient
   PRIVATE
+  $<$:${CMAKE_REQUIRED_INCLUDES}>
   $<$:${HAVE_GETOPT_H}>)
 
 target_link_libraries(mclient
diff --git a/clients/mapiclient/iconv-stream.h 
b/clients/mapiclient/iconv-stream.h
new file mode 100644
--- /dev/null
+++ b/clients/mapiclient/iconv-stream.h
@@ -0,0 +1,256 @@
+#include 
+
+struct ic_priv_t {
+   stream *s;
+   iconv_t cd;
+   bool eof;
+   size_t buflen;
+   char buffer[BUFSIZ];
+};
+
+static ssize_t
+ic_read(void *restrict private, void *restrict buf, size_t elmsize, size_t cnt)
+{
+   struct ic_priv_t *ic = private;
+   char *inbuf = ic->buffer;
+   size_t inbytesleft = ic->buflen;
+   char *outbuf = buf;
+   size_t outbytesleft = elmsize * cnt;
+
+   if (outbytesleft == 0)
+   return 0;
+   while (outbytesleft > 0 && !ic->eof) {
+   if (ic->buflen == sizeof(ic->buffer)) {
+   /* ridiculously long multibyte sequence, return error */
+   fprintf(stderr, "multibyte sequence too long");
+   return -1;
+   }
+
+   switch (mnstr_read(ic->s, ic->buffer + ic->buflen, 1, 1)) {
+   case 1:
+   /* expected: read one byte */
+   ic->buflen++;
+   inbytesleft++;
+   break;
+   case 0:
+   /* end of file */
+   ic->eof = true;
+   if (ic->buflen > 0) {
+   /* incomplete input */
+   fprintf(stderr, "incomplete input");
+   return -1;
+   }
+   if (iconv(ic->cd, NULL, NULL, , ) 
== (size_t) -1) {
+   /* some error occurred */
+   

MonetDB: ascii-flag - Use a single source for open_urlstream (CU...

2024-05-03 Thread Sjoerd Mullender via checkin-list
Changeset: f3c92bdfb810 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/f3c92bdfb810
Added Files:
clients/mapiclient/curl-stream.h
Modified Files:
clients/examples/C/CMakeLists.txt
clients/examples/C/streamcat.c
clients/mapiclient/CMakeLists.txt
Branch: ascii-flag
Log Message:

Use a single source for open_urlstream (CURL support).


diffs (182 lines):

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
@@ -43,6 +43,10 @@ target_link_libraries(smack01
 add_executable(streamcat
   streamcat.c)
 
+target_include_directories(streamcat
+  PRIVATE
+  ../../mapiclient)
+
 target_link_libraries(streamcat
   PRIVATE
   monetdb_config_header
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
@@ -437,68 +437,20 @@ opener_rastream(char *filename)
 }
 
 #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;
-}
+#include "curl-stream.h"
 
 static stream *
-open_urlstream(const char *url)
+opener_urlstream(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 */
+   stream *s = open_urlstream(url,  errbuf);
+   if (s == NULL)
+   fprintf(stderr, "%s\n", errbuf);
return s;
 }
 #else
 static stream *
-open_urlstream(const char *url)
+opener_urlstream(char *url)
 {
(void) url;
return NULL;
@@ -506,13 +458,6 @@ open_urlstream(const char *url)
 #endif
 
 static stream *
-opener_urlstream(char *url)
-{
-   stream *s = open_urlstream(url);
-   return s;
-}
-
-static stream *
 opener_wstream(char *filename)
 {
stream *s = open_wstream(filename);
diff --git a/clients/mapiclient/CMakeLists.txt 
b/clients/mapiclient/CMakeLists.txt
--- a/clients/mapiclient/CMakeLists.txt
+++ b/clients/mapiclient/CMakeLists.txt
@@ -38,7 +38,8 @@ target_sources(mclient
   ReadlineTools.c
   ReadlineTools.h
   mhelp.c
-  mhelp.h)
+  mhelp.h
+  curl-stream.h)
 
 target_include_directories(mclient
   PRIVATE
diff --git a/clients/mapiclient/curl-stream.h b/clients/mapiclient/curl-stream.h
new file mode 100644
--- /dev/null
+++ b/clients/mapiclient/curl-stream.h
@@ -0,0 +1,58 @@
+#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, CURL_ERROR_SIZE, "could not create CURL 
handle");
+