mirror of
https://github.com/sqlite/sqlite.git
synced 2025-11-05 04:30:38 +03:00
Fix a bug in the shell ".import" command: Do not end the field
when an escaped double-quote occurs at the end of a CRNL line. FossilOrigin-Name: 5e239ecda0f7835ce037b38b04627a574b5854cd
This commit is contained in:
14
manifest
14
manifest
@@ -1,5 +1,5 @@
|
|||||||
C Remove\san\sunreachable\sconditional\sinserted\sby\sthe\sprevious\scheck-in.
|
C Fix\sa\sbug\sin\sthe\sshell\s".import"\scommand:\s\sDo\snot\send\sthe\sfield\nwhen\san\sescaped\sdouble-quote\soccurs\sat\sthe\send\sof\sa\sCRNL\sline.
|
||||||
D 2013-12-11T12:02:55.839
|
D 2013-12-11T14:00:04.667
|
||||||
F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
|
F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
|
||||||
F Makefile.in 2ef13430cd359f7b361bb863504e227b25cc7f81
|
F Makefile.in 2ef13430cd359f7b361bb863504e227b25cc7f81
|
||||||
F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
|
F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
|
||||||
@@ -220,7 +220,7 @@ F src/random.c 0b2dbc37fdfbfa6bd455b091dfcef5bdb32dba68
|
|||||||
F src/resolve.c 7eda9097b29fcf3d2b42fdc17d1de672134e09b6
|
F src/resolve.c 7eda9097b29fcf3d2b42fdc17d1de672134e09b6
|
||||||
F src/rowset.c 64655f1a627c9c212d9ab497899e7424a34222e0
|
F src/rowset.c 64655f1a627c9c212d9ab497899e7424a34222e0
|
||||||
F src/select.c d41381d80a22d3a83352aeca274cccf264ac277a
|
F src/select.c d41381d80a22d3a83352aeca274cccf264ac277a
|
||||||
F src/shell.c 936a72ff784efff3832cce274a96ed0b036e6758
|
F src/shell.c 18924f6ccfa70da98bf9e388bab512c0fd1e792e
|
||||||
F src/sqlite.h.in 125dc0b76f0116f1cd6f13536db52ba981e1c5bd
|
F src/sqlite.h.in 125dc0b76f0116f1cd6f13536db52ba981e1c5bd
|
||||||
F src/sqlite3.rc 11094cc6a157a028b301a9f06b3d03089ea37c3e
|
F src/sqlite3.rc 11094cc6a157a028b301a9f06b3d03089ea37c3e
|
||||||
F src/sqlite3ext.h 886f5a34de171002ad46fae8c36a7d8051c190fc
|
F src/sqlite3ext.h 886f5a34de171002ad46fae8c36a7d8051c190fc
|
||||||
@@ -804,7 +804,7 @@ F test/shell1.test e7c0b9ebda25d5e78f0a3ea0dc4e31bb6d8098c0
|
|||||||
F test/shell2.test e1d3790f064e50b2f973502f45750012667486df
|
F test/shell2.test e1d3790f064e50b2f973502f45750012667486df
|
||||||
F test/shell3.test 5e8545ec72c4413a0e8d4c6be56496e3c257ca29
|
F test/shell3.test 5e8545ec72c4413a0e8d4c6be56496e3c257ca29
|
||||||
F test/shell4.test aa4eef8118b412d1a01477a53426ece169ea86a9
|
F test/shell4.test aa4eef8118b412d1a01477a53426ece169ea86a9
|
||||||
F test/shell5.test 46c8c18d62732415c4fe084816c13d559831705e
|
F test/shell5.test cee83b4385f842fec1f2a0bec9ea811f35386edf
|
||||||
F test/shortread1.test bb591ef20f0fd9ed26d0d12e80eee6d7ac8897a3
|
F test/shortread1.test bb591ef20f0fd9ed26d0d12e80eee6d7ac8897a3
|
||||||
F test/shrink.test 8c70f62b6e8eb4d54533de6d65bd06b1b9a17868
|
F test/shrink.test 8c70f62b6e8eb4d54533de6d65bd06b1b9a17868
|
||||||
F test/sidedelete.test f0ad71abe6233e3b153100f3b8d679b19a488329
|
F test/sidedelete.test f0ad71abe6233e3b153100f3b8d679b19a488329
|
||||||
@@ -1146,7 +1146,7 @@ F tool/vdbe-compress.tcl 0cf56e9263a152b84da86e75a5c0cdcdb7a47891
|
|||||||
F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4
|
F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4
|
||||||
F tool/warnings.sh d1a6de74685f360ab718efda6265994b99bbea01
|
F tool/warnings.sh d1a6de74685f360ab718efda6265994b99bbea01
|
||||||
F tool/win/sqlite.vsix 030f3eeaf2cb811a3692ab9c14d021a75ce41fff
|
F tool/win/sqlite.vsix 030f3eeaf2cb811a3692ab9c14d021a75ce41fff
|
||||||
P a7e5fcd66659750eb2f4675082df324e7cf35427
|
P 3e1d55f0bd84810a035bd6c54583eb373784a9a3
|
||||||
R 67c3fc3c4877c3d23735c8e7af689974
|
R 7d1fbc3502ae32ded8a54ca8c1f54c36
|
||||||
U drh
|
U drh
|
||||||
Z 7b01fedab63512666d5da7a3d79c1ff6
|
Z 2736aa335da363db578416e90c12bc54
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
3e1d55f0bd84810a035bd6c54583eb373784a9a3
|
5e239ecda0f7835ce037b38b04627a574b5854cd
|
||||||
@@ -1836,7 +1836,7 @@ static void csv_append_char(CSVReader *p, int c){
|
|||||||
** + Report syntax errors on stderr
|
** + Report syntax errors on stderr
|
||||||
*/
|
*/
|
||||||
static char *csv_read_one_field(CSVReader *p){
|
static char *csv_read_one_field(CSVReader *p){
|
||||||
int c, pc;
|
int c, pc, ppc;
|
||||||
int cSep = p->cSeparator;
|
int cSep = p->cSeparator;
|
||||||
p->n = 0;
|
p->n = 0;
|
||||||
c = fgetc(p->in);
|
c = fgetc(p->in);
|
||||||
@@ -1847,7 +1847,7 @@ static char *csv_read_one_field(CSVReader *p){
|
|||||||
if( c=='"' ){
|
if( c=='"' ){
|
||||||
int startLine = p->nLine;
|
int startLine = p->nLine;
|
||||||
int cQuote = c;
|
int cQuote = c;
|
||||||
pc = 0;
|
pc = ppc = 0;
|
||||||
while( 1 ){
|
while( 1 ){
|
||||||
c = fgetc(p->in);
|
c = fgetc(p->in);
|
||||||
if( c=='\n' ) p->nLine++;
|
if( c=='\n' ) p->nLine++;
|
||||||
@@ -1859,7 +1859,7 @@ static char *csv_read_one_field(CSVReader *p){
|
|||||||
}
|
}
|
||||||
if( (c==cSep && pc==cQuote)
|
if( (c==cSep && pc==cQuote)
|
||||||
|| (c=='\n' && pc==cQuote)
|
|| (c=='\n' && pc==cQuote)
|
||||||
|| (c=='\n' && pc=='\r' && p->n>=2 && p->z[p->n-2]==cQuote)
|
|| (c=='\n' && pc=='\r' && ppc==cQuote)
|
||||||
|| (c==EOF && pc==cQuote)
|
|| (c==EOF && pc==cQuote)
|
||||||
){
|
){
|
||||||
do{ p->n--; }while( p->z[p->n]!=cQuote );
|
do{ p->n--; }while( p->z[p->n]!=cQuote );
|
||||||
@@ -1877,6 +1877,7 @@ static char *csv_read_one_field(CSVReader *p){
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
csv_append_char(p, c);
|
csv_append_char(p, c);
|
||||||
|
ppc = pc;
|
||||||
pc = c;
|
pc = c;
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
|
|||||||
@@ -268,4 +268,23 @@ do_test shell5-1.9 {
|
|||||||
} {1 {} 11 | 2 x 22 | 3 {"} 33 | 4 hello 44 | 5 55 {} | 6 66 x | 7 77 {"} | 8 88 hello | {} 9 99 | x 10 110 | {"} 11 121 | hello 12 132 |}
|
} {1 {} 11 | 2 x 22 | 3 {"} 33 | 4 hello 44 | 5 55 {} | 6 66 x | 7 77 {"} | 8 88 hello | {} 9 99 | x 10 110 | {"} 11 121 | hello 12 132 |}
|
||||||
db close
|
db close
|
||||||
|
|
||||||
|
# Import columns containing quoted strings
|
||||||
|
do_test shell5-1.10 {
|
||||||
|
set out [open shell5.csv w]
|
||||||
|
fconfigure $out -translation lf
|
||||||
|
puts $out {column1,column2,column3,column4}
|
||||||
|
puts $out "field1,field2,\"x3 \"\"\r\ndata\"\" 3\",field4"
|
||||||
|
puts $out "x1,x2,\"x3 \"\"\ndata\"\" 3\",x4"
|
||||||
|
close $out
|
||||||
|
forcedelete test.db
|
||||||
|
catchcmd test.db {.mode csv
|
||||||
|
CREATE TABLE t1(a,b,c,d);
|
||||||
|
.import shell5.csv t1
|
||||||
|
}
|
||||||
|
sqlite3 db test.db
|
||||||
|
db eval {SELECT hex(c) FROM t1 ORDER BY rowid}
|
||||||
|
} {636F6C756D6E33 783320220D0A64617461222033 783320220A64617461222033}
|
||||||
|
|
||||||
|
db close
|
||||||
|
|
||||||
finish_test
|
finish_test
|
||||||
|
|||||||
Reference in New Issue
Block a user