SQLite CLI removes '\r' even from inside quoted strings
that appear in SQL input piped into sqlite
(CLI).
These are never replaced later.
A program should not tamper literals in this undocumented way.
Files in this repository face automatic CRLF translation
from browsers or perhaps github.
So take care that you either download zip of this gist
or first ensure that git
itself does not do
automatic CRLF translations
(run git config --global core.autocrlf false
),
only then clone the gist.
To run demo, hop inside folder containing bug_demo.sh,
and run bash -x bug_demo.sh
.
View the relevant files (see DESCRIPTION OF VARIOUS FILES below) using any program which shows all bytes. I used hexdump (hd) in demo for this purpose.
A diff against version b066637bb7 that removes the bug (on my pc) is
in file potential_correction.diff
.
fossil blame src/shell.c
shows:
...
b1b48be1cf 2009-12-17 shaneh: if( n>0 && zLine[n-1]=='\r' ) n--;
...
fossil info b1b48be1cf
shows:
uuid b1b48be1cf55f3179eab8824cf5fee8100518845 2009-12-17 21:07:15 UTC
parent 333c3ffe6d4d2293d01958812b9c02b0bf9796a4 2009-12-17 21:05:43 UTC
child 29e3c8da1bd3971215036e5f5cfa5b25c6caa81f 2009-12-17 21:07:54 UTC
tags trunk`
comment In shell.c (CLI), modified local_getline() to remove '\r' as well
as '\n' from end of lines.
This provides consistency between MSVC and CYGWIN builds.
(user: shaneh)
Someone please weigh the problem and decide on appropriate fix.
README This file.
original_dump.sql original database dump.
(has '\r' inside a string literal).
final_dump.sql dump of the imported database
('\r' missing)
diff diff between original and final dumps
bug_demo.sh script that demonstrates bug
demo_output.txt stdout of the above script when I ran it
potential_correction.diff A diff against b066637bb7 that
removes the bug (on my pc).
hd hexdump, to demonstrate CR ('\r', ASCII 0x0D) character
in outputs which would otherwise be not visible on terminal
grep to look for CR in hexdump output
diff
sqlite3
uname to identify the platform
-- Prashant Karmakar webster15july@gmail.com Sat Oct 8 12:27:49 IST 2016