Changeset: b434d2d9e71d for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=b434d2d9e71d
Modified Files:
        MonetDB5/src/modules/mal/tablet_sql.mx
        sql/ChangeLog.Jun2010
        
sql/src/test/BugDay_2005-11-09_2.9.3/Tests/hang_on_copy_into.SF-1100504.stable.err
        
sql/src/test/BugDay_2005-11-09_2.9.3/Tests/hang_on_copy_into.SF-1100504.stable.err.Windows
Branch: Jun2010
Log Message:

Fixed reading in CSV files where a quote is missing.
We now give a decent error message and the COPY INTO will have failed
(instead of having silently accepted all but the final, faulty
record).
Approved the new stable output for the test testing this.


diffs (263 lines):

diff -r d4c180120f3c -r b434d2d9e71d MonetDB5/src/modules/mal/tablet_sql.mx
--- a/MonetDB5/src/modules/mal/tablet_sql.mx    Wed Sep 15 15:44:46 2010 +0200
+++ b/MonetDB5/src/modules/mal/tablet_sql.mx    Fri Sep 17 10:09:22 2010 +0200
@@ -470,15 +470,16 @@
        for (i = 0; i < 16; i++)
                ptask[i].cols = 0;
 
+       if ( task == 0){
+               as->error = M5OutOfMemory;
+               return BUN_NONE;
+       }
+
        /* trimming process should not be active during this process. */
        /* on sf10 experiments it showed a slowdown of a factor 2 on */
        /* large tables. Instead rely on madvise */
        GDK_vm_trim = 0;
 
-       if ( task == 0){
-               as->error = M5OutOfMemory;
-               return BUN_NONE;
-       }
        assert(rsep);
        assert(csep);
        assert(maxrow < 0 || maxrow <= (lng) BUN_MAX);
@@ -622,7 +623,7 @@
                           The user should supply the correct number
                           of fields.
                           In the first phase we simply break the lines
-                               at the record boundary.
+                          at the record boundary.
                        */
                        if ( quote == 0) {
                                if (rseplen == 1)
@@ -720,7 +721,7 @@
                                        res = -1;
                        }
                }
-               lio += GDKusec() -t1;   /* line bread done */
+               lio += GDKusec() -t1;   /* line break done */
                if ( task->next ){
                        if ( res == 0){
                                SQLworkdivider(task, ptask, (int) as->nr_attrs, 
threads);
@@ -751,6 +752,14 @@
                MT_down_sema(task->consumer, "tablet loader");
        }
 
+       if (task->b->pos < task->b->len && cnt < (BUN) maxrow && task->ateof) {
+               GDKerror("Incomplete record at end of file.\n");
+               /* indicate that we did read everything (even if we couldn't
+                  deal with it */
+               task->b->pos = task->b->len;
+               res = -1;
+       }
+
        if (GDKdebug & GRPalgorithms) {
                if (cnt < (BUN) maxrow   && maxrow > 0)
                        /* providing a precise count is not always easy, 
instead consider maxrow as an upper bound */
@@ -822,6 +831,8 @@
 #ifdef MLOCK_TST
        munlockall();
 #endif
+       /* restore system setting */
+       GDK_vm_trim = vmtrim;
        return BUN_NONE;
 }
 
diff -r d4c180120f3c -r b434d2d9e71d sql/ChangeLog.Jun2010
--- a/sql/ChangeLog.Jun2010     Wed Sep 15 15:44:46 2010 +0200
+++ b/sql/ChangeLog.Jun2010     Fri Sep 17 10:09:22 2010 +0200
@@ -1,6 +1,10 @@
 # ChangeLog file for sql
 # This file is updated with Maddlog
 
+* Fri Sep 17 2010 Sjoerd Mullender <sjo...@acm.org>
+- Fixed a bug where the server silently ignored the last record in a
+  COPY INTO if it was incomplete (e.g. missing a quote).
+
 * Mon Aug 30 2010 Sjoerd Mullender <sjo...@acm.org>
 - Fixed a crash of the server when an extremely complex query is
   attempted.  This is the latest incarnation of bug 104.
diff -r d4c180120f3c -r b434d2d9e71d 
sql/src/test/BugDay_2005-11-09_2.9.3/Tests/hang_on_copy_into.SF-1100504.stable.err
--- 
a/sql/src/test/BugDay_2005-11-09_2.9.3/Tests/hang_on_copy_into.SF-1100504.stable.err
        Wed Sep 15 15:44:46 2010 +0200
+++ 
b/sql/src/test/BugDay_2005-11-09_2.9.3/Tests/hang_on_copy_into.SF-1100504.stable.err
        Fri Sep 17 10:09:22 2010 +0200
@@ -76,51 +76,21 @@
 # 23:26:36 >  mclient -lsql -i --host=eir --port=38510 
 # 23:26:36 >  
 
-MAPI  = mone...@alf:32257
+MAPI  = mone...@ottar:34319
 QUERY = COPY 1 RECORDS INTO "news" FROM stdin USING DELIMITERS '\t', '\n', 
'''';
-ERROR = !SQLException:sql:End of string (') missing in "1      'dwerg.net word 
volwassen, er is eindelijk content
-        !en het voicemail archief begint al aardig vol te lopen.
-        !De commentaar en rating code voor de voicemails is ook
-        !al vrij aardig aan het vorderen. Dus dat beloofd nog
-        !wat.r
-        !<br /><br />r
-        !Mja, het is dat ik veel te veel
-        !tijd heb en het helemaal verkeerd indeel dat het
-        !allemaal nogal lang duurt, maar in principe is het nog
-        !maar een uurtje of 6 werk om het goed te krijgen. Zoals
-        !je kan zien heb ik bij de voicemails al wat leuke
-        !knopjes gezet, en het aantal voicemails dat je in 1
-        !keer ziet verhoogd naar 15. Poepoe.r
-        !<br /><br
-        !/>r
-        !Het is me allemaal wat...r
-        !<br /><br
-        !/>r
-        !Muziek: Air   1       2002-02-22 00:21:00.000
-        !              
-        !" at line 1 field 1
-        !SQLException:importTable:failed to import table
-        !ERROR: End of string (') missing in "1        'dwerg.net word 
volwassen, er is eindelijk content
-        !ERROR: en het voicemail archief begint al aardig vol te lopen.
-        !ERROR: De commentaar en rating code voor de voicemails is ook
-        !ERROR: al vrij aardig aan het vorderen. Dus dat beloofd nog
-        !ERROR: wat.r
-        !ERROR: <br /><br />r
-        !ERROR: Mja, het is dat ik veel te veel
-        !ERROR: tijd heb en het helemaal verkeerd indeel dat het
-        !ERROR: allemaal nogal lang duurt, maar in principe is het nog
-        !ERROR: maar een uurtje of 6 werk om het goed te krijgen. Zoals
-        !ERROR: je kan zien heb ik bij de voicemails al wat leuke
-        !ERROR: knopjes gezet, en het aantal voicemails dat je in 1
-        !ERROR: keer ziet verhoogd naar 15. Poepoe.r
-        !ERROR: <br /><br
-        !ERROR: />r
-        !ERROR: Het is me allemaal wat...r
-        !ERROR: <br /><br
-        !ERROR: />r
-        !ERROR: Muziek: Air    1       2002-02-22 00:21:00.000
-        !ERROR:                
-        !ERROR: " at line 1 field 1
+        1      'dwerg.net word volwassen, er is eindelijk content
+        en het voicemail archief begint al aardig vol te lopen.
+        De commentaar en rating code voor de voicemails is ook
+        al vrij aardig aan het vorderen. Dus dat beloofd nog
+        wat.r
+        <br /><br />r
+        Mja, het is dat ik veel te veel
+        tijd heb en het helemaal verkeerd indeel dat het
+        allemaal nogal lang duurt, maar in principe is het nog
+        maar een uurtje of 6 werk om het goed te krijgen. Zoals
+        je kan zie
+ERROR = !SQLException:importTable:failed to import table
+        !ERROR: Incomplete record at end of file.
 
 # 23:26:36 >  
 # 23:26:36 >  Done.
diff -r d4c180120f3c -r b434d2d9e71d 
sql/src/test/BugDay_2005-11-09_2.9.3/Tests/hang_on_copy_into.SF-1100504.stable.err.Windows
--- 
a/sql/src/test/BugDay_2005-11-09_2.9.3/Tests/hang_on_copy_into.SF-1100504.stable.err.Windows
        Wed Sep 15 15:44:46 2010 +0200
+++ /dev/null   Thu Jan 01 00:00:00 1970 +0000
@@ -1,110 +0,0 @@
-stderr of test 'hang_on_copy_into.SF-1100504` in directory 
'src/test/BugDay_2005-11-09_2.9.3` itself:
-
-
-# 23:26:36 >  
-# 23:26:36 >   mserver5 "--config=/ufs/mk/candidate//Linux/etc/monetdb5.conf" 
--debug=10 --set gdk_nr_threads=0 --set 
"monet_mod_path=/ufs/mk/candidate//Linux/lib/MonetDB5:/ufs/mk/candidate//Linux/lib/MonetDB5/lib:/ufs/mk/candidate//Linux/lib/MonetDB5/bin"
 --set "gdk_dbfarm=/ufs/mk/candidate//Linux/var/MonetDB5/dbfarm"  --set 
mapi_open=true --set xrpc_open=true --set mapi_port=38510 --set xrpc_port=45958 
--set monet_prompt= --trace  "--dbname=mTests_src_test_BugDay_2005-11-09_2.9.3" 
--set mal_listing=0 "--dbinit= include sql;" ; echo ; echo Over..
-# 23:26:36 >  
-
-# builtin opt  gdk_arch = 64bitx86_64-unknown-linux-gnu
-# builtin opt  gdk_version = 1.34.0
-# builtin opt  prefix = /ufs/mk/candidate//Linux
-# builtin opt  exec_prefix = ${prefix}
-# builtin opt  gdk_dbname = tst
-# builtin opt  gdk_dbfarm = ${prefix}/var/MonetDB
-# builtin opt  gdk_debug = 8
-# builtin opt  gdk_alloc_map = yes
-# builtin opt  gdk_vmtrim = yes
-# builtin opt  monet_admin = adm
-# builtin opt  monet_prompt = >
-# builtin opt  monet_welcome = yes
-# builtin opt  monet_mod_path = ${exec_prefix}/lib/MonetDB
-# builtin opt  monet_daemon = yes
-# builtin opt  host = localhost
-# builtin opt  mapi_port = 50000
-# builtin opt  mapi_noheaders = no
-# builtin opt  mapi_debug = 0
-# builtin opt  mapi_clients = 2
-# builtin opt  sql_debug = 0
-# builtin opt  standoff_ns = http://monetdb.cwi.nl/standoff
-# builtin opt  standoff_start = start
-# builtin opt  standoff_end = end
-# config opt   prefix = /ufs/mk/candidate//Linux
-# config opt   config = ${prefix}/etc/monetdb5.conf
-# config opt   prefix = /ufs/mk/candidate//Linux
-# config opt   exec_prefix = ${prefix}
-# config opt   gdk_dbfarm = ${prefix}/var/MonetDB5/dbfarm
-# config opt   gdk_dbname = demo
-# config opt   gdk_alloc_map = no
-# config opt   gdk_embedded = no
-# config opt   gdk_debug = 0
-# config opt   monet_mod_path = 
${exec_prefix}/lib/MonetDB5:${exec_prefix}/lib/MonetDB5/lib:${exec_prefix}/lib/MonetDB5/bin
-# config opt   monet_daemon = no
-# config opt   monet_welcome = yes
-# config opt   mero_msglog = ${prefix}/var/log/MonetDB/merovingian.log
-# config opt   mero_errlog = ${prefix}/var/log/MonetDB/merovingian.log
-# config opt   mero_pidfile = ${prefix}/var/run/MonetDB/merovingian.pid
-# config opt   mero_controlport = 50001
-# config opt   mal_init = ${exec_prefix}/lib/MonetDB5/mal_init.mal
-# config opt   mal_listing = 2
-# config opt   mapi_port = 50000
-# config opt   mapi_autosense = false
-# config opt   mapi_open = false
-# config opt   sql_optimizer = accumulator_pipe
-# config opt   default_pipe = 
inline,remap,evaluate,costModel,coercions,emptySet,aliases,mergetable,deadcode,constants,commonTerms,joinPath,deadcode,reduce,garbageCollector,dataflow,history,multiplex
-# config opt   accumulator_pipe = 
inline,remap,evaluate,costModel,coercions,emptySet,aliases,mergetable,deadcode,constants,commonTerms,joinPath,deadcode,reduce,accumulators,garbageCollector,dataflow,history,multiplex
-# config opt   replication_pipe = 
inline,remap,evaluate,costModel,coercions,emptySet,aliases,mergetable,deadcode,constants,commonTerms,joinPath,deadcode,reduce,garbageCollector,dataflow,history,replication,multiplex
-# config opt   recycler_pipe = 
inline,remap,evaluate,costModel,coercions,emptySet,aliases,deadcode,constants,commonTerms,joinPath,deadcode,recycle,reduce,garbageCollector,dataflow,history,multiplex
-# config opt   cracker_pipe = 
inline,remap,evaluate,costModel,coercions,emptySet,aliases,selcrack,deadcode,constants,commonTerms,joinPath,deadcode,reduce,garbageCollector,dataflow,history,multiplex
-# config opt   datacell_pipe = 
inline,remap,evaluate,costModel,coercions,emptySet,aliases,deadcode,constants,commonTerms,joinPath,datacell,deadcode,reduce,garbageCollector,dataflow,history,multiplex
-# config opt   octopus_pipe = 
inline,remap,evaluate,costModel,coercions,emptySet,mitosis,aliases,mergetable,deadcode,constants,commonTerms,joinPath,octopus,deadcode,reduce,garbageCollector,dataflow,history,multiplex
-# config opt   mitosis_pipe = 
inline,remap,evaluate,costModel,coercions,emptySet,mitosis,aliases,mergetable,deadcode,constants,commonTerms,joinPath,reorder,deadcode,reduce,garbageCollector,dataflow,history,multiplex
-# cmdline opt  config = /ufs/mk/candidate//Linux/etc/monetdb5.conf
-# cmdline opt  gdk_nr_threads = 0
-# cmdline opt  monet_mod_path = 
/ufs/mk/candidate//Linux/lib/MonetDB5:/ufs/mk/candidate//Linux/lib/MonetDB5/lib:/ufs/mk/candidate//Linux/lib/MonetDB5/bin
-# cmdline opt  gdk_dbfarm = /ufs/mk/candidate//Linux/var/MonetDB5/dbfarm
-# cmdline opt  mapi_open = true
-# cmdline opt  xrpc_open = true
-# cmdline opt  mapi_port = 38510
-# cmdline opt  xrpc_port = 45958
-# cmdline opt  monet_prompt = 
-# cmdline opt  gdk_dbname = mTests_src_test_BugDay_2005-11-09_2.9.3
-# cmdline opt  mal_listing = 0
-#warning: please don't forget to set your vault key!
-#(see /ufs/mk/candidate//Linux/etc/monetdb5.conf)
-
-# 23:26:36 >  
-# 23:26:36 >  mclient -lsql -i --host=eir --port=38510 
-# 23:26:36 >  
-
-MAPI  = mone...@eir:38510
-QUERY = COPY 1 RECORDS INTO "news" FROM stdin USING DELIMITERS '\t', '\n', 
'''';
-ERROR = !SQLException:sql:End of string (') missing in "1      'dwerg.net word 
volwassen, er is eindelijk content
-        !en het voicemail archief begint al aardig vol te lopen.
-        !De commentaar en rating code voor de voicemails is ook
-        !al vrij aardig aan het vorderen. Dus dat beloofd nog
-        !wat.r
-        !<br /><br />r
-        !Mja, het is dat ik veel te veel
-        !tijd heb en het helemaal verkeerd indeel dat het
-        !allemaal nogal lang duurt, maar in principe is het nog
-        !maar een uurtje of 6 werk om het goed te krijgen. Zoals
-        !je kan zien heb ik bij de voicemails al wat leuke
-        !kno"
-        !SQLException:importTable:failed to import table
-        !ERROR: End of string (') missing in "1        'dwerg.net word 
volwassen, er is eindelijk content
-        !ERROR: en het voicemail archief begint al aardig vol te lopen.
-        !ERROR: De commentaar en rating code voor de voicemails is ook
-        !ERROR: al vrij aardig aan het vorderen. Dus dat beloofd nog
-        !ERROR: wat.r
-        !ERROR: <br /><br />r
-        !ERROR: Mja, het is dat ik veel te veel
-        !ERROR: tijd heb en het helemaal verkeerd indeel dat het
-        !ERROR: allemaal nogal lang duurt, maar in principe is het nog
-        !ERROR: maar een uurtje of 6 werk om het goed te krijgen. Zoals
-        !ERROR: je kan zien heb ik bij de voicemails al wat leuke
-        !ERROR: kno"
-
-# 23:26:36 >  
-# 23:26:36 >  Done.
-# 23:26:36 >  
-
_______________________________________________
Checkin-list mailing list
Checkin-list@monetdb.org
http://mail.monetdb.org/mailman/listinfo/checkin-list

Reply via email to