Changeset: 23b2d0c60db9 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=23b2d0c60db9
Added Files:
sql/test/copy/Tests/columns.sql
sql/test/copy/Tests/columns.stable.err
sql/test/copy/Tests/columns.stable.out
Modified Files:
sql/server/rel_updates.c
sql/test/copy/Tests/All
Branch: Jun2016
Log Message:
fixed crash in copy into with column list (only)
diffs (174 lines):
diff --git a/sql/server/rel_updates.c b/sql/server/rel_updates.c
--- a/sql/server/rel_updates.c
+++ b/sql/server/rel_updates.c
@@ -1243,8 +1243,12 @@ copyfrom(mvc *sql, dlist *qname, dlist *
collist = check_table_columns(sql, t, columns, "COPY", tname);
if (!collist)
return NULL;
- /* if collist has skip and different order (or format specification)
use intermediate table */
+ /* If we have a header specification use intermediate table, for
+ * column specification other then the default list we need to reorder
+ */
nt = t;
+ if (headers || collist != t->columns.set)
+ reorder = 1;
if (headers) {
int has_formats = 0;
dnode *n;
diff --git a/sql/test/copy/Tests/All b/sql/test/copy/Tests/All
--- a/sql/test/copy/Tests/All
+++ b/sql/test/copy/Tests/All
@@ -12,3 +12,4 @@ format_date
key_copy
nonutf8
incorrect_columns
+columns
diff --git a/sql/test/copy/Tests/columns.sql b/sql/test/copy/Tests/columns.sql
new file mode 100644
--- /dev/null
+++ b/sql/test/copy/Tests/columns.sql
@@ -0,0 +1,26 @@
+-- error as there is no data for the s column (which we later skip)
+create table tbl (i int, s string, d decimal(5, 2));
+copy 3 records into tbl (i, d) from stdin delimiters ',','\n';
+1,2.0
+2,2.1
+3,2.2
+select * from tbl;
+drop table tbl;
+
+-- s column has data but we do not use it
+create table tbl (i int, s string, d decimal(5, 2));
+copy 3 records into tbl (i, d) from stdin delimiters ',','\n';
+1,"test",2.0
+2,"test1",2.1
+3,"test",2.2
+select * from tbl;
+drop table tbl;
+
+-- s not given and not used
+create table tbl (i int, s string, d decimal(5, 2));
+copy 3 records into tbl (i, d) from stdin (i, d) delimiters ',','\n';
+1,2.0
+2,2.1
+3,2.2
+select * from tbl;
+drop table tbl;
diff --git a/sql/test/copy/Tests/columns.stable.err
b/sql/test/copy/Tests/columns.stable.err
new file mode 100644
--- /dev/null
+++ b/sql/test/copy/Tests/columns.stable.err
@@ -0,0 +1,44 @@
+stderr of test 'columns` in directory 'sql/test/copy` itself:
+
+
+# 09:30:18 >
+# 09:30:18 > "mserver5" "--debug=10" "--set" "gdk_nr_threads=0" "--set"
"mapi_open=true" "--set" "mapi_port=36199" "--set"
"mapi_usock=/var/tmp/mtest-15100/.s.monetdb.36199" "--set" "monet_prompt="
"--forcemito"
"--dbpath=/home/niels/scratch/rc-clean/Linux-x86_64/var/MonetDB/mTests_sql_test_copy"
"--set" "embedded_r=yes"
+# 09:30:18 >
+
+# 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 = 36199
+# cmdline opt mapi_usock = /var/tmp/mtest-15100/.s.monetdb.36199
+# cmdline opt monet_prompt =
+# cmdline opt gdk_dbpath =
/home/niels/scratch/rc-clean/Linux-x86_64/var/MonetDB/mTests_sql_test_copy
+# cmdline opt embedded_r = yes
+# cmdline opt gdk_debug = 536870922
+
+# 09:30:19 >
+# 09:30:19 > "mclient" "-lsql" "-ftest" "-Eutf-8" "-i" "-e"
"--host=/var/tmp/mtest-15100" "--port=36199"
+# 09:30:19 >
+
+MAPI = (monetdb) /var/tmp/mtest-15100/.s.monetdb.36199
+QUERY = copy 3 records into tbl (i, d) from stdin delimiters ',','\n';
+ 1,2.0
+ERROR = !Failed to import table Column value 2 missing
+MAPI = (monetdb) /var/tmp/mtest-15100/.s.monetdb.36199
+QUERY = 2,2.1
+ 3,2.2
+ select * from tbl;
+ERROR = !syntax error, unexpected sqlINT in: "2"
+
+# 09:30:19 >
+# 09:30:19 > "Done."
+# 09:30:19 >
+
diff --git a/sql/test/copy/Tests/columns.stable.out
b/sql/test/copy/Tests/columns.stable.out
new file mode 100644
--- /dev/null
+++ b/sql/test/copy/Tests/columns.stable.out
@@ -0,0 +1,64 @@
+stdout of test 'columns` in directory 'sql/test/copy` itself:
+
+
+# 09:30:18 >
+# 09:30:18 > "mserver5" "--debug=10" "--set" "gdk_nr_threads=0" "--set"
"mapi_open=true" "--set" "mapi_port=36199" "--set"
"mapi_usock=/var/tmp/mtest-15100/.s.monetdb.36199" "--set" "monet_prompt="
"--forcemito"
"--dbpath=/home/niels/scratch/rc-clean/Linux-x86_64/var/MonetDB/mTests_sql_test_copy"
"--set" "embedded_r=yes"
+# 09:30:18 >
+
+# MonetDB 5 server v11.23.4
+# This is an unreleased version
+# Serving database 'mTests_sql_test_copy', using 4 threads
+# Compiled for x86_64-unknown-linux-gnu/64bit with 64bit OIDs and 128bit
integers dynamically linked
+# Found 7.332 GiB available main-memory.
+# Copyright (c) 1993-July 2008 CWI.
+# Copyright (c) August 2008-2016 MonetDB B.V., all rights reserved
+# Visit http://www.monetdb.org/ for further information
+# Listening for connection requests on mapi:monetdb://localhost.nes.nl:36199/
+# Listening for UNIX domain connection requests on
mapi:monetdb:///var/tmp/mtest-15100/.s.monetdb.36199
+# MonetDB/GIS module loaded
+# MonetDB/SQL module loaded
+# MonetDB/R module loaded
+
+Ready.
+
+# 09:30:19 >
+# 09:30:19 > "mclient" "-lsql" "-ftest" "-Eutf-8" "-i" "-e"
"--host=/var/tmp/mtest-15100" "--port=36199"
+# 09:30:19 >
+
+#create table tbl (i int, s string, d decimal(5, 2));
+#drop table tbl;
+#create table tbl (i int, s string, d decimal(5, 2));
+#copy 3 records into tbl (i, d) from stdin delimiters ',','\n';
+#1,"test",2.0
+#2,"test1",2.1
+#3,"test",2.2
+[ 3 ]
+#select * from tbl;
+% sys.tbl, sys.tbl, sys.tbl # table_name
+% i, s, d # name
+% int, clob, decimal # type
+% 1, 0, 7 # length
+[ 1, NULL, 2.00 ]
+[ 2, NULL, 2.10 ]
+[ 3, NULL, 2.20 ]
+#drop table tbl;
+#create table tbl (i int, s string, d decimal(5, 2));
+#copy 3 records into tbl (i, d) from stdin (i, d) delimiters ',','\n';
+#1,2.0
+#2,2.1
+#3,2.2
+[ 3 ]
+#select * from tbl;
+% sys.tbl, sys.tbl, sys.tbl # table_name
+% i, s, d # name
+% int, clob, decimal # type
+% 1, 0, 7 # length
+[ 1, NULL, 2.00 ]
+[ 2, NULL, 2.10 ]
+[ 3, NULL, 2.20 ]
+#drop table tbl;
+
+# 09:30:19 >
+# 09:30:19 > "Done."
+# 09:30:19 >
+
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list