Changeset: b532bb0d072a for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=b532bb0d072a
Added Files:
sql/test/BugTracker-2013/Tests/like_pcre_or.Bug-3348.sql
sql/test/BugTracker-2013/Tests/like_pcre_or.Bug-3348.stable.err
sql/test/BugTracker-2013/Tests/like_pcre_or.Bug-3348.stable.out
Modified Files:
monetdb5/modules/mal/pcre.c
sql/test/BugTracker-2013/Tests/All
Branch: Feb2013
Log Message:
fixed bug in sql like handling, we didn't escape pcre 'or' ie '|'.
diffs (163 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
@@ -1134,7 +1134,7 @@ sql2pcre(str *r, const char *pat, const
* expression. If the user used the "+" char as escape and has "++"
* in its pattern, then replacing this with "+" is not correct and
* should be "\+" instead. */
- specials = (*esc_str && strchr( ".+*()[]", esc) != NULL);
+ specials = (*esc_str && strchr( ".+*()[]|", esc) != NULL);
*ppat++ = '^';
while ((c = *pat++) != 0) {
@@ -1151,7 +1151,7 @@ sql2pcre(str *r, const char *pat, const
escaped = 1;
}
hasWildcard = 1;
- } else if (strchr(".?+*()[]\\", c) != NULL) {
+ } else if (strchr(".?+*()[]|\\", c) != NULL) {
/* escape PCRE special chars, avoid double backslash if
the
* user uses an invalid escape sequence */
if (!escaped)
@@ -1203,7 +1203,7 @@ pat2pcre(str *r, str pat)
while (*pat) {
int c = *pat++;
- if (strchr( ".+*()\\", c) != NULL) {
+ if (strchr( ".+*()|\\", c) != NULL) {
*ppat++ = '\\';
*ppat++ = c;
} else if (c == '%') {
diff --git a/sql/test/BugTracker-2013/Tests/All
b/sql/test/BugTracker-2013/Tests/All
--- a/sql/test/BugTracker-2013/Tests/All
+++ b/sql/test/BugTracker-2013/Tests/All
@@ -37,3 +37,4 @@ cannot_use_columns_after_groupby.Bug-334
sort_void_crash.Bug-3341
bogus_aggregation_casts.Bug-3342
nestedcalls
+like_pcre_or.Bug-3348
diff --git a/sql/test/BugTracker-2013/Tests/like_pcre_or.Bug-3348.sql
b/sql/test/BugTracker-2013/Tests/like_pcre_or.Bug-3348.sql
new file mode 100644
--- /dev/null
+++ b/sql/test/BugTracker-2013/Tests/like_pcre_or.Bug-3348.sql
@@ -0,0 +1,11 @@
+create table x (a CLOB);
+insert into x VALUES ('aapX');
+insert into x VALUES ('abc|aapX');
+insert into x VALUES ('abc|aap_beer');
+
+select * from x where a like 'abc|aap_%';
+select * from x where a like 'abc|aap_%' escape '_';
+select * from x where a like 'abc|aap__%' escape '_';
+select * from x where a like 'abc|aap!_%' escape '!';
+
+drop table x;
diff --git a/sql/test/BugTracker-2013/Tests/like_pcre_or.Bug-3348.stable.err
b/sql/test/BugTracker-2013/Tests/like_pcre_or.Bug-3348.stable.err
new file mode 100644
--- /dev/null
+++ b/sql/test/BugTracker-2013/Tests/like_pcre_or.Bug-3348.stable.err
@@ -0,0 +1,35 @@
+stderr of test 'like_pcre_or.Bug-3348` in directory 'sql/test/BugTracker-2013`
itself:
+
+
+# 09:04:45 >
+# 09:04:45 > "mserver5" "--debug=10" "--set" "gdk_nr_threads=0" "--set"
"mapi_open=true" "--set" "mapi_port=39939" "--set"
"mapi_usock=/var/tmp/mtest-5753/.s.monetdb.39939" "--set" "monet_prompt="
"--forcemito" "--set" "mal_listing=2"
"--dbpath=/home/niels/scratch/rc-clean/Linux-x86_64/var/MonetDB/mTests_sql_test_BugTracker-2013"
"--set" "mal_listing=0"
+# 09:04:45 >
+
+# 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 = yes
+# 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 = 39939
+# cmdline opt mapi_usock = /var/tmp/mtest-5753/.s.monetdb.39939
+# cmdline opt monet_prompt =
+# cmdline opt mal_listing = 2
+# cmdline opt gdk_dbpath =
/home/niels/scratch/rc-clean/Linux-x86_64/var/MonetDB/mTests_sql_test_BugTracker-2013
+# cmdline opt mal_listing = 0
+
+# 09:04:45 >
+# 09:04:45 > "mclient" "-lsql" "-ftest" "-Eutf-8" "-i" "-e"
"--host=/var/tmp/mtest-5753" "--port=39939"
+# 09:04:45 >
+
+
+# 09:04:45 >
+# 09:04:45 > "Done."
+# 09:04:45 >
+
diff --git a/sql/test/BugTracker-2013/Tests/like_pcre_or.Bug-3348.stable.out
b/sql/test/BugTracker-2013/Tests/like_pcre_or.Bug-3348.stable.out
new file mode 100644
--- /dev/null
+++ b/sql/test/BugTracker-2013/Tests/like_pcre_or.Bug-3348.stable.out
@@ -0,0 +1,64 @@
+stdout of test 'like_pcre_or.Bug-3348` in directory 'sql/test/BugTracker-2013`
itself:
+
+
+# 09:04:45 >
+# 09:04:45 > "mserver5" "--debug=10" "--set" "gdk_nr_threads=0" "--set"
"mapi_open=true" "--set" "mapi_port=39939" "--set"
"mapi_usock=/var/tmp/mtest-5753/.s.monetdb.39939" "--set" "monet_prompt="
"--forcemito" "--set" "mal_listing=2"
"--dbpath=/home/niels/scratch/rc-clean/Linux-x86_64/var/MonetDB/mTests_sql_test_BugTracker-2013"
"--set" "mal_listing=0"
+# 09:04:45 >
+
+# MonetDB 5 server v11.15.12
+# This is an unreleased version
+# Serving database 'mTests_sql_test_BugTracker-2013', using 4 threads
+# Compiled for x86_64-unknown-linux-gnu/64bit with 64bit OIDs dynamically
linked
+# Found 3.775 GiB available main-memory.
+# Copyright (c) 1993-July 2008 CWI.
+# Copyright (c) August 2008-2013 MonetDB B.V., all rights reserved
+# Visit http://www.monetdb.org/ for further information
+# Listening for connection requests on
mapi:monetdb://niels.nesco.mine.nu:39939/
+# Listening for UNIX domain connection requests on
mapi:monetdb:///var/tmp/mtest-5753/.s.monetdb.39939
+# MonetDB/GIS module loaded
+# MonetDB/JAQL module loaded
+# MonetDB/SQL module loaded
+
+Ready.
+
+# 09:04:45 >
+# 09:04:45 > "mclient" "-lsql" "-ftest" "-Eutf-8" "-i" "-e"
"--host=/var/tmp/mtest-5753" "--port=39939"
+# 09:04:45 >
+
+#create table x (a CLOB);
+#insert into x VALUES ('aapX');
+[ 1 ]
+#insert into x VALUES ('abc|aapX');
+[ 1 ]
+#insert into x VALUES ('abc|aap_beer');
+[ 1 ]
+#select * from x where a like 'abc|aap_%';
+% sys.x # table_name
+% a # name
+% clob # type
+% 12 # length
+[ "abc|aapX" ]
+[ "abc|aap_beer" ]
+#select * from x where a like 'abc|aap_%' escape '_';
+% sys.x # table_name
+% a # name
+% clob # type
+% 0 # length
+#select * from x where a like 'abc|aap__%' escape '_';
+% sys.x # table_name
+% a # name
+% clob # type
+% 12 # length
+[ "abc|aap_beer" ]
+#select * from x where a like 'abc|aap!_%' escape '!';
+% sys.x # table_name
+% a # name
+% clob # type
+% 12 # length
+[ "abc|aap_beer" ]
+#drop table x;
+
+# 09:04:45 >
+# 09:04:45 > "Done."
+# 09:04:45 >
+
_______________________________________________
checkin-list mailing list
[email protected]
http://mail.monetdb.org/mailman/listinfo/checkin-list