Changeset: 0a414832df80 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=0a414832df80
Added Files:
        sql/test/BugTracker-2017/Tests/crash_in_null_cast.Bug-6186.sql
        sql/test/BugTracker-2017/Tests/crash_in_null_cast.Bug-6186.stable.err
        sql/test/BugTracker-2017/Tests/crash_in_null_cast.Bug-6186.stable.out
        sql/test/BugTracker-2017/Tests/oidx-on-strings.Bug-6202.sql
        sql/test/BugTracker-2017/Tests/oidx-on-strings.Bug-6202.stable.err
        sql/test/BugTracker-2017/Tests/oidx-on-strings.Bug-6202.stable.out
Modified Files:
        monetdb5/mal/Makefile.ag
        monetdb5/modules/atoms/str.c
        monetdb5/modules/mal/orderidx.c
        monetdb5/modules/mal/pcre.c
        sql/backends/monet5/sql.c
        sql/backends/monet5/sql_cat.c
        sql/server/rel_optimizer.c
        sql/test/BugTracker-2017/Tests/All
Branch: wlcr
Log Message:

merge with default


diffs (truncated from 512 to 300 lines):

diff --git a/monetdb5/mal/Makefile.ag b/monetdb5/mal/Makefile.ag
--- a/monetdb5/mal/Makefile.ag
+++ b/monetdb5/mal/Makefile.ag
@@ -54,10 +54,18 @@ headers_h = {
        HEADERS = h
        SOURCES = \
                mal.h \
+               mal_client.h \
                mal_errors.h \
                mal_exception.h \
+               mal_factory.h \
+               mal_function.h \
                mal_instruction.h \
+               mal_interpreter.h \
+               mal_listing.h \
+               mal_module.h \
                mal_namespace.h \
+               mal_profiler.h \
+               mal_resolve.h \
                mal_stack.h \
                mal_type.h
 }
diff --git a/monetdb5/modules/atoms/str.c b/monetdb5/modules/atoms/str.c
--- a/monetdb5/modules/atoms/str.c
+++ b/monetdb5/modules/atoms/str.c
@@ -1831,8 +1831,8 @@ STRReverseStrSearch(int *res, const str 
 str
 STRsplitpart(str *res, str *haystack, str *needle, int *field)
 {
-       size_t slen;
-       int len, f = *field;
+       size_t len;
+       int f = *field;
        char *p;
        const char *s = *haystack;
        const char *s2 = *needle;
@@ -1848,10 +1848,10 @@ STRsplitpart(str *res, str *haystack, st
                throw(MAL, "str.splitpart", "field position must be greater 
than zero");
        }
 
-       slen = strlen(s2);
+       len = strlen(s2);
 
        while ((p = strstr(s, s2)) != 0 && f > 1) {
-               s = p + slen;
+               s = p + len;
                f--;
        }
 
@@ -1861,16 +1861,16 @@ STRsplitpart(str *res, str *haystack, st
                        throw(MAL, "str.splitpart", MAL_MALLOC_FAIL);
                return MAL_SUCCEED;
        }
-   
+
        if (p == 0) {
                len = strlen(s);
        } else if ((p = strstr(s, s2)) != 0) {
-               len = (int) (p - s);
+               len = (size_t) (p - s);
        } else {
                len = strlen(s);
        }
 
-       if (len == int_nil || len == 0) {
+       if (len == 0) {
                *res = GDKstrdup("");
                if (*res == NULL)
                        throw(MAL, "str.splitpart", MAL_MALLOC_FAIL);
diff --git a/monetdb5/modules/mal/orderidx.c b/monetdb5/modules/mal/orderidx.c
--- a/monetdb5/modules/mal/orderidx.c
+++ b/monetdb5/modules/mal/orderidx.c
@@ -47,6 +47,25 @@ OIDXcreateImplementation(Client cntxt, i
        if (b->torderidx)
                return MAL_SUCCEED;
 
+       switch (ATOMbasetype(b->ttype)) {
+       case TYPE_bte:
+       case TYPE_sht:
+       case TYPE_int:
+       case TYPE_lng:
+#ifdef HAVE_HGE
+       case TYPE_hge:
+#endif
+       case TYPE_flt:
+       case TYPE_dbl:
+               break;
+       case TYPE_str:
+               /* TODO: support strings etc. */
+       case TYPE_void:
+       case TYPE_ptr:
+       default:
+               throw(MAL, "bat.orderidx", TYPE_NOT_SUPPORTED);
+       }
+
        if( pieces < 0 ){
                if (GDKnr_threads <= 1) {
                        pieces = 1;
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
@@ -319,7 +319,7 @@ static str
 pcre_likeselect(BAT **bnp, BAT *b, BAT *s, const char *pat, int caseignore, 
int anti)
 {
 #ifdef HAVE_LIBPCRE
-       int options = PCRE_UTF8 | PCRE_MULTILINE;
+       int options = PCRE_UTF8 | PCRE_MULTILINE | PCRE_DOTALL;
        pcre *re;
        pcre_extra *pe;
        const char *error;
@@ -928,8 +928,14 @@ pcre_match_with_flags(bit *ret, const ch
        return MAL_SUCCEED;
 }
 
+#ifdef HAVE_LIBPCRE
 /* special characters in PCRE that need to be escaped */
 static const char *pcre_specials = ".+?*()[]{}|^$\\";
+#else
+/* special characters in POSIX basic regular expressions that need to
+ * be escaped */
+static const char *pcre_specials = ".*[]^$\\";
+#endif
 
 /* change SQL LIKE pattern into PCRE pattern */
 static str
@@ -1068,7 +1074,7 @@ PCREreplace_bat_wrap(bat *res, const bat
 str
 PCREmatch(bit *ret, const str *val, const str *pat)
 {
-       char *flags = "";
+       char *flags = "s";
        return pcre_match_with_flags(ret, *val, *pat, flags);
 }
 
@@ -1294,7 +1300,7 @@ BATPCRElike3(bat *ret, const bat *bid, c
 #ifdef HAVE_LIBPCRE
                        const char err[BUFSIZ], *err_p = err;
                        int errpos = 0;
-                       int options = PCRE_UTF8;
+                       int options = PCRE_UTF8 | PCRE_DOTALL;
                        pcre *re;
 #else
                        pcre re;
diff --git a/sql/backends/monet5/sql_cat.c b/sql/backends/monet5/sql_cat.c
--- a/sql/backends/monet5/sql_cat.c
+++ b/sql/backends/monet5/sql_cat.c
@@ -642,8 +642,13 @@ alter_table(Client cntxt, mvc *sql, char
                        if (i->type == ordered_idx) {
                                sql_kc *ic = i->columns->h->data;
                                BAT *b = mvc_bind(sql, nt->s->base.name, 
nt->base.name, ic->c->base.name, 0);
-                               OIDXcreateImplementation(cntxt, 
newBatType(b->ttype), b, -1);
+                               char *msg = OIDXcreateImplementation(cntxt, 
newBatType(b->ttype), b, -1);
                                BBPunfix(b->batCacheid);
+                               if (msg != MAL_SUCCEED) {
+                                       char *smsg = sql_message("40002!CREATE 
ORDERED INDEX: %s", msg);
+                                       freeException(msg);
+                                       return smsg;
+                               }
                        }
                        if (i->type == imprints_idx) {
                                sql_kc *ic = i->columns->h->data;
diff --git a/sql/test/BugTracker-2017/Tests/All 
b/sql/test/BugTracker-2017/Tests/All
--- a/sql/test/BugTracker-2017/Tests/All
+++ b/sql/test/BugTracker-2017/Tests/All
@@ -4,6 +4,7 @@ semijoinunion.Bug-6150
 HAVE_LIBZ?heapextend.Bug-6134
 incorrect_error.Bug-6141
 empty-interval.Bug-6184
+crash_in_null_cast.Bug-6186
 drop_not_null_on_pkey.Bug-6189
 too-large-decimals.Bug-6192
 round-or-truncate.Bug-6193
@@ -11,3 +12,4 @@ splitpart.Bug-6194
 HAVE_HGE?cast-with-many-decimals.Bug-6195
 union_func_crash.Bug-6196
 complicated_logic.Bug-105
+oidx-on-strings.Bug-6202
diff --git a/sql/test/BugTracker-2017/Tests/crash_in_null_cast.Bug-6186.sql 
b/sql/test/BugTracker-2017/Tests/crash_in_null_cast.Bug-6186.sql
new file mode 100644
--- /dev/null
+++ b/sql/test/BugTracker-2017/Tests/crash_in_null_cast.Bug-6186.sql
@@ -0,0 +1,48 @@
+CREATE TABLE "sys"."unitTestDontDelete" (
+       "A" VARCHAR(255),
+       "B" BIGINT,
+       "C" DOUBLE,
+       "D" TIMESTAMP
+);
+COPY 10 RECORDS INTO "sys"."unitTestDontDelete" FROM stdin USING DELIMITERS 
'\t','\n','"';
+NULL   NULL    NULL    NULL
+"Cat1" 0       0.5     2013-06-10 11:10:10.000000
+"Cat2" 1       1.5     2013-06-11 12:11:11.000000
+"Cat1" 2       2.5     2013-06-12 13:12:12.000000
+"Cat2" 3       3.5     2013-06-13 14:13:13.000000
+"Cat1" 4       4.5     2013-06-14 15:14:14.000000
+"Cat2" 5       5.5     2013-06-15 16:15:15.000000
+"Cat1" 6       6.5     2013-06-16 17:16:16.000000
+"Cat2" 7       7.5     2013-06-17 18:17:17.000000
+"Cat1" 8       8.5     2013-06-18 19:18:18.000000
+
+
+CREATE TABLE "sys"."test_join_left_table" (
+       "a"   VARCHAR(255),
+       "b"   VARCHAR(255),
+       "l_c" VARCHAR(255)
+);
+COPY 4 RECORDS INTO "sys"."test_join_left_table" FROM stdin USING DELIMITERS 
'\t','\n','"';
+"a1"   "b1"    "c1"
+"a2"   "b2"    "c2"
+"a3"   "b3"    "c3"
+"a4"   "b4"    NULL
+
+
+
+select * from "test_join_left_table" as "ta" where not exists 
+       (select 1 as "one" from 
+               (select "t2"."A", "t2"."B", "t2"."C", "t2"."D", "t2"."l_c" from 
+               (
+                       (select "t0"."A" as "A", cast("B" as  CLOB) as "B", 
"t0"."C" as "C", "t0"."D" as "D", null as "l_c" from "unitTestDontDelete" as 
"t0")
+               union all 
+                       (select "t1"."a" as "A", "t1"."b" as "B", cast(null as 
double) as "C", cast(null as timestamp) as "D", "t1"."l_c" as "l_c" from 
"test_join_left_table" as "t1")
+               ) as "t2") as "tb" 
+       where ("ta"."l_c" = "tb"."l_c" or ("ta"."l_c" is null and "tb"."l_c" is 
null)));
+
+drop table test_join_left_table;
+drop table "unitTestDontDelete";
+
+
+
+       
diff --git 
a/sql/test/BugTracker-2017/Tests/crash_in_null_cast.Bug-6186.stable.err 
b/sql/test/BugTracker-2017/Tests/crash_in_null_cast.Bug-6186.stable.err
new file mode 100644
--- /dev/null
+++ b/sql/test/BugTracker-2017/Tests/crash_in_null_cast.Bug-6186.stable.err
@@ -0,0 +1,34 @@
+stderr of test 'crash_in_null_cast.Bug-6186` in directory 
'sql/test/BugTracker-2017` itself:
+
+
+# 21:51:16 >  
+# 21:51:16 >  "mserver5" "--debug=10" "--set" "gdk_nr_threads=0" "--set" 
"mapi_open=true" "--set" "mapi_port=33190" "--set" 
"mapi_usock=/var/tmp/mtest-28204/.s.monetdb.33190" "--set" "monet_prompt=" 
"--forcemito" 
"--dbpath=/home/niels/scratch/rc-clean/Linux-x86_64/var/MonetDB/mTests_sql_test_BugTracker-2017"
+# 21:51:16 >  
+
+# builtin opt  gdk_dbpath = 
/home/niels/scratch/rc-clean/Linux-x86_64/var/monetdb5/dbfarm/demo
+# builtin opt  gdk_debug = 0
+# builtin opt  gdk_vmtrim = no
+# builtin opt  monet_prompt = >
+# builtin opt  monet_daemon = no
+# builtin opt  mapi_port = 50000
+# builtin opt  mapi_open = false
+# builtin opt  mapi_autosense = false
+# builtin opt  sql_optimizer = default_pipe
+# builtin opt  sql_debug = 0
+# cmdline opt  gdk_nr_threads = 0
+# cmdline opt  mapi_open = true
+# cmdline opt  mapi_port = 33190
+# cmdline opt  mapi_usock = /var/tmp/mtest-28204/.s.monetdb.33190
+# cmdline opt  monet_prompt = 
+# cmdline opt  gdk_dbpath = 
/home/niels/scratch/rc-clean/Linux-x86_64/var/MonetDB/mTests_sql_test_BugTracker-2017
+# cmdline opt  gdk_debug = 536870922
+
+# 21:51:16 >  
+# 21:51:16 >  "mclient" "-lsql" "-ftest" "-Eutf-8" "-i" "-e" 
"--host=/var/tmp/mtest-28204" "--port=33190"
+# 21:51:16 >  
+
+
+# 21:51:16 >  
+# 21:51:16 >  "Done."
+# 21:51:16 >  
+
diff --git 
a/sql/test/BugTracker-2017/Tests/crash_in_null_cast.Bug-6186.stable.out 
b/sql/test/BugTracker-2017/Tests/crash_in_null_cast.Bug-6186.stable.out
new file mode 100644
--- /dev/null
+++ b/sql/test/BugTracker-2017/Tests/crash_in_null_cast.Bug-6186.stable.out
@@ -0,0 +1,75 @@
+stdout of test 'crash_in_null_cast.Bug-6186` in directory 
'sql/test/BugTracker-2017` itself:
+
+
+# 21:51:16 >  
+# 21:51:16 >  "mserver5" "--debug=10" "--set" "gdk_nr_threads=0" "--set" 
"mapi_open=true" "--set" "mapi_port=33190" "--set" 
"mapi_usock=/var/tmp/mtest-28204/.s.monetdb.33190" "--set" "monet_prompt=" 
"--forcemito" 
"--dbpath=/home/niels/scratch/rc-clean/Linux-x86_64/var/MonetDB/mTests_sql_test_BugTracker-2017"
+# 21:51:16 >  
+
+# MonetDB 5 server v11.25.6
+# This is an unreleased version
+# Serving database 'mTests_sql_test_BugTracker-2017', using 8 threads
+# Compiled for x86_64-unknown-linux-gnu/64bit with 128bit integers
+# Found 15.615 GiB available main-memory.
+# Copyright (c) 1993-July 2008 CWI.
+# Copyright (c) August 2008-2017 MonetDB B.V., all rights reserved
+# Visit http://www.monetdb.org/ for further information
+# Listening for connection requests on mapi:monetdb://mosquitto:33190/
+# Listening for UNIX domain connection requests on 
mapi:monetdb:///var/tmp/mtest-28204/.s.monetdb.33190
+# MonetDB/GIS module loaded
+# MonetDB/SQL module loaded
+
+Ready.
+
+# 21:51:16 >  
+# 21:51:16 >  "mclient" "-lsql" "-ftest" "-Eutf-8" "-i" "-e" 
"--host=/var/tmp/mtest-28204" "--port=33190"
+# 21:51:16 >  
+
_______________________________________________
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to