Changeset: 474d14eca916 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=474d14eca916 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/backends/monet5/sql_upgrades.c sql/server/rel_optimizer.c sql/server/rel_select.c sql/server/rel_unnest.c sql/server/rel_unnest.h sql/server/sql_env.c 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/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/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 sql/test/sys-schema/Tests/systemfunctions.stable.out sql/test/sys-schema/Tests/systemfunctions.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 testing/Mtest.py.in Branch: default Log Message:
Merge heads. diffs (truncated from 3675 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 @@ -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); 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 || strNil(esc) || strstr(pat, esc) == NULL; } -static bool +static inline bool re_match_ignore(const char *s, RE *pattern) { RE *r; @@ -410,7 +410,7 @@ re_match_ignore(const char *s, RE *patte return true; } -static bool +static inline bool re_match_no_ignore(const char *s, RE *pattern) { RE *r; @@ -725,8 +725,11 @@ re_likeselect(BAT **bnp, BAT *b, BAT *s, if (!use_strcmp) { re = re_create(pat, caseignore, esc); - if (!re) + if (!re) { + BBPreclaim(bn); + *bnp = NULL; throw(MAL, "pcre.likeselect", SQLSTATE(HY013) MAL_MALLOC_FAIL); + } } if (s && !BATtdense(s)) { struct canditer ci; @@ -737,8 +740,11 @@ re_likeselect(BAT **bnp, BAT *b, BAT *s, if (use_strcmp) { if (caseignore) { wpat = utf8stoucs(pat); - if (wpat == NULL) + if (wpat == NULL) { + BBPreclaim(bn); + *bnp = NULL; throw(MAL, "pcre.likeselect", SQLSTATE(HY013) MAL_MALLOC_FAIL); + } if (anti) candscanloop(v && *v != '\200' && mywstrcasecmp(v, wpat) != 0); @@ -788,8 +794,11 @@ re_likeselect(BAT **bnp, BAT *b, BAT *s, if (use_strcmp) { if (caseignore) { wpat = utf8stoucs(pat); - if (wpat == NULL) + if (wpat == NULL) { + BBPreclaim(bn); + *bnp = NULL; throw(MAL, "pcre.likeselect", SQLSTATE(HY013) MAL_MALLOC_FAIL); + } if (anti) scanloop(v && *v != '\200' && mywstrcasecmp(v, wpat) != 0); @@ -841,6 +850,103 @@ re_likeselect(BAT **bnp, BAT *b, BAT *s, throw(MAL, "pcre.likeselect", OPERATION_FAILED); } +#define proj_scanloop(TEST) \ + do { \ + if (b->tnonil) { \ + for (BUN p = 0; p < q; p++) { \ + v = BUNtail(bi, p); \ + res[p] = TEST; \ + } \ + } else { \ + for (BUN p = 0; p < q; p++) { \ + v = BUNtail(bi, p); \ + if (*v == '\200') { \ + res[p] = bit_nil; \ + bn->tnonil = false; \ + bn->tnil = true; \ + } else \ + res[p] = TEST; \ + } \ + } \ + } while (0) + +static str +re_like_proj(BAT **bnp, BAT *b, const char *pat, bool caseignore, bool anti, bool use_strcmp, uint32_t esc) +{ + BATiter bi = bat_iterator(b); + BAT *bn; + const char *restrict v; + RE *re = NULL; + uint32_t *wpat = NULL; + BUN q = BATcount(b); + bit *restrict res; + str msg = MAL_SUCCEED; + + assert(ATOMstorage(b->ttype) == TYPE_str); + + bn = COLnew(0, TYPE_bit, BATcount(b), TRANSIENT); + if (bn == NULL) { + msg = createException(MAL, "pcre.likeselect", SQLSTATE(HY013) MAL_MALLOC_FAIL); + goto bailout; + } + res = (bit*) Tloc(bn, 0); + + if (!use_strcmp) { + re = re_create(pat, caseignore, esc); + if (!re) { + msg = createException(MAL, "pcre.likeselect", SQLSTATE(HY013) MAL_MALLOC_FAIL); + goto bailout; + } + } + + if (use_strcmp) { + if (caseignore) { + wpat = utf8stoucs(pat); + if (wpat == NULL) { + msg = createException(MAL, "pcre.likeselect", SQLSTATE(HY013) MAL_MALLOC_FAIL); + goto bailout; + } + if (anti) + proj_scanloop(mywstrcasecmp(v, wpat) != 0); + else + proj_scanloop(mywstrcasecmp(v, wpat) == 0); + } else { + if (anti) + proj_scanloop(strcmp(v, pat) != 0); + else + proj_scanloop(strcmp(v, pat) == 0); + } + } else { + if (caseignore) { + if (anti) + proj_scanloop(re_match_ignore(v, re) == 0); + else + proj_scanloop(re_match_ignore(v, re)); + } else { + if (anti) + proj_scanloop(re_match_no_ignore(v, re) == 0); + else + proj_scanloop(re_match_no_ignore(v, re)); + } + } + +bailout: + if (bn) { + if (msg) { + BBPreclaim(bn); + } else { + BATsetcount(bn, BATcount(b)); + bn->tsorted = false; + bn->trevsorted = false; + *bnp = bn; + } + } + if (re) + re_destroy(re); + GDKfree(wpat); + return msg; +} + /* maximum number of back references and quoted \ or $ in replacement string */ #define MAX_NR_REFS 20 @@ -1343,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); @@ -1405,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); @@ -1609,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; @@ -1709,138 +1815,238 @@ PCREnotilike2(bit *ret, const str *s, co return MAL_SUCCEED; } +/* try if a simple list of keywords works */ +static str +choose_like_path(char **ppat, bool *use_re, bool *use_strcmp, bool *empty, const str *pat, const str *esc, const bit *caseignore) +{ + *use_re = false; + *use_strcmp = false; + *empty = false; + + if (strNil(*pat) || strNil(*esc)) { + *empty = true; + } else if (is_strcmpable(*pat, *esc)) { + *use_re = true; + *use_strcmp = true; + } else if (re_simple(*pat, (unsigned char) **esc)) { + *use_re = true; + } else { + str res = sql2pcre(ppat, *pat, *esc); + if (res != MAL_SUCCEED) + return res; + if (strNil(*ppat)) { + GDKfree(*ppat); + *ppat = NULL; + if (*caseignore) { + if (!(*ppat = GDKmalloc(strlen(*pat) + 3))) + throw(MAL, "algebra.likeselect", SQLSTATE(HY013) MAL_MALLOC_FAIL); + stpcpy(stpcpy(stpcpy(*ppat, "^"), *pat), "$"); + } + } + } + return MAL_SUCCEED; +} + +#define PCRE_LIKE_BODY(LOOP_BODY, RES1, RES2) \ _______________________________________________ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list