Changeset: 4237cf8af7d9 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=4237cf8af7d9
Added Files:
sql/test/BugTracker-2014/Tests/copy_decimal_into.Bug-3596.sql
sql/test/BugTracker-2014/Tests/copy_decimal_into.Bug-3596.stable.err
sql/test/BugTracker-2014/Tests/copy_decimal_into.Bug-3596.stable.out
Modified Files:
sql/backends/monet5/sql_result.c
sql/test/BugTracker-2014/Tests/All
Branch: Oct2014
Log Message:
skip whitespace when loading decimals fixes bug 3596
diffs (149 lines):
diff --git a/sql/backends/monet5/sql_result.c b/sql/backends/monet5/sql_result.c
--- a/sql/backends/monet5/sql_result.c
+++ b/sql/backends/monet5/sql_result.c
@@ -388,6 +388,8 @@ bat_max_lnglength(BAT *b)
unsigned int i, neg = 0; \
X *r; \
X res = 0; \
+ while(isspace(*s)) \
+ s++; \
if (*s == '-'){ \
neg = 1; \
s++; \
@@ -408,16 +410,18 @@ bat_max_lnglength(BAT *b)
res *= 10; \
} \
} \
+ while(isspace(*s)) \
+ s++; \
if (*s) { \
if (*s != '.') \
return NULL; \
s++; \
- for (i = 0; *s && i < t->scale; i++, s++) { \
- if (*s < '0' || *s > '9') \
- return NULL; \
+ for (i = 0; *s && *s >= '0' && *s <= '9' && i <
t->scale; i++, s++) { \
res *= 10; \
res += *s - '0'; \
} \
+ while(isspace(*s)) \
+ s++; \
for (; i < t->scale; i++) { \
res *= 10; \
} \
diff --git a/sql/test/BugTracker-2014/Tests/All
b/sql/test/BugTracker-2014/Tests/All
--- a/sql/test/BugTracker-2014/Tests/All
+++ b/sql/test/BugTracker-2014/Tests/All
@@ -45,3 +45,4 @@ sign-sorted.Bug-3594
nil_2dec_lng.Bug-3592
manifold.Bug-3556
duplicate_primary_keys.Bug-3474
+copy_decimal_into.Bug-3596
diff --git a/sql/test/BugTracker-2014/Tests/copy_decimal_into.Bug-3596.sql
b/sql/test/BugTracker-2014/Tests/copy_decimal_into.Bug-3596.sql
new file mode 100644
--- /dev/null
+++ b/sql/test/BugTracker-2014/Tests/copy_decimal_into.Bug-3596.sql
@@ -0,0 +1,8 @@
+create table load_decimals ( n string, d decimal(10,2));
+copy 3 records into load_decimals from STDIN USING DELIMITERS ',','\n';
+t1, 0.1
+t2,0.2
+t3, 1.1
+
+select * from load_decimals;
+drop table load_decimals;
diff --git
a/sql/test/BugTracker-2014/Tests/copy_decimal_into.Bug-3596.stable.err
b/sql/test/BugTracker-2014/Tests/copy_decimal_into.Bug-3596.stable.err
new file mode 100644
--- /dev/null
+++ b/sql/test/BugTracker-2014/Tests/copy_decimal_into.Bug-3596.stable.err
@@ -0,0 +1,37 @@
+stderr of test 'copy_decimal_into.Bug-3596` in directory
'sql/test/BugTracker-2014` itself:
+
+
+# 14:51:59 >
+# 14:51:59 > "mserver5" "--debug=10" "--set" "gdk_nr_threads=0" "--set"
"mapi_open=true" "--set" "mapi_port=38963" "--set"
"mapi_usock=/var/tmp/mtest-5565/.s.monetdb.38963" "--set" "monet_prompt="
"--forcemito" "--set" "mal_listing=2"
"--dbpath=/home/niels/scratch/rc-monetdb/Linux-x86_64/var/MonetDB/mTests_sql_test_BugTracker-2014"
"--set" "mal_listing=0" "--set" "embedded_r=yes"
+# 14:51:59 >
+
+# builtin opt gdk_dbpath =
/home/niels/scratch/rc-monetdb/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 = 38963
+# cmdline opt mapi_usock = /var/tmp/mtest-5565/.s.monetdb.38963
+# cmdline opt monet_prompt =
+# cmdline opt mal_listing = 2
+# cmdline opt gdk_dbpath =
/home/niels/scratch/rc-monetdb/Linux-x86_64/var/MonetDB/mTests_sql_test_BugTracker-2014
+# cmdline opt mal_listing = 0
+# cmdline opt embedded_r = yes
+# cmdline opt gdk_debug = 536870922
+
+# 14:51:59 >
+# 14:51:59 > "mclient" "-lsql" "-ftest" "-Eutf-8" "-i" "-e"
"--host=/var/tmp/mtest-5565" "--port=38963"
+# 14:51:59 >
+
+
+# 14:51:59 >
+# 14:51:59 > "Done."
+# 14:51:59 >
+
diff --git
a/sql/test/BugTracker-2014/Tests/copy_decimal_into.Bug-3596.stable.out
b/sql/test/BugTracker-2014/Tests/copy_decimal_into.Bug-3596.stable.out
new file mode 100644
--- /dev/null
+++ b/sql/test/BugTracker-2014/Tests/copy_decimal_into.Bug-3596.stable.out
@@ -0,0 +1,47 @@
+stdout of test 'copy_decimal_into.Bug-3596` in directory
'sql/test/BugTracker-2014` itself:
+
+
+# 14:51:59 >
+# 14:51:59 > "mserver5" "--debug=10" "--set" "gdk_nr_threads=0" "--set"
"mapi_open=true" "--set" "mapi_port=38963" "--set"
"mapi_usock=/var/tmp/mtest-5565/.s.monetdb.38963" "--set" "monet_prompt="
"--forcemito" "--set" "mal_listing=2"
"--dbpath=/home/niels/scratch/rc-monetdb/Linux-x86_64/var/MonetDB/mTests_sql_test_BugTracker-2014"
"--set" "mal_listing=0" "--set" "embedded_r=yes"
+# 14:51:59 >
+
+# MonetDB 5 server v11.19.0
+# This is an unreleased version
+# Serving database 'mTests_sql_test_BugTracker-2014', using 4 threads
+# Compiled for x86_64-unknown-linux-gnu/64bit with 64bit OIDs dynamically
linked
+# Found 7.334 GiB available main-memory.
+# Copyright (c) 1993-July 2008 CWI.
+# Copyright (c) August 2008-2014 MonetDB B.V., all rights reserved
+# Visit http://www.monetdb.org/ for further information
+# Listening for connection requests on mapi:monetdb://localhost.nes.nl:38963/
+# Listening for UNIX domain connection requests on
mapi:monetdb:///var/tmp/mtest-5565/.s.monetdb.38963
+# MonetDB/GIS module loaded
+# MonetDB/SQL module loaded
+# MonetDB/R module loaded
+
+Ready.
+
+# 14:51:59 >
+# 14:51:59 > "mclient" "-lsql" "-ftest" "-Eutf-8" "-i" "-e"
"--host=/var/tmp/mtest-5565" "--port=38963"
+# 14:51:59 >
+
+#create table load_decimals ( n string, d decimal(10,2));
+#copy 3 records into load_decimals from STDIN USING DELIMITERS ',','\n';
+#t1, 0.1
+#t2,0.2
+#t3, 1.1
+[ 3 ]
+#select * from load_decimals;
+% sys.load_decimals, sys.load_decimals # table_name
+% n, d # name
+% clob, decimal # type
+% 2, 12 # length
+[ "t1", 0.10 ]
+[ "t2", 0.20 ]
+[ "t3", 1.10 ]
+#drop table load_decimals;
+
+# 14:51:59 >
+# 14:51:59 > "Done."
+# 14:51:59 >
+
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list