Avoid ignoring the last line of a csv file if the final field is empty and

there is no trailing CFLS. Also have the csv extension treat the last line of a
file in the same way as any other line if it is short fields.

FossilOrigin-Name: 587795d47fcaf5142526fabbcc4d5a632f561f258414c2846e8932a49b5b2e6b
This commit is contained in:
dan 2022-07-06 15:44:57 +00:00
parent e36281fc31
commit e7ebe0aa81
4 changed files with 27 additions and 10 deletions

View File

@ -751,7 +751,7 @@ static int csvtabNext(sqlite3_vtab_cursor *cur){
i++;
}
}while( pCur->rdr.cTerm==',' );
if( z==0 || (pCur->rdr.cTerm==EOF && i<pTab->nCol) ){
if( z==0 && i==0 ){
pCur->iRowid = -1;
}else{
pCur->iRowid++;

View File

@ -1,5 +1,5 @@
C Avoid\sdropping\serror\scodes\sin\sthe\sxBegin()\smethod\sof\svirtual\stable\ssqlite_dbpage.
D 2022-07-06T13:59:45.908
C Avoid\signoring\sthe\slast\sline\sof\sa\scsv\sfile\sif\sthe\sfinal\sfield\sis\sempty\sand\nthere\sis\sno\strailing\sCFLS.\sAlso\shave\sthe\scsv\sextension\streat\sthe\slast\sline\sof\sa\nfile\sin\sthe\ssame\sway\sas\sany\sother\sline\sif\sit\sis\sshort\sfields.
D 2022-07-06T15:44:57.999
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
@ -314,7 +314,7 @@ F ext/misc/cksumvfs.c b42ef52eaaa510d54ec320c87bea149e934a3b06cd232be2093562bf66
F ext/misc/closure.c dbfd8543b2a017ae6b1a5843986b22ddf99ff126ec9634a2f4047cd14c85c243
F ext/misc/completion.c 6dafd7f4348eecc7be9e920d4b419d1fb2af75d938cd9c59a20cfe8beb2f22b9
F ext/misc/compress.c 3354c77a7c8e86e07d849916000cdac451ed96500bfb5bd83b20eb61eee012c9
F ext/misc/csv.c ed30e56908a42499e3f167bbc0a2366a2226d020e2f6ef84d0cf8c191686ebd6
F ext/misc/csv.c ca8d6dafc5469639de81937cb66ae2e6b358542aba94c4f791910d355a8e7f73
F ext/misc/dbdata.c e316fba936571584e55abd5b974a32a191727a6b746053a0c9d439bd2cf93940
F ext/misc/dbdump.c b8592f6f2da292c62991a13864a60d6c573c47a9cc58362131b9e6a64f823e01
F ext/misc/decimal.c 09f967dcf4a1ee35a76309829308ec278d3648168733f4a1147820e11ebefd12
@ -853,7 +853,7 @@ F test/crashM.test d95f59046fa749b0d0822edf18a717788c8f318d
F test/crashtest1.c 09c1c7d728ccf4feb9e481671e29dda5669bbcc2
F test/createtab.test 85cdfdae5c3de331cd888d6c66e1aba575b47c2e3c3cc4a1d6f54140699f5165
F test/cse.test 00b3aea44b16828833c94fbe92475fd6977583fcb064ae0bc590986812b38d0c
F test/csv01.test f3c76474e8e4aed7a0008065e4da4ab9fb7967712eb2037c13b478def0227c72
F test/csv01.test 2ab5514005fd308995c8910bc313e47f0368b94213b9d6c27f9a2da78796a091
F test/ctime.test 340f362f41f92972bbd71f44e10569a5cc694062b692231bd08aa6fe6c1c4773
F test/cursorhint.test 0175e4404181ace3ceca8b114eb0a98eae600d565aa4e2705abbe6614c7fe201
F test/cursorhint2.test 6f3aa9cb19e7418967a10ec6905209bcbb5968054da855fc36c8beee9ae9c42f
@ -1979,8 +1979,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93
F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
P 77916947ce3f0828e1c50bcb8a6438c951ab9e74d83ec4324e82e90e100b9a98
R e13916bae86c24145a230aedfd5b02fd
P 570e2bce595d3a48977dca0bb573dd3fe745a0d13b7122b3ad8ab4745c0700d0
R de3e674aa770d8389e09eb000a6ba987
U dan
Z 3a52626dc6b0f09ba85ace5a67f4f7d5
Z 390a28cf69c24072416f697a32ef7273
# Remove this line to create a well-formed Fossil manifest.

View File

@ -1 +1 @@
570e2bce595d3a48977dca0bb573dd3fe745a0d13b7122b3ad8ab4745c0700d0
587795d47fcaf5142526fabbcc4d5a632f561f258414c2846e8932a49b5b2e6b

View File

@ -253,10 +253,27 @@ for {set ii 0} {$ii < 200} {incr ii} {
do_execsql_test 6.$ii.1 {
CREATE VIRTUAL TABLE abc USING csv(filename='csv.data', header=true);
}
do_execsql_test 6.$ii.2 {
SELECT count(*) FROM abc
} 1
}
for {set ii 0} {$ii < 20} {incr ii} {
reset_db
load_static_extension db csv
set T [randomtext $ii]
set fd [open csv.data w]
puts $fd "a,b"
puts -nonewline $fd "abcd,$T"
close $fd
do_execsql_test 7.$ii.1 {
CREATE VIRTUAL TABLE abc USING csv(filename='csv.data', header=true);
}
breakpoint
do_execsql_test 7.$ii.2 {
SELECT * FROM abc
} [list abcd $T]
}
finish_test