MonetDB: Jun2020 - Also don't use PCRE for patterns without _ no...

2020-06-05 Thread Sjoerd Mullender
Changeset: c70c5c521c4d for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=c70c5c521c4d
Modified Files:
monetdb5/mal/Tests/tst201.malC
monetdb5/modules/mal/pcre.c
Branch: Jun2020
Log Message:

Also don't use PCRE for patterns without _ not ending in %.


diffs (truncated from 366 to 300 lines):

diff --git a/monetdb5/mal/Tests/tst201.malC b/monetdb5/mal/Tests/tst201.malC
--- a/monetdb5/mal/Tests/tst201.malC
+++ b/monetdb5/mal/Tests/tst201.malC
@@ -61,14 +61,14 @@ exit  MALException;
v45:= algebra.slice(b,v43,v44);
v46:= io.print(v45);
 
-   v75:= algebra.likeselect(b, nil:bat[:oid], "ox", nil:str, false, false);
+   v75:= algebra.likeselect(b, nil:bat[:oid], "ox", "", false, false);
v76:= io.print(v75);
 
-   v78:= algebra.likeselect(b, nil:bat[:oid], "fo", nil:str, false, false);
+   v78:= algebra.likeselect(b, nil:bat[:oid], "fo", "", false, false);
v79:= io.print(v78);
 
-   v81:= algebra.likeselect(b, nil:bat[:oid], "fox", nil:str, false, 
false);
+   v81:= algebra.likeselect(b, nil:bat[:oid], "fox", "", false, false);
v82:= io.print(v81);
 
-   v84:= algebra.likeselect(b, nil:bat[:oid], " fox", nil:str, false, 
false);
+   v84:= algebra.likeselect(b, nil:bat[:oid], " fox", "", false, false);
v85:= io.print(v84);
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
@@ -85,13 +85,14 @@ mal_export str ILIKEjoin(bat *r1, bat *r
 mal_export str ILIKEjoin1(bat *r1, bat *r2, const bat *lid, const bat *rid, 
const bat *slid, const bat *srid, const bit *nil_matches, const lng *estimate);
 
 /* current implementation assumes simple %keyword% [keyw%]* */
-typedef struct RE {
+struct RE {
char *k;
uint32_t *w;
-   bool search;
+   bool search:1,
+   atend:1;
size_t len;
struct RE *n;
-} RE;
+};
 
 /* We cannot use strcasecmp and strncasecmp since they work byte for
  * byte and don't deal with multibyte encodings (such as UTF-8).
@@ -233,32 +234,32 @@ myucslen(const uint32_t *ucs)
return i;
 }
 
-static inline int
-mywstrncasecmp(const char *restrict s1, const uint32_t *restrict s2, size_t n2)
+static inline bool
+mywstrncaseeq(const char *restrict s1, const uint32_t *restrict s2, size_t n2, 
bool atend)
 {
uint32_t c1;
 
while (n2 > 0) {
size_t nn1 = utfc8touc(&c1, s1);
if (nn1 == 0 || nn1 == (size_t) -1)
-   return -(*s2 != 0);
+   return (*s2 == 0);
if (*s2 == 0)
-   return 1;
+   return false;
if (nn1 == (size_t) -1 || nn1 == (size_t) -2)
-   return 0;/* actually an error that shouldn't 
happen */
+   return true; /* actually an error that shouldn't 
happen */
 #if SIZEOF_WCHAR_T == 2
if (c1 > 0x || *s2 > 0x) {
if (c1 != *s2)
-   return c1 - *s2;
+   return false;
} else
 #endif
if (towlower((wint_t) c1) != towlower((wint_t) *s2))
-   return towlower((wint_t) c1) - towlower((wint_t) *s2);
+   return false;
s1 += nn1;
n2--;
s2++;
}
-   return 0;
+   return !atend || *s1 == 0;
 }
 
 static inline int
@@ -316,12 +317,12 @@ mywstrcasecmp(const char *restrict s1, c
 }
 
 static inline const char *
-mywstrcasestr(const char *restrict haystack, const uint32_t *restrict wneedle)
+mywstrcasestr(const char *restrict haystack, const uint32_t *restrict wneedle, 
bool atend)
 {
size_t nlen = myucslen(wneedle);
 
if (nlen == 0)
-   return haystack;
+   return atend ? haystack + strlen(haystack) : haystack;
 
size_t hlen = strlen(haystack);
 
@@ -347,7 +348,7 @@ mywstrcasestr(const char *restrict hayst
break;
h += j;
}
-   if (i == nlen)
+   if (i == nlen && (!atend || haystack[h] == 0))
return haystack;
haystack += step;
hlen -= step;
@@ -362,31 +363,26 @@ static bool
 re_simple(const char *pat, unsigned char esc)
 {
bool escaped = false;
-   bool percatend = false;
 
if (pat == 0)
-   return 0;
+   return false;
if (*pat == '%') {
-   percatend = true;
pat++;
}
while (*pat) {
-   percatend = false;
if (escaped) {
escaped = false;
} else if ((unsigned char) *pat == esc) {
escaped = true;
} else if (*pat == '_') {
-

MonetDB: mbedded - merged

2020-06-05 Thread Niels Nes
Changeset: 54b3ccf00f0a for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=54b3ccf00f0a
Modified Files:
monetdb5/modules/mal/pcre.c
sql/backends/monet5/sql_upgrades.c
sql/server/rel_select.c
sql/server/sql_env.c
sql/test/emptydb-upgrade-chain-hge/Tests/upgrade.stable.out.int128

sql/test/emptydb-upgrade-chain-hge/Tests/upgrade.stable.out.powerpc64.int128
sql/test/emptydb-upgrade-chain/Tests/upgrade.stable.out
sql/test/emptydb-upgrade-chain/Tests/upgrade.stable.out.32bit
sql/test/emptydb-upgrade-chain/Tests/upgrade.stable.out.int128
sql/test/emptydb-upgrade-chain/Tests/upgrade.stable.out.powerpc64
sql/test/emptydb-upgrade-chain/Tests/upgrade.stable.out.powerpc64.int128
sql/test/emptydb-upgrade-hge/Tests/upgrade.stable.out.int128
sql/test/emptydb-upgrade/Tests/upgrade.stable.out
sql/test/emptydb-upgrade/Tests/upgrade.stable.out.32bit
sql/test/emptydb-upgrade/Tests/upgrade.stable.out.int128
sql/test/emptydb/Tests/check.stable.out
sql/test/emptydb/Tests/check.stable.out.32bit
sql/test/emptydb/Tests/check.stable.out.int128
sql/test/miscellaneous/Tests/simple_selects.sql
sql/test/miscellaneous/Tests/simple_selects.stable.err
sql/test/subquery/Tests/subquery6.sql
sql/test/subquery/Tests/subquery6.stable.out
sql/test/testdb-upgrade-chain-hge/Tests/upgrade.stable.out.int128
sql/test/testdb-upgrade-chain/Tests/upgrade.stable.out
sql/test/testdb-upgrade-chain/Tests/upgrade.stable.out.32bit
sql/test/testdb-upgrade-chain/Tests/upgrade.stable.out.int128
sql/test/testdb-upgrade-hge/Tests/upgrade.stable.out.int128
sql/test/testdb-upgrade/Tests/upgrade.stable.out
sql/test/testdb-upgrade/Tests/upgrade.stable.out.32bit
sql/test/testdb-upgrade/Tests/upgrade.stable.out.int128
testing/Mtest.py.in
Branch: mbedded
Log Message:

merged


diffs (truncated from 1005 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
@@ -1451,8 +1451,8 @@ sql2pcre(str *r, const char *pat, const 
 
if (strlen(esc_str) > 1)
throw(MAL, "pcre.sql2pcre", SQLSTATE(22019) ILLEGAL_ARGUMENT ": 
ESCAPE string must have length 1");
-   if (pat == NULL )
-   throw(MAL, "pcre.sql2pcre", OPERATION_FAILED);
+   if (pat == NULL)
+   throw(MAL, "pcre.sql2pcre", SQLSTATE(22019) ILLEGAL_ARGUMENT ": 
(I)LIKE pattern must not be NULL");
ppat = GDKmalloc(strlen(pat)*3+3 /* 3 = "^'the translated regexp'$0" 
*/);
if (ppat == NULL)
throw(MAL, "pcre.sql2pcre", SQLSTATE(HY013) MAL_MALLOC_FAIL);
@@ -1513,7 +1513,7 @@ sql2pcre(str *r, const char *pat, const 
GDKfree(*r);
*r = NULL;
if (escaped)
-   throw(MAL, "pcre.sql2pcre", OPERATION_FAILED);
+   throw(MAL, "pcre.sql2pcre", SQLSTATE(22019) 
ILLEGAL_ARGUMENT ": (I)LIKE pattern must not end with escape character");
*r = GDKstrdup(str_nil);
if (*r == NULL)
throw(MAL, "pcre.sql2pcre", SQLSTATE(HY013) 
MAL_MALLOC_FAIL);
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
@@ -216,15 +216,39 @@ sql_update_hugeint(Client c, mvc *sql, c
"create aggregate stddev_samp(val HUGEINT) returns 
DOUBLE\n"
" external name \"aggr\".\"stdev\";\n"
"GRANT EXECUTE ON AGGREGATE stddev_samp(HUGEINT) TO 
PUBLIC;\n"
+   "create window stddev_samp(val HUGEINT) returns 
DOUBLE\n"
+   " external name \"sql\".\"stdev\";\n"
+   "GRANT EXECUTE ON WINDOW stddev_samp(HUGEINT) TO 
PUBLIC;\n"
"create aggregate stddev_pop(val HUGEINT) returns 
DOUBLE\n"
" external name \"aggr\".\"stdevp\";\n"
"GRANT EXECUTE ON AGGREGATE stddev_pop(HUGEINT) TO 
PUBLIC;\n"
+   "create window stddev_pop(val HUGEINT) returns DOUBLE\n"
+   " external name \"sql\".\"stdevp\";\n"
+   "GRANT EXECUTE ON WINDOW stddev_pop(HUGEINT) TO 
PUBLIC;\n"
"create aggregate var_samp(val HUGEINT) returns 
DOUBLE\n"
" external name \"aggr\".\"variance\";\n"
"GRANT EXECUTE ON AGGREGATE var_samp(HUGEINT) TO 
PUBLIC;\n"
+   "create window var_samp(val HUGEINT) returns DOUBLE\n"
+   " external name \"sql\".\"variance\";\n"
+   "GRANT EXECUTE ON WINDOW var_samp(HUGEINT) TO PUBLIC;\n"
+   "creat

MonetDB: unlock - merged

2020-06-05 Thread Niels Nes
Changeset: 8f4c6b364de1 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=8f4c6b364de1
Modified Files:
monetdb5/modules/mal/pcre.c
sql/backends/monet5/sql_upgrades.c
sql/server/rel_select.c
sql/server/sql_env.c
sql/test/emptydb-upgrade-chain-hge/Tests/upgrade.stable.out.int128

sql/test/emptydb-upgrade-chain-hge/Tests/upgrade.stable.out.powerpc64.int128
sql/test/emptydb-upgrade-chain/Tests/upgrade.stable.out
sql/test/emptydb-upgrade-chain/Tests/upgrade.stable.out.32bit
sql/test/emptydb-upgrade-chain/Tests/upgrade.stable.out.int128
sql/test/emptydb-upgrade-chain/Tests/upgrade.stable.out.powerpc64
sql/test/emptydb-upgrade-chain/Tests/upgrade.stable.out.powerpc64.int128
sql/test/emptydb-upgrade-hge/Tests/upgrade.stable.out.int128
sql/test/emptydb-upgrade/Tests/upgrade.stable.out
sql/test/emptydb-upgrade/Tests/upgrade.stable.out.32bit
sql/test/emptydb-upgrade/Tests/upgrade.stable.out.int128
sql/test/emptydb/Tests/check.stable.out
sql/test/emptydb/Tests/check.stable.out.32bit
sql/test/emptydb/Tests/check.stable.out.int128
sql/test/miscellaneous/Tests/simple_selects.sql
sql/test/miscellaneous/Tests/simple_selects.stable.err
sql/test/subquery/Tests/subquery6.sql
sql/test/subquery/Tests/subquery6.stable.out
sql/test/testdb-upgrade-chain-hge/Tests/upgrade.stable.out.int128
sql/test/testdb-upgrade-chain/Tests/upgrade.stable.out
sql/test/testdb-upgrade-chain/Tests/upgrade.stable.out.32bit
sql/test/testdb-upgrade-chain/Tests/upgrade.stable.out.int128
sql/test/testdb-upgrade-hge/Tests/upgrade.stable.out.int128
sql/test/testdb-upgrade/Tests/upgrade.stable.out
sql/test/testdb-upgrade/Tests/upgrade.stable.out.32bit
sql/test/testdb-upgrade/Tests/upgrade.stable.out.int128
testing/Mtest.py.in
Branch: unlock
Log Message:

merged


diffs (truncated from 942 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
@@ -1449,8 +1449,8 @@ sql2pcre(str *r, const char *pat, const 
 
if (strlen(esc_str) > 1)
throw(MAL, "pcre.sql2pcre", SQLSTATE(22019) ILLEGAL_ARGUMENT ": 
ESCAPE string must have length 1");
-   if (pat == NULL )
-   throw(MAL, "pcre.sql2pcre", OPERATION_FAILED);
+   if (pat == NULL)
+   throw(MAL, "pcre.sql2pcre", SQLSTATE(22019) ILLEGAL_ARGUMENT ": 
(I)LIKE pattern must not be NULL");
ppat = GDKmalloc(strlen(pat)*3+3 /* 3 = "^'the translated regexp'$0" 
*/);
if (ppat == NULL)
throw(MAL, "pcre.sql2pcre", SQLSTATE(HY013) MAL_MALLOC_FAIL);
@@ -1511,7 +1511,7 @@ sql2pcre(str *r, const char *pat, const 
GDKfree(*r);
*r = NULL;
if (escaped)
-   throw(MAL, "pcre.sql2pcre", OPERATION_FAILED);
+   throw(MAL, "pcre.sql2pcre", SQLSTATE(22019) 
ILLEGAL_ARGUMENT ": (I)LIKE pattern must not end with escape character");
*r = GDKstrdup(str_nil);
if (*r == NULL)
throw(MAL, "pcre.sql2pcre", SQLSTATE(HY013) 
MAL_MALLOC_FAIL);
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
@@ -215,15 +215,39 @@ sql_update_hugeint(Client c, mvc *sql, c
"create aggregate stddev_samp(val HUGEINT) returns 
DOUBLE\n"
" external name \"aggr\".\"stdev\";\n"
"GRANT EXECUTE ON AGGREGATE stddev_samp(HUGEINT) TO 
PUBLIC;\n"
+   "create window stddev_samp(val HUGEINT) returns 
DOUBLE\n"
+   " external name \"sql\".\"stdev\";\n"
+   "GRANT EXECUTE ON WINDOW stddev_samp(HUGEINT) TO 
PUBLIC;\n"
"create aggregate stddev_pop(val HUGEINT) returns 
DOUBLE\n"
" external name \"aggr\".\"stdevp\";\n"
"GRANT EXECUTE ON AGGREGATE stddev_pop(HUGEINT) TO 
PUBLIC;\n"
+   "create window stddev_pop(val HUGEINT) returns DOUBLE\n"
+   " external name \"sql\".\"stdevp\";\n"
+   "GRANT EXECUTE ON WINDOW stddev_pop(HUGEINT) TO 
PUBLIC;\n"
"create aggregate var_samp(val HUGEINT) returns 
DOUBLE\n"
" external name \"aggr\".\"variance\";\n"
"GRANT EXECUTE ON AGGREGATE var_samp(HUGEINT) TO 
PUBLIC;\n"
+   "create window var_samp(val HUGEINT) returns DOUBLE\n"
+   " external name \"sql\".\"variance\";\n"
+   "GRANT EXECUTE ON WINDOW var_samp(HUGEINT) TO PUBLIC;\n"
+   "create 

MonetDB: unlock - merged with default

2020-06-05 Thread Niels Nes
Changeset: abe025f0366b for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=abe025f0366b
Added Files:
sql/test/Tests/hot_snapshot.py
sql/test/Tests/hot_snapshot.stable.err
sql/test/Tests/hot_snapshot.stable.out
sql/test/Tests/hot_snapshot_bz2.py
sql/test/Tests/hot_snapshot_bz2.stable.err
sql/test/Tests/hot_snapshot_bz2.stable.out
sql/test/Tests/hot_snapshot_gz.py
sql/test/Tests/hot_snapshot_gz.stable.err
sql/test/Tests/hot_snapshot_gz.stable.out
sql/test/Tests/hot_snapshot_lz4.py
sql/test/Tests/hot_snapshot_lz4.stable.err
sql/test/Tests/hot_snapshot_lz4.stable.out
sql/test/Tests/hot_snapshot_xz.py
sql/test/Tests/hot_snapshot_xz.stable.err
sql/test/Tests/hot_snapshot_xz.stable.out
Removed Files:
sql/test/Tests/hot-snapshot-bz2.py
sql/test/Tests/hot-snapshot-bz2.stable.err
sql/test/Tests/hot-snapshot-bz2.stable.out
sql/test/Tests/hot-snapshot-gz.py
sql/test/Tests/hot-snapshot-gz.stable.err
sql/test/Tests/hot-snapshot-gz.stable.out
sql/test/Tests/hot-snapshot-lz4.py
sql/test/Tests/hot-snapshot-lz4.stable.err
sql/test/Tests/hot-snapshot-lz4.stable.out
sql/test/Tests/hot-snapshot-xz.py
sql/test/Tests/hot-snapshot-xz.stable.err
sql/test/Tests/hot-snapshot-xz.stable.out
sql/test/Tests/hot-snapshot.py
sql/test/Tests/hot-snapshot.stable.err
sql/test/Tests/hot-snapshot.stable.out
sql/test/Tests/hot_snapshot_compression.py
Modified Files:
clients/Tests/exports.stable.out
common/stream/stream.c
monetdb5/modules/mal/pcre.c
sql/backends/monet5/sql_subquery.c
sql/server/rel_optimizer.c
sql/server/rel_select.c
sql/server/rel_unnest.c
sql/server/rel_unnest.h
sql/server/sql_query.c
sql/server/sql_query.h
sql/storage/bat/bat_logger.c
sql/storage/store.c
sql/test/BugTracker-2011/Tests/crash_on_alias.Bug-2798.stable.out
sql/test/BugTracker-2011/Tests/crash_on_alias.Bug-2798.stable.out.int128
sql/test/BugTracker-2013/Tests/syntaxerror.Bug-3399.stable.out
sql/test/Tests/All
sql/test/bugs/Tests/select_select_bug.stable.out
sql/test/subquery/Tests/correlated.stable.out
sql/test/subquery/Tests/subquery.stable.out
sql/test/subquery/Tests/subquery3.stable.err
sql/test/subquery/Tests/subquery3.stable.out
sql/test/subquery/Tests/subquery4.stable.out
sql/test/subquery/Tests/subquery5.stable.out
sql/test/subquery/Tests/subquery6.sql
sql/test/subquery/Tests/subquery6.stable.err
sql/test/subquery/Tests/subquery6.stable.out
Branch: unlock
Log Message:

merged with default


diffs (truncated from 1887 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
@@ -1626,8 +1626,8 @@ str MTIMEtimestamp_decade(int *ret, cons
 str MTIMEtimestamp_decade_bulk(bat *ret, const bat *bid);
 str MTIMEtimestamp_diff_msec(lng *ret, const timestamp *v1, const timestamp 
*v2);
 str MTIMEtimestamp_diff_msec_bulk(bat *ret, const bat *bid1, const bat *bid2);
-str MTIMEtimestamp_diff_msec_bulk_p1(bat *ret, const timestamp *src1, const 
bat *bid2);
-str MTIMEtimestamp_diff_msec_bulk_p2(bat *ret, const bat *bid1, const 
timestamp *src2);
+str MTIMEtimestamp_diff_msec_bulk_p1(bat *ret, const timestamp *restrict src1, 
const bat *bid2);
+str MTIMEtimestamp_diff_msec_bulk_p2(bat *ret, const bat *bid1, const 
timestamp *restrict src2);
 str MTIMEtimestamp_extract_date(date *ret, const timestamp *src);
 str MTIMEtimestamp_extract_date_bulk(bat *ret, const bat *bid);
 str MTIMEtimestamp_extract_daytime(daytime *ret, const timestamp *src);
diff --git a/common/stream/stream.c b/common/stream/stream.c
--- a/common/stream/stream.c
+++ b/common/stream/stream.c
@@ -1824,8 +1824,15 @@ stream_lz4close(stream *s)
lz4_stream *lz4 = s->stream_data.p;
 
if (lz4) {
-   stream_lz4flush(s);
if(!s->readonly) {
+   char final_bytes[128]; // 4 would probably suffice
+   stream_lz4flush(s);
+   size_t remainder = 
LZ4F_compressEnd(lz4->context.comp_context, final_bytes, sizeof(final_bytes), 
NULL);
+   // no channel to return an error from here :(
+   if (!LZ4F_isError(remainder)) {
+   // again, hope for the best
+   (void) fwrite(final_bytes, 1, remainder, 
lz4->fp);
+   }
(void) 
LZ4F_freeCompressionContext(lz4->context.comp_context);
} else {
(void) 
LZ4F_freeDecompressionContext(lz4->context.dec_context);
diff --git a/monetd

MonetDB: default - Reduce differences after upgrade.

2020-06-05 Thread Sjoerd Mullender
Changeset: 37f99d1a0a6d for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=37f99d1a0a6d
Modified Files:
sql/backends/monet5/sql_upgrades.c
sql/server/sql_env.c
sql/test/emptydb-upgrade-chain-hge/Tests/upgrade.stable.out.int128

sql/test/emptydb-upgrade-chain-hge/Tests/upgrade.stable.out.powerpc64.int128
sql/test/emptydb-upgrade-chain/Tests/upgrade.stable.out
sql/test/emptydb-upgrade-chain/Tests/upgrade.stable.out.32bit
sql/test/emptydb-upgrade-chain/Tests/upgrade.stable.out.int128
sql/test/emptydb-upgrade-chain/Tests/upgrade.stable.out.powerpc64
sql/test/emptydb-upgrade-chain/Tests/upgrade.stable.out.powerpc64.int128
sql/test/emptydb-upgrade-hge/Tests/upgrade.stable.out.int128
sql/test/emptydb-upgrade/Tests/upgrade.stable.out
sql/test/emptydb-upgrade/Tests/upgrade.stable.out.32bit
sql/test/emptydb-upgrade/Tests/upgrade.stable.out.int128
sql/test/emptydb/Tests/check.stable.out
sql/test/emptydb/Tests/check.stable.out.32bit
sql/test/emptydb/Tests/check.stable.out.int128
sql/test/testdb-upgrade-chain-hge/Tests/upgrade.stable.out.int128
sql/test/testdb-upgrade-chain/Tests/upgrade.stable.out
sql/test/testdb-upgrade-chain/Tests/upgrade.stable.out.32bit
sql/test/testdb-upgrade-chain/Tests/upgrade.stable.out.int128
sql/test/testdb-upgrade-hge/Tests/upgrade.stable.out.int128
sql/test/testdb-upgrade/Tests/upgrade.stable.out
sql/test/testdb-upgrade/Tests/upgrade.stable.out.32bit
sql/test/testdb-upgrade/Tests/upgrade.stable.out.int128
Branch: default
Log Message:

Reduce differences after upgrade.


diffs (truncated from 440 to 300 lines):

diff --git a/sql/backends/monet5/sql_upgrades.c 
b/sql/backends/monet5/sql_upgrades.c
--- a/sql/backends/monet5/sql_upgrades.c
+++ b/sql/backends/monet5/sql_upgrades.c
@@ -2945,13 +2945,13 @@ sql_update_default(Client c, mvc *sql, c
/* scoping branch changes */
pos += snprintf(buf + pos, bufsize - pos,
"drop function \"sys\".\"var\"();\n"
-   "create function \"sys\".\"var\"()\n" 
-   "returns table(\n"
-   "\"schema\" string,\n"
-   "\"name\" string,\n"
-   "\"type\" string,\n"
-   "\"value\" string)\n"
-   " external name 
\"sql\".\"sql_variables\";\n"
+   "create function \"sys\".\"var\"() "
+   "returns table("
+   "\"schema\" string, "
+   "\"name\" string, "
+   "\"type\" string, "
+   "\"value\" string) "
+   "external name 
\"sql\".\"sql_variables\";\n"
"grant execute on function 
\"sys\".\"var\" to public;\n");
 
pos += snprintf(buf + pos, bufsize - pos,
diff --git a/sql/server/sql_env.c b/sql/server/sql_env.c
--- a/sql/server/sql_env.c
+++ b/sql/server/sql_env.c
@@ -99,6 +99,6 @@ sql_create_env(mvc *m, sql_schema *s)
 
/* add function */
ops = sa_list(m->sa);
-   mvc_create_func(m, NULL, s, "var", ops, res, F_UNION, FUNC_LANG_SQL, 
"sql", "sql_variables", "CREATE FUNCTION \"sys\".\"var\"() RETURNS 
TABLE(\"schema\" string, \"name\" string, \"type\" string, \"value\" string) 
EXTERNAL NAME \"sql\".\"sql_variables\";", FALSE, FALSE, TRUE);
+   mvc_create_func(m, NULL, s, "var", ops, res, F_UNION, FUNC_LANG_SQL, 
"sql", "sql_variables", "create function \"sys\".\"var\"() returns 
table(\"schema\" string, \"name\" string, \"type\" string, \"value\" string) 
external name \"sql\".\"sql_variables\";", FALSE, FALSE, TRUE);
return 0;
 }
diff --git a/sql/test/emptydb-upgrade-chain-hge/Tests/upgrade.stable.out.int128 
b/sql/test/emptydb-upgrade-chain-hge/Tests/upgrade.stable.out.int128
--- a/sql/test/emptydb-upgrade-chain-hge/Tests/upgrade.stable.out.int128
+++ b/sql/test/emptydb-upgrade-chain-hge/Tests/upgrade.stable.out.int128
@@ -38,13 +38,7 @@ grant select on sys.queue to public;
 update sys.functions set system = true where schema_id = (select id from 
sys.schemas where name = 'sys') and name = 'queue' and type = 5;
 update sys._tables set system = true where schema_id = (select id from 
sys.schemas where name = 'sys') and name = 'queue';
 drop function "sys"."var"();
-create function "sys"."var"()
-returns table(
-"schema" string,
-"name" string,
-"type" string,
-"value" string)
- external name "sql"."sql_variables";
+create function "sys"."var"() returns table("schema" string, "name" string, 

MonetDB: default - Merge with Jun2020 branch.

2020-06-05 Thread Sjoerd Mullender
Changeset: 0f82cb5c99fc for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=0f82cb5c99fc
Modified Files:
monetdb5/modules/mal/pcre.c
sql/backends/monet5/sql_upgrades.c
sql/server/rel_select.c

sql/test/emptydb-upgrade-chain-hge/Tests/upgrade.stable.out.powerpc64.int128
sql/test/emptydb-upgrade-chain/Tests/upgrade.stable.out.int128
sql/test/emptydb-upgrade-chain/Tests/upgrade.stable.out.powerpc64.int128
sql/test/emptydb-upgrade/Tests/upgrade.stable.out.int128
sql/test/miscellaneous/Tests/simple_selects.sql
sql/test/miscellaneous/Tests/simple_selects.stable.err
sql/test/subquery/Tests/subquery6.sql
sql/test/subquery/Tests/subquery6.stable.out
sql/test/testdb-upgrade-chain/Tests/upgrade.stable.out.int128
sql/test/testdb-upgrade/Tests/upgrade.stable.out.int128
testing/Mtest.py.in
Branch: default
Log Message:

Merge with Jun2020 branch.


diffs (truncated from 583 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
@@ -1449,8 +1449,8 @@ sql2pcre(str *r, const char *pat, const 
 
if (strlen(esc_str) > 1)
throw(MAL, "pcre.sql2pcre", SQLSTATE(22019) ILLEGAL_ARGUMENT ": 
ESCAPE string must have length 1");
-   if (pat == NULL )
-   throw(MAL, "pcre.sql2pcre", OPERATION_FAILED);
+   if (pat == NULL)
+   throw(MAL, "pcre.sql2pcre", SQLSTATE(22019) ILLEGAL_ARGUMENT ": 
(I)LIKE pattern must not be NULL");
ppat = GDKmalloc(strlen(pat)*3+3 /* 3 = "^'the translated regexp'$0" 
*/);
if (ppat == NULL)
throw(MAL, "pcre.sql2pcre", SQLSTATE(HY013) MAL_MALLOC_FAIL);
@@ -1511,7 +1511,7 @@ sql2pcre(str *r, const char *pat, const 
GDKfree(*r);
*r = NULL;
if (escaped)
-   throw(MAL, "pcre.sql2pcre", OPERATION_FAILED);
+   throw(MAL, "pcre.sql2pcre", SQLSTATE(22019) 
ILLEGAL_ARGUMENT ": (I)LIKE pattern must not end with escape character");
*r = GDKstrdup(str_nil);
if (*r == NULL)
throw(MAL, "pcre.sql2pcre", SQLSTATE(HY013) 
MAL_MALLOC_FAIL);
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
@@ -216,15 +216,39 @@ sql_update_hugeint(Client c, mvc *sql, c
"create aggregate stddev_samp(val HUGEINT) returns 
DOUBLE\n"
" external name \"aggr\".\"stdev\";\n"
"GRANT EXECUTE ON AGGREGATE stddev_samp(HUGEINT) TO 
PUBLIC;\n"
+   "create window stddev_samp(val HUGEINT) returns 
DOUBLE\n"
+   " external name \"sql\".\"stdev\";\n"
+   "GRANT EXECUTE ON WINDOW stddev_samp(HUGEINT) TO 
PUBLIC;\n"
"create aggregate stddev_pop(val HUGEINT) returns 
DOUBLE\n"
" external name \"aggr\".\"stdevp\";\n"
"GRANT EXECUTE ON AGGREGATE stddev_pop(HUGEINT) TO 
PUBLIC;\n"
+   "create window stddev_pop(val HUGEINT) returns DOUBLE\n"
+   " external name \"sql\".\"stdevp\";\n"
+   "GRANT EXECUTE ON WINDOW stddev_pop(HUGEINT) TO 
PUBLIC;\n"
"create aggregate var_samp(val HUGEINT) returns 
DOUBLE\n"
" external name \"aggr\".\"variance\";\n"
"GRANT EXECUTE ON AGGREGATE var_samp(HUGEINT) TO 
PUBLIC;\n"
+   "create window var_samp(val HUGEINT) returns DOUBLE\n"
+   " external name \"sql\".\"variance\";\n"
+   "GRANT EXECUTE ON WINDOW var_samp(HUGEINT) TO PUBLIC;\n"
+   "create aggregate covar_samp(e1 HUGEINT, e2 HUGEINT) 
returns DOUBLE\n"
+   " external name \"aggr\".\"covariance\";\n"
+   "GRANT EXECUTE ON AGGREGATE covar_samp(HUGEINT, 
HUGEINT) TO PUBLIC;\n"
+   "create window covar_samp(e1 HUGEINT, e2 HUGEINT) 
returns DOUBLE\n"
+   " external name \"sql\".\"covariance\";\n"
+   "GRANT EXECUTE ON WINDOW covar_samp(HUGEINT, HUGEINT) 
TO PUBLIC;\n"
"create aggregate var_pop(val HUGEINT) returns DOUBLE\n"
" external name \"aggr\".\"variancep\";\n"
"GRANT EXECUTE ON AGGREGATE var_pop(HUGEINT) TO 
PUBLIC;\n"
+   "create window var_pop(val HUGEINT) returns DOUBLE\n"
+   " external name \"sql\".\"variancep\";\n"
+   "GRANT EXECUTE ON WINDOW var_pop(HUGEINT) TO PUBLIC;\n"
+   "create aggregate covar_pop(e1 HUGEINT, e2 HUGEINT) 
returns DOUBLE\n"
+

MonetDB: Jun2020 - Properly deal with missing lz4 python module

2020-06-05 Thread Joeri van Ruth
Changeset: 663fc7d7452e for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=663fc7d7452e
Added Files:
sql/test/Tests/hot_snapshot_lz4_lite.py
sql/test/Tests/hot_snapshot_lz4_lite.stable.err
sql/test/Tests/hot_snapshot_lz4_lite.stable.out
Modified Files:
sql/test/Tests/All
sql/test/Tests/hot_snapshot.py
Branch: Jun2020
Log Message:

Properly deal with missing lz4 python module


diffs (93 lines):

diff --git a/sql/test/Tests/All b/sql/test/Tests/All
--- a/sql/test/Tests/All
+++ b/sql/test/Tests/All
@@ -126,5 +126,6 @@ HAVE_PYMONETDB?hot_snapshot
 HAVE_PYMONETDB&HAVE_LIBZ?hot_snapshot_gz
 HAVE_PYMONETDB&HAVE_LIBBZ2?hot_snapshot_bz2
 HAVE_PYMONETDB&HAVE_LIBLZMA?hot_snapshot_xz
-HAVE_PYMONETDB&HAVE_LIBLZ4&HAVE_PYTHON_LZ4?hot_snapshot_lz4
+HAVE_PYTHON_LZ4&HAVE_PYMONETDB&HAVE_LIBLZ4?hot_snapshot_lz4
+!HAVE_PYTHON_LZ4&HAVE_PYMONETDB&HAVE_LIBLZ4?hot_snapshot_lz4_lite
 
diff --git a/sql/test/Tests/hot_snapshot.py b/sql/test/Tests/hot_snapshot.py
--- a/sql/test/Tests/hot_snapshot.py
+++ b/sql/test/Tests/hot_snapshot.py
@@ -29,7 +29,7 @@ assert dbfarm
 assert tstdb
 
 
-def test_snapshot(z_extension, expected_initial_bytes):
+def test_snapshot(z_extension, expected_initial_bytes, unpack=True):
 mydb = tstdb + '_snap'
 mydbdir = os.path.join(dbfarm, mydb)
 tarname = os.path.join(dbfarm, mydb + '.tar' + z_extension)
@@ -91,18 +91,8 @@ def test_snapshot(z_extension, expected_
 initial_bytes = f.read(len(expected_initial_bytes))
 assert initial_bytes == expected_initial_bytes
 
-# if not self.compression:
-# f = open(filename, 'rb')
-# elif self.compression == 'gz':
-# f = gzip.GzipFile(filename, 'rb', mtime=131875200)
-# elif self.compression == 'bz2':
-# f = bz2.BZ2File(filename, 'rb')
-# elif self.compression == 'xz':
-# f = lzma.LZMAFile(filename, 'rb')
-# elif self.compression == 'lz4':
-# f = lz4.frame.LZ4FrameFile(filename, 'rb')
-# else:
-# raise Exception("Unknown compression scheme: " + 
self.compression)
+if not unpack:
+return
 
 # open with decompression
 if tarname.endswith('.bz2'):
diff --git a/sql/test/Tests/hot_snapshot_lz4_lite.py 
b/sql/test/Tests/hot_snapshot_lz4_lite.py
new file mode 100644
--- /dev/null
+++ b/sql/test/Tests/hot_snapshot_lz4_lite.py
@@ -0,0 +1,10 @@
+#!/usr/bin/env python3
+
+# Test if the snapshot data is actually compressed.
+
+import sys
+import os
+sys.path.append(os.getenv('TSTSRCDIR'))
+from hot_snapshot import test_snapshot
+
+test_snapshot('.lz4', b'\x04\x22\x4D\x18', unpack=False)
diff --git a/sql/test/Tests/hot_snapshot_lz4_lite.stable.err 
b/sql/test/Tests/hot_snapshot_lz4_lite.stable.err
new file mode 100644
--- /dev/null
+++ b/sql/test/Tests/hot_snapshot_lz4_lite.stable.err
@@ -0,0 +1,12 @@
+stderr of test 'hot_snapshot_lz4_lite` in directory 'sql/test` itself:
+
+
+# 11:10:24 >  
+# 11:10:24 >  "/usr/bin/python3" "hot-snapshot-lz4.py" "hot-snapshot-lz4"
+# 11:10:24 >  
+
+
+# 11:10:24 >  
+# 11:10:24 >  "Done."
+# 11:10:24 >  
+
diff --git a/sql/test/Tests/hot_snapshot_lz4_lite.stable.out 
b/sql/test/Tests/hot_snapshot_lz4_lite.stable.out
new file mode 100644
--- /dev/null
+++ b/sql/test/Tests/hot_snapshot_lz4_lite.stable.out
@@ -0,0 +1,12 @@
+stdout of test 'hot_snapshot_lz4_lite` in directory 'sql/test` itself:
+
+
+# 11:10:24 >  
+# 11:10:24 >  "/usr/bin/python3" "hot-snapshot-lz4.py" "hot-snapshot-lz4"
+# 11:10:24 >  
+
+
+# 11:10:24 >  
+# 11:10:24 >  "Done."
+# 11:10:24 >  
+
___
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list


MonetDB: Jun2020 - Added conditional to test

2020-06-05 Thread Pedro Ferreira
Changeset: c0d2ed68bc4e for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=c0d2ed68bc4e
Modified Files:
sql/test/Tests/All
Branch: Jun2020
Log Message:

Added conditional to test


diffs (10 lines):

diff --git a/sql/test/Tests/All b/sql/test/Tests/All
--- a/sql/test/Tests/All
+++ b/sql/test/Tests/All
@@ -126,5 +126,5 @@ HAVE_PYMONETDB?hot_snapshot
 HAVE_PYMONETDB&HAVE_LIBZ?hot_snapshot_gz
 HAVE_PYMONETDB&HAVE_LIBBZ2?hot_snapshot_bz2
 HAVE_PYMONETDB&HAVE_LIBLZMA?hot_snapshot_xz
-HAVE_PYMONETDB&HAVE_LIBLZ4?hot_snapshot_lz4
+HAVE_PYMONETDB&HAVE_LIBLZ4&HAVE_PYTHON_LZ4?hot_snapshot_lz4
 
___
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list


MonetDB: Jun2020 - Fix upgrade from non-128 bit version to 128-b...

2020-06-05 Thread Sjoerd Mullender
Changeset: a6771befb7f6 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=a6771befb7f6
Modified Files:
sql/backends/monet5/sql_upgrades.c

sql/test/emptydb-upgrade-chain-hge/Tests/upgrade.stable.out.powerpc64.int128
sql/test/emptydb-upgrade-chain/Tests/upgrade.stable.out.int128
sql/test/emptydb-upgrade-chain/Tests/upgrade.stable.out.powerpc64.int128
sql/test/emptydb-upgrade/Tests/upgrade.stable.out.int128
sql/test/testdb-upgrade-chain/Tests/upgrade.stable.out.int128
sql/test/testdb-upgrade/Tests/upgrade.stable.out.int128
Branch: Jun2020
Log Message:

Fix upgrade from non-128 bit version to 128-bit version.


diffs (truncated from 19119 to 300 lines):

diff --git a/sql/backends/monet5/sql_upgrades.c 
b/sql/backends/monet5/sql_upgrades.c
--- a/sql/backends/monet5/sql_upgrades.c
+++ b/sql/backends/monet5/sql_upgrades.c
@@ -213,15 +213,39 @@ sql_update_hugeint(Client c, mvc *sql, c
"create aggregate stddev_samp(val HUGEINT) returns 
DOUBLE\n"
" external name \"aggr\".\"stdev\";\n"
"GRANT EXECUTE ON AGGREGATE stddev_samp(HUGEINT) TO 
PUBLIC;\n"
+   "create window stddev_samp(val HUGEINT) returns 
DOUBLE\n"
+   " external name \"sql\".\"stdev\";\n"
+   "GRANT EXECUTE ON WINDOW stddev_samp(HUGEINT) TO 
PUBLIC;\n"
"create aggregate stddev_pop(val HUGEINT) returns 
DOUBLE\n"
" external name \"aggr\".\"stdevp\";\n"
"GRANT EXECUTE ON AGGREGATE stddev_pop(HUGEINT) TO 
PUBLIC;\n"
+   "create window stddev_pop(val HUGEINT) returns DOUBLE\n"
+   " external name \"sql\".\"stdevp\";\n"
+   "GRANT EXECUTE ON WINDOW stddev_pop(HUGEINT) TO 
PUBLIC;\n"
"create aggregate var_samp(val HUGEINT) returns 
DOUBLE\n"
" external name \"aggr\".\"variance\";\n"
"GRANT EXECUTE ON AGGREGATE var_samp(HUGEINT) TO 
PUBLIC;\n"
+   "create window var_samp(val HUGEINT) returns DOUBLE\n"
+   " external name \"sql\".\"variance\";\n"
+   "GRANT EXECUTE ON WINDOW var_samp(HUGEINT) TO PUBLIC;\n"
+   "create aggregate covar_samp(e1 HUGEINT, e2 HUGEINT) 
returns DOUBLE\n"
+   " external name \"aggr\".\"covariance\";\n"
+   "GRANT EXECUTE ON AGGREGATE covar_samp(HUGEINT, 
HUGEINT) TO PUBLIC;\n"
+   "create window covar_samp(e1 HUGEINT, e2 HUGEINT) 
returns DOUBLE\n"
+   " external name \"sql\".\"covariance\";\n"
+   "GRANT EXECUTE ON WINDOW covar_samp(HUGEINT, HUGEINT) 
TO PUBLIC;\n"
"create aggregate var_pop(val HUGEINT) returns DOUBLE\n"
" external name \"aggr\".\"variancep\";\n"
"GRANT EXECUTE ON AGGREGATE var_pop(HUGEINT) TO 
PUBLIC;\n"
+   "create window var_pop(val HUGEINT) returns DOUBLE\n"
+   " external name \"sql\".\"variancep\";\n"
+   "GRANT EXECUTE ON WINDOW var_pop(HUGEINT) TO PUBLIC;\n"
+   "create aggregate covar_pop(e1 HUGEINT, e2 HUGEINT) 
returns DOUBLE\n"
+   " external name \"aggr\".\"covariancep\";\n"
+   "GRANT EXECUTE ON AGGREGATE covar_pop(HUGEINT, HUGEINT) 
TO PUBLIC;\n"
+   "create window covar_pop(e1 HUGEINT, e2 HUGEINT) 
returns DOUBLE\n"
+   " external name \"sql\".\"covariancep\";\n"
+   "GRANT EXECUTE ON WINDOW covar_pop(HUGEINT, HUGEINT) TO 
PUBLIC;\n"
"create aggregate median(val HUGEINT) returns HUGEINT\n"
" external name \"aggr\".\"median\";\n"
"GRANT EXECUTE ON AGGREGATE median(HUGEINT) TO 
PUBLIC;\n"
@@ -236,7 +260,10 @@ sql_update_hugeint(Client c, mvc *sql, c
"GRANT EXECUTE ON AGGREGATE quantile_avg(HUGEINT, 
DOUBLE) TO PUBLIC;\n"
"create aggregate corr(e1 HUGEINT, e2 HUGEINT) returns 
DOUBLE\n"
" external name \"aggr\".\"corr\";\n"
-   "GRANT EXECUTE ON AGGREGATE corr(HUGEINT, HUGEINT) TO 
PUBLIC;\n");
+   "GRANT EXECUTE ON AGGREGATE corr(HUGEINT, HUGEINT) TO 
PUBLIC;\n"
+   "create window corr(e1 HUGEINT, e2 HUGEINT) returns 
DOUBLE\n"
+   " external name \"sql\".\"corr\";\n"
+   "GRANT EXECUTE ON WINDOW corr(HUGEINT, HUGEINT) TO 
PUBLIC;\n");
 
/* 40_json_hge.sql */
pos += snprintf(buf + pos, bufsize - pos,
@@ -247,9 +274,10 @@ sql_update_hugeint(Client c, mvc *sql, c
pos += snprintf(buf + pos, bufsize - pos,
 

MonetDB: Jun2020 - New crash with respective fix, ie when attemp...

2020-06-05 Thread Pedro Ferreira
Changeset: 208acf96d69b for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=208acf96d69b
Modified Files:
sql/server/rel_select.c
sql/test/subquery/Tests/subquery6.sql
sql/test/subquery/Tests/subquery6.stable.out
Branch: Jun2020
Log Message:

New crash with respective fix, ie when attempting to push early on a filter 
expression, test if freevars are available on either side of the filter 
expression


diffs (47 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
@@ -1649,7 +1649,7 @@ rel_filter(mvc *sql, sql_rel *rel, list 
else
return sql_error(sql, ERR_GROUPBY, SQLSTATE(42000) 
"SELECT: cannot use non GROUP BY column in query results without an aggregate 
function");
}
-   if (exps_card(r) <= CARD_ATOM && exps_are_atoms(r)) {
+   if (exps_card(r) <= CARD_ATOM && (exps_are_atoms(r) || 
exps_have_freevar(sql, r) || exps_have_freevar(sql, l))) {
if (exps_card(l) == exps_card(r) || rel->processed)  /* bin 
compare op */
return rel_select(sql->sa, rel, e);
 
diff --git a/sql/test/subquery/Tests/subquery6.sql 
b/sql/test/subquery/Tests/subquery6.sql
--- a/sql/test/subquery/Tests/subquery6.sql
+++ b/sql/test/subquery/Tests/subquery6.sql
@@ -81,6 +81,12 @@ SELECT CAST((SELECT SUM((SELECT col1))) 
 SELECT CAST((SELECT SUM((SELECT col1 + col2))) AS BIGINT) FROM another_t;
-- 3702
 
+SELECT (SELECT 1 FROM another_t t1 WHERE 'aa' LIKE t2.product_category) FROM 
tbl_ProductSales t2;
+   -- NULL
+   -- NULL
+   -- NULL
+   -- NULL
+
 DROP TABLE tbl_ProductSales;
 DROP TABLE another_T;
 DROP TABLE integers;
diff --git a/sql/test/subquery/Tests/subquery6.stable.out 
b/sql/test/subquery/Tests/subquery6.stable.out
--- a/sql/test/subquery/Tests/subquery6.stable.out
+++ b/sql/test/subquery/Tests/subquery6.stable.out
@@ -98,6 +98,15 @@ stdout of test 'subquery6` in directory 
 % bigint # type
 % 4 # length
 [ 3702 ]
+#SELECT (SELECT 1 FROM another_t t1 WHERE 'aa' LIKE t2.product_category) FROM 
tbl_ProductSales t2;
+% .%1 # table_name
+% %1 # name
+% tinyint # type
+% 1 # length
+[ NULL ]
+[ NULL ]
+[ NULL ]
+[ NULL ]
 #DROP TABLE tbl_ProductSales;
 #DROP TABLE another_T;
 #DROP TABLE integers;
___
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list


MonetDB: Jun2020 - Add test conditional HAVE_PYTHON_LZ4.

2020-06-05 Thread Sjoerd Mullender
Changeset: 3ac212b87628 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=3ac212b87628
Modified Files:
testing/Mtest.py.in
Branch: Jun2020
Log Message:

Add test conditional HAVE_PYTHON_LZ4.


diffs (24 lines):

diff --git a/testing/Mtest.py.in b/testing/Mtest.py.in
--- a/testing/Mtest.py.in
+++ b/testing/Mtest.py.in
@@ -398,6 +398,7 @@ CONDITIONALS = {
 'HAVE_PHP' : "",
 'HAVE_PYMONETDB'   : "", # default PYTHON can import pymonetdb
 'HAVE_PY3MONETDB'  : "", # PYTHON3 exists and can import pymonetdb
+'HAVE_PYTHON_LZ4'  : "", # module lz4 is available
 'HAVE_RUBY': "",
 'HAVE_DATA_PATH'   : "",
 'MERCURIAL': "",
@@ -3880,6 +3881,12 @@ def main(argv) :
 print('Python available, but pymonetdb package not available')
 else:
 CONDITIONALS['HAVE_PYMONETDB'] = '#'
+try:
+import lz4
+except ImportError:
+CONDITIONALS['HAVE_PYTHON_LZ4'] = False
+else:
+CONDITIONALS['HAVE_PYTHON_LZ4'] = True
 if 'PYTHON3' in os.environ:
 proc = process.Popen([os.environ['PYTHON3'], '-c', 'import scipy'],
  stdout=process.PIPE, stderr=process.PIPE,
___
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list


MonetDB: mbedded - merged

2020-06-05 Thread Niels Nes
Changeset: 49faaf14e163 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=49faaf14e163
Added Files:
sql/test/Tests/hot_snapshot.py
sql/test/Tests/hot_snapshot.stable.err
sql/test/Tests/hot_snapshot.stable.out
sql/test/Tests/hot_snapshot_bz2.py
sql/test/Tests/hot_snapshot_bz2.stable.err
sql/test/Tests/hot_snapshot_bz2.stable.out
sql/test/Tests/hot_snapshot_gz.py
sql/test/Tests/hot_snapshot_gz.stable.err
sql/test/Tests/hot_snapshot_gz.stable.out
sql/test/Tests/hot_snapshot_lz4.py
sql/test/Tests/hot_snapshot_lz4.stable.err
sql/test/Tests/hot_snapshot_lz4.stable.out
sql/test/Tests/hot_snapshot_xz.py
sql/test/Tests/hot_snapshot_xz.stable.err
sql/test/Tests/hot_snapshot_xz.stable.out
Removed Files:
sql/test/Tests/hot-snapshot-bz2.py
sql/test/Tests/hot-snapshot-bz2.stable.err
sql/test/Tests/hot-snapshot-bz2.stable.out
sql/test/Tests/hot-snapshot-gz.py
sql/test/Tests/hot-snapshot-gz.stable.err
sql/test/Tests/hot-snapshot-gz.stable.out
sql/test/Tests/hot-snapshot-lz4.py
sql/test/Tests/hot-snapshot-lz4.stable.err
sql/test/Tests/hot-snapshot-lz4.stable.out
sql/test/Tests/hot-snapshot-xz.py
sql/test/Tests/hot-snapshot-xz.stable.err
sql/test/Tests/hot-snapshot-xz.stable.out
sql/test/Tests/hot-snapshot.py
sql/test/Tests/hot-snapshot.stable.err
sql/test/Tests/hot-snapshot.stable.out
sql/test/Tests/hot_snapshot_compression.py
Modified Files:
clients/Tests/exports.stable.out
common/stream/stream.c
monetdb5/modules/mal/pcre.c
sql/backends/monet5/sql_subquery.c
sql/server/rel_optimizer.c
sql/server/rel_select.c
sql/server/rel_unnest.c
sql/server/rel_unnest.h
sql/server/sql_query.c
sql/server/sql_query.h
sql/storage/bat/bat_logger.c
sql/storage/store.c
sql/test/BugTracker-2011/Tests/crash_on_alias.Bug-2798.stable.out
sql/test/BugTracker-2011/Tests/crash_on_alias.Bug-2798.stable.out.int128
sql/test/BugTracker-2013/Tests/syntaxerror.Bug-3399.stable.out
sql/test/Tests/All
sql/test/bugs/Tests/select_select_bug.stable.out
sql/test/subquery/Tests/correlated.stable.out
sql/test/subquery/Tests/subquery.stable.out
sql/test/subquery/Tests/subquery3.stable.err
sql/test/subquery/Tests/subquery3.stable.out
sql/test/subquery/Tests/subquery4.stable.out
sql/test/subquery/Tests/subquery5.stable.out
sql/test/subquery/Tests/subquery6.sql
sql/test/subquery/Tests/subquery6.stable.err
sql/test/subquery/Tests/subquery6.stable.out
Branch: mbedded
Log Message:

merged


diffs (truncated from 1972 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
@@ -1690,8 +1690,8 @@ str MTIMEtimestamp_decade(int *ret, cons
 str MTIMEtimestamp_decade_bulk(bat *ret, const bat *bid);
 str MTIMEtimestamp_diff_msec(lng *ret, const timestamp *v1, const timestamp 
*v2);
 str MTIMEtimestamp_diff_msec_bulk(bat *ret, const bat *bid1, const bat *bid2);
-str MTIMEtimestamp_diff_msec_bulk_p1(bat *ret, const timestamp *src1, const 
bat *bid2);
-str MTIMEtimestamp_diff_msec_bulk_p2(bat *ret, const bat *bid1, const 
timestamp *src2);
+str MTIMEtimestamp_diff_msec_bulk_p1(bat *ret, const timestamp *restrict src1, 
const bat *bid2);
+str MTIMEtimestamp_diff_msec_bulk_p2(bat *ret, const bat *bid1, const 
timestamp *restrict src2);
 str MTIMEtimestamp_extract_date(date *ret, const timestamp *src);
 str MTIMEtimestamp_extract_date_bulk(bat *ret, const bat *bid);
 str MTIMEtimestamp_extract_daytime(daytime *ret, const timestamp *src);
diff --git a/common/stream/stream.c b/common/stream/stream.c
--- a/common/stream/stream.c
+++ b/common/stream/stream.c
@@ -1826,8 +1826,15 @@ stream_lz4close(stream *s)
lz4_stream *lz4 = s->stream_data.p;
 
if (lz4) {
-   stream_lz4flush(s);
if(!s->readonly) {
+   char final_bytes[128]; // 4 would probably suffice
+   stream_lz4flush(s);
+   size_t remainder = 
LZ4F_compressEnd(lz4->context.comp_context, final_bytes, sizeof(final_bytes), 
NULL);
+   // no channel to return an error from here :(
+   if (!LZ4F_isError(remainder)) {
+   // again, hope for the best
+   (void) fwrite(final_bytes, 1, remainder, 
lz4->fp);
+   }
(void) 
LZ4F_freeCompressionContext(lz4->context.comp_context);
} else {
(void) 
LZ4F_freeDecompressionContext(lz4->context.dec_context);
diff --git a/monetdb5/modules/m

MonetDB: default - Relax over-eager consistency check

2020-06-05 Thread Joeri van Ruth
Changeset: 7ef15bf9feb9 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=7ef15bf9feb9
Modified Files:
sql/storage/bat/bat_logger.c
Branch: default
Log Message:

Relax over-eager consistency check


diffs (28 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
@@ -1114,18 +1114,23 @@ snapshot_wal(stream *plan, const char *d
fclose(f);
return GDK_FAIL;
}
-   assert(version == 52204); // if version has changed this code may need 
to be revised
ret = fscanf(f, LLSCN, &start_id); // real read (log id))
if (ret != 1) {
GDKerror("Could not read log id from %s", meta_file);
fclose(f);
return GDK_FAIL;
}
+   // if there's more the file format must have changed
+   // and this code should be updated accordingly:
+   assert((fscanf(f, " "), feof(f))); // sanity check
fclose(f);
 
// Determining the current log file is easy
cur_id = bat_logger->id;
 
+   assert(start_id >= 1);
+   assert(start_id <= cur_id);
+
for (lng i = start_id; i <= cur_id; i++) {
len = snprintf(log_file, sizeof(log_file),
   "%s/%s%s." LLFMT, db_dir, bat_logger->dir, 
LOGFILE, i);
___
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list


MonetDB: Jun2020 - Throw better error messages

2020-06-05 Thread Pedro Ferreira
Changeset: b8fbe11da875 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=b8fbe11da875
Modified Files:
monetdb5/modules/mal/pcre.c
sql/test/miscellaneous/Tests/simple_selects.sql
sql/test/miscellaneous/Tests/simple_selects.stable.err
Branch: Jun2020
Log Message:

Throw better error messages


diffs (46 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
@@ -1449,8 +1449,8 @@ sql2pcre(str *r, const char *pat, const 
 
if (strlen(esc_str) > 1)
throw(MAL, "pcre.sql2pcre", SQLSTATE(22019) ILLEGAL_ARGUMENT ": 
ESCAPE string must have length 1");
-   if (pat == NULL )
-   throw(MAL, "pcre.sql2pcre", OPERATION_FAILED);
+   if (pat == NULL)
+   throw(MAL, "pcre.sql2pcre", SQLSTATE(22019) ILLEGAL_ARGUMENT ": 
(I)LIKE pattern must not be NULL");
ppat = GDKmalloc(strlen(pat)*3+3 /* 3 = "^'the translated regexp'$0" 
*/);
if (ppat == NULL)
throw(MAL, "pcre.sql2pcre", SQLSTATE(HY013) MAL_MALLOC_FAIL);
@@ -1511,7 +1511,7 @@ sql2pcre(str *r, const char *pat, const 
GDKfree(*r);
*r = NULL;
if (escaped)
-   throw(MAL, "pcre.sql2pcre", OPERATION_FAILED);
+   throw(MAL, "pcre.sql2pcre", SQLSTATE(22019) 
ILLEGAL_ARGUMENT ": (I)LIKE pattern must not end with escape character");
*r = GDKstrdup(str_nil);
if (*r == NULL)
throw(MAL, "pcre.sql2pcre", SQLSTATE(HY013) 
MAL_MALLOC_FAIL);
diff --git a/sql/test/miscellaneous/Tests/simple_selects.sql 
b/sql/test/miscellaneous/Tests/simple_selects.sql
--- a/sql/test/miscellaneous/Tests/simple_selects.sql
+++ b/sql/test/miscellaneous/Tests/simple_selects.sql
@@ -154,3 +154,5 @@ set current_schema = null; --error, defa
 
 select greatest(null, null);
 select sql_min(null, null);
+
+select 'a' like 'a' escape 'a'; --error, like sequence ending with escape 
character 
diff --git a/sql/test/miscellaneous/Tests/simple_selects.stable.err 
b/sql/test/miscellaneous/Tests/simple_selects.stable.err
--- a/sql/test/miscellaneous/Tests/simple_selects.stable.err
+++ b/sql/test/miscellaneous/Tests/simple_selects.stable.err
@@ -189,6 +189,10 @@ MAPI  = (monetdb) /var/tmp/mtest-440671/
 QUERY = set current_schema = null; --error, default global variables cannot be 
null
 ERROR = !current_schema cannot be NULL
 CODE  = 42000
+MAPI  = (monetdb) /var/tmp/mtest-400226/.s.monetdb.31130
+QUERY = select 'a' like 'a' escape 'a'; --error, like sequence ending with 
escape character 
+ERROR = !Illegal argument: (I)LIKE pattern must not end with escape character
+CODE  = 22019
 
 # 17:31:38 >  
 # 17:31:38 >  "Done."
___
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list


MonetDB: default - Merged with Jun2020

2020-06-05 Thread Pedro Ferreira
Changeset: f27dfe585138 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=f27dfe585138
Added Files:
sql/test/Tests/hot_snapshot.py
sql/test/Tests/hot_snapshot.stable.err
sql/test/Tests/hot_snapshot.stable.out
sql/test/Tests/hot_snapshot_bz2.py
sql/test/Tests/hot_snapshot_bz2.stable.err
sql/test/Tests/hot_snapshot_bz2.stable.out
sql/test/Tests/hot_snapshot_gz.py
sql/test/Tests/hot_snapshot_gz.stable.err
sql/test/Tests/hot_snapshot_gz.stable.out
sql/test/Tests/hot_snapshot_lz4.py
sql/test/Tests/hot_snapshot_lz4.stable.err
sql/test/Tests/hot_snapshot_lz4.stable.out
sql/test/Tests/hot_snapshot_xz.py
sql/test/Tests/hot_snapshot_xz.stable.err
sql/test/Tests/hot_snapshot_xz.stable.out
Removed Files:
sql/test/Tests/hot-snapshot-bz2.py
sql/test/Tests/hot-snapshot-bz2.stable.err
sql/test/Tests/hot-snapshot-bz2.stable.out
sql/test/Tests/hot-snapshot-gz.py
sql/test/Tests/hot-snapshot-gz.stable.err
sql/test/Tests/hot-snapshot-gz.stable.out
sql/test/Tests/hot-snapshot-lz4.py
sql/test/Tests/hot-snapshot-lz4.stable.err
sql/test/Tests/hot-snapshot-lz4.stable.out
sql/test/Tests/hot-snapshot-xz.py
sql/test/Tests/hot-snapshot-xz.stable.err
sql/test/Tests/hot-snapshot-xz.stable.out
sql/test/Tests/hot-snapshot.py
sql/test/Tests/hot-snapshot.stable.err
sql/test/Tests/hot-snapshot.stable.out
sql/test/Tests/hot_snapshot_compression.py
Modified Files:
common/stream/stream.c
monetdb5/modules/mal/pcre.c
sql/backends/monet5/sql_subquery.c
sql/server/rel_optimizer.c
sql/server/rel_select.c
sql/server/rel_unnest.c
sql/server/rel_unnest.h
sql/server/sql_query.c
sql/server/sql_query.h
sql/storage/bat/bat_logger.c
sql/storage/store.c
sql/test/BugTracker-2011/Tests/crash_on_alias.Bug-2798.stable.out
sql/test/BugTracker-2011/Tests/crash_on_alias.Bug-2798.stable.out.int128
sql/test/BugTracker-2013/Tests/syntaxerror.Bug-3399.stable.out
sql/test/Tests/All
sql/test/bugs/Tests/select_select_bug.stable.out
sql/test/subquery/Tests/correlated.stable.out
sql/test/subquery/Tests/subquery.stable.out
sql/test/subquery/Tests/subquery3.stable.err
sql/test/subquery/Tests/subquery3.stable.out
sql/test/subquery/Tests/subquery4.stable.out
sql/test/subquery/Tests/subquery5.stable.out
sql/test/subquery/Tests/subquery6.sql
sql/test/subquery/Tests/subquery6.stable.err
sql/test/subquery/Tests/subquery6.stable.out
Branch: default
Log Message:

Merged with Jun2020


diffs (truncated from 1953 to 300 lines):

diff --git a/common/stream/stream.c b/common/stream/stream.c
--- a/common/stream/stream.c
+++ b/common/stream/stream.c
@@ -1824,8 +1824,15 @@ stream_lz4close(stream *s)
lz4_stream *lz4 = s->stream_data.p;
 
if (lz4) {
-   stream_lz4flush(s);
if(!s->readonly) {
+   char final_bytes[128]; // 4 would probably suffice
+   stream_lz4flush(s);
+   size_t remainder = 
LZ4F_compressEnd(lz4->context.comp_context, final_bytes, sizeof(final_bytes), 
NULL);
+   // no channel to return an error from here :(
+   if (!LZ4F_isError(remainder)) {
+   // again, hope for the best
+   (void) fwrite(final_bytes, 1, remainder, 
lz4->fp);
+   }
(void) 
LZ4F_freeCompressionContext(lz4->context.comp_context);
} else {
(void) 
LZ4F_freeDecompressionContext(lz4->context.dec_context);
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
@@ -233,7 +233,7 @@ myucslen(const uint32_t *ucs)
return i;
 }
 
-static int
+static inline int
 mywstrncasecmp(const char *restrict s1, const uint32_t *restrict s2, size_t n2)
 {
uint32_t c1;
@@ -261,7 +261,7 @@ mywstrncasecmp(const char *restrict s1, 
return 0;
 }
 
-static int
+static inline int
 mystrcasecmp(const char *s1, const char *s2)
 {
uint32_t c1, c2;
@@ -289,7 +289,7 @@ mystrcasecmp(const char *s1, const char 
}
 }
 
-static int
+static inline int
 mywstrcasecmp(const char *restrict s1, const uint32_t *restrict s2)
 {
uint32_t c1;
@@ -315,7 +315,7 @@ mywstrcasecmp(const char *restrict s1, c
}
 }
 
-static const char *
+static inline const char *
 mywstrcasestr(const char *restrict haystack, const uint32_t *restrict wneedle)
 {
size_t nlen = myucslen(wneedle);
@@ -394,7 +394,7 @@ is_strcmpable(const char *pat, const cha
return strlen(esc) == 0 || strNi

MonetDB: default - Approved output

2020-06-05 Thread Pedro Ferreira
Changeset: bb894e8dff74 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=bb894e8dff74
Modified Files:
clients/Tests/exports.stable.out
Branch: default
Log Message:

Approved output


diffs (14 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
@@ -1628,8 +1628,8 @@ str MTIMEtimestamp_decade(int *ret, cons
 str MTIMEtimestamp_decade_bulk(bat *ret, const bat *bid);
 str MTIMEtimestamp_diff_msec(lng *ret, const timestamp *v1, const timestamp 
*v2);
 str MTIMEtimestamp_diff_msec_bulk(bat *ret, const bat *bid1, const bat *bid2);
-str MTIMEtimestamp_diff_msec_bulk_p1(bat *ret, const timestamp *src1, const 
bat *bid2);
-str MTIMEtimestamp_diff_msec_bulk_p2(bat *ret, const bat *bid1, const 
timestamp *src2);
+str MTIMEtimestamp_diff_msec_bulk_p1(bat *ret, const timestamp *restrict src1, 
const bat *bid2);
+str MTIMEtimestamp_diff_msec_bulk_p2(bat *ret, const bat *bid1, const 
timestamp *restrict src2);
 str MTIMEtimestamp_extract_date(date *ret, const timestamp *src);
 str MTIMEtimestamp_extract_date_bulk(bat *ret, const bat *bid);
 str MTIMEtimestamp_extract_daytime(daytime *ret, const timestamp *src);
___
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list


MonetDB: Jun2020 - Extracted constants from loops and small cleanup

2020-06-05 Thread Pedro Ferreira
Changeset: 055a2b7e0694 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=055a2b7e0694
Modified Files:
monetdb5/modules/mal/pcre.c
Branch: Jun2020
Log Message:

Extracted constants from loops and small cleanup


diffs (215 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
@@ -852,13 +852,13 @@ re_likeselect(BAT **bnp, BAT *b, BAT *s,
 
 #define proj_scanloop(TEST)\
do {\
-   if (bn->tnonil) { \
-   BATloop (b, p, q) { \
+   if (b->tnonil) { \
+   for (BUN p = 0; p < q; p++) {   \
v = BUNtail(bi, p); \
res[p] = TEST; \
}   \
} else { \
-   BATloop (b, p, q) { \
+   for (BUN p = 0; p < q; p++) {   \
v = BUNtail(bi, p); \
if (*v == '\200') { \
res[p] = bit_nil; \
@@ -878,7 +878,7 @@ re_like_proj(BAT **bnp, BAT *b, const ch
const char *restrict v;
RE *re = NULL;
uint32_t *wpat = NULL;
-   BUN p, q;
+   BUN q = BATcount(b);
bit *restrict res;
str msg = MAL_SUCCEED;
 
@@ -1715,7 +1715,7 @@ PCRElike4(bit *ret, const str *s, const 
 
if (!r) {
assert(ppat);
-   if (strNil(*pat) || strNil(*s)) {
+   if (strNil(*pat) || strNil(*s) || strNil(*esc)) {
*ret = bit_nil;
} else if (strNil(ppat)) {
*ret = FALSE;
@@ -1847,11 +1847,48 @@ choose_like_path(char **ppat, bool *use_
return MAL_SUCCEED;
 }
 
+#define PCRE_LIKE_BODY(LOOP_BODY, RES1, RES2) \
+   do { \
+   if (b->tnonil) { \
+   for (BUN p = 0; p < q; p++) {   \
+   const char *restrict s = BUNtail(bi, p); \
+   LOOP_BODY  \
+   if (pos >= 0) \
+   res[p] = RES1; \
+   else if (pos == -1) \
+   res[p] = RES2; \
+   else { \
+   msg = createException(MAL, 
"pcre.match", OPERATION_FAILED ": matching of regular expression (%s) failed 
with %d", ppat, pos); \
+   goto bailout; \
+   } \
+   }   \
+   } else { \
+   for (BUN p = 0; p < q; p++) { \
+   const char *restrict s = BUNtail(bi, p); \
+   LOOP_BODY  \
+   if (*s == '\200') { \
+   res[p] = bit_nil; \
+   bn->tnonil = false; \
+   bn->tnil = true; \
+   } else { \
+   if (pos >= 0) \
+   res[p] = RES1; \
+   else if (pos == -1) \
+   res[p] = RES2; \
+   else { \
+   msg = createException(MAL, 
"pcre.match", OPERATION_FAILED ": matching of regular expression (%s) failed 
with %d", ppat, pos); \
+   goto bailout; \
+   } \
+   } \
+   } \
+   } \
+   } while(0)
+
 static str
 pcre_like(BAT **bnp, BAT *b, const char *ppat, bool caseignore, bool anti)
 {
BATiter bi = bat_iterator(b);
-   BUN p, q;
+   BUN q = BATcount(b);
int pos;
BAT *bn;
bit *restrict res;
@@ -1899,31 +1936,19 @@ pcre_like(BAT **bnp, BAT *b, const char 
goto bailout;
}
 
-   BATloop(b, p, q) {
-   const char *restrict s = BUNtail(bi, p);
-
-   if (*s == '\200') {
-   res[p] = bit_nil;
-   bn->tnonil = false;
-   bn->tnil = true;
-   } else {
 #ifdef HAVE_LIBPCRE
-   pos = pcre_exec(re, NULL, s, (int) strlen(s), 0, 0, 
NULL, 0);
+#define LOOP_BODY  \
+   pos = pcre_exec(re, NULL, s, (int) strlen(s), 0, 0, NULL, 0);
 #else
-   int retval = regexec(&re, s, (size_t) 0, NULL, 0);
-   pos = retval == REG_NOMATCH ? -1 : (retval == 
REG_ENOSYS ? -2 : 0);
+#define LOOP_BODY  \
+   int retval = regexec(&re, s, (size_t) 0, NULL, 0); \
+   pos = retval == REG_NOMATCH ? -1 : (retval == REG_ENOSYS ? -2