Changeset: ee1a1816db24 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=ee1a1816db24
Added Files:
        sql/test/SQLancer/Tests/sqlancer03.sql
        sql/test/SQLancer/Tests/sqlancer03.stable.err
        sql/test/SQLancer/Tests/sqlancer03.stable.out
Modified Files:
        monetdb5/modules/atoms/str.c
        sql/test/SQLancer/Tests/All
Branch: Jun2020
Log Message:

At splitpart, if the needle is empty, skip loop. This speed up SQLancer testing


diffs (81 lines):

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
@@ -3565,7 +3565,7 @@ STRsplitpart(str *res, str *haystack, st
 {
        size_t len;
        int f = *field;
-       char *p;
+       char *p = NULL;
        const char *s = *haystack;
        const char *s2 = *needle;
 
@@ -3581,10 +3581,11 @@ STRsplitpart(str *res, str *haystack, st
        }
 
        len = strlen(s2);
-
-       while ((p = strstr(s, s2)) != NULL && f > 1) {
-               s = p + len;
-               f--;
+       if (len) {
+               while ((p = strstr(s, s2)) != NULL && f > 1) {
+                       s = p + len;
+                       f--;
+               }
        }
 
        if (f != 1) {
diff --git a/sql/test/SQLancer/Tests/All b/sql/test/SQLancer/Tests/All
--- a/sql/test/SQLancer/Tests/All
+++ b/sql/test/SQLancer/Tests/All
@@ -1,2 +1,3 @@
 sqlancer01
 KNOWNFAIL?sqlancer02
+sqlancer03
diff --git a/sql/test/SQLancer/Tests/sqlancer03.sql 
b/sql/test/SQLancer/Tests/sqlancer03.sql
new file mode 100644
--- /dev/null
+++ b/sql/test/SQLancer/Tests/sqlancer03.sql
@@ -0,0 +1,1 @@
+select splitpart(r'%Fz晟2墁', '', 1), splitpart(r'%Fz晟2墁', r'', 2), 
splitpart(r'%Fz晟2墁', r'', 1271186887);
diff --git a/sql/test/SQLancer/Tests/sqlancer03.stable.err 
b/sql/test/SQLancer/Tests/sqlancer03.stable.err
new file mode 100644
--- /dev/null
+++ b/sql/test/SQLancer/Tests/sqlancer03.stable.err
@@ -0,0 +1,12 @@
+stderr of test 'sqlancer03` in directory 'sql/test/SQLancer` itself:
+
+
+# 17:14:16 >  
+# 17:14:16 >  "mclient" "-lsql" "-ftest" "-tnone" "-Eutf-8" "-i" "-e" 
"--host=/var/tmp/mtest-439482" "--port=37916"
+# 17:14:16 >  
+
+
+# 17:14:16 >  
+# 17:14:16 >  "Done."
+# 17:14:16 >  
+
diff --git a/sql/test/SQLancer/Tests/sqlancer03.stable.out 
b/sql/test/SQLancer/Tests/sqlancer03.stable.out
new file mode 100644
--- /dev/null
+++ b/sql/test/SQLancer/Tests/sqlancer03.stable.out
@@ -0,0 +1,18 @@
+stdout of test 'sqlancer03` in directory 'sql/test/SQLancer` itself:
+
+
+# 17:14:16 >  
+# 17:14:16 >  "mclient" "-lsql" "-ftest" "-tnone" "-Eutf-8" "-i" "-e" 
"--host=/var/tmp/mtest-439482" "--port=37916"
+# 17:14:16 >  
+
+#select splitpart(r'%Fz晟2墁', '', 1), splitpart(r'%Fz晟2墁', r'', 2), 
splitpart(r'%Fz晟2墁', r'', 1271186887);
+% .%2, .%3,    .%4 # table_name
+% %2,  %3,     %4 # name
+% clob,        clob,   varchar # type
+% 9,   0,      0 # length
+[ "%Fz晟2墁",   "",     ""      ]
+
+# 17:14:16 >  
+# 17:14:16 >  "Done."
+# 17:14:16 >  
+
_______________________________________________
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to