Unwanted CLI CR-LF to LF conversion

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Unwanted CLI CR-LF to LF conversion

Tomáš Szépe
Hi,

cat << EOF| sqlite3 x.sqlite3
create table foo(bar text);
insert into foo values(' baz
x');
EOF

The literal written as a C string is "\r\r\rbaz\r\nx".
However, the string actually stored turns out to be "\r\r\rbaz\nx".

$ echo .dump| sqlite3 x.sqlite3
PRAGMA foreign_keys=OFF;
BEGIN TRANSACTION;
CREATE TABLE foo(bar text);
INSERT INTO "foo" VALUES(' baz
x');
COMMIT;

Happens even with CLI ".read" command.
I believe this to be a bug.

Linux/i686, sqlite-3.6.23.

Best regards,
--
Tomáš Szépe <[hidden email]>
_______________________________________________
sqlite-users mailing list
[hidden email]
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: Unwanted CLI CR-LF to LF conversion

Roger Binns
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Tomáš Szépe wrote:
> Happens even with CLI ".read" command.
> I believe this to be a bug.

You are supplying text to a text based program and finding that it
treats text as text :-)  Note that on Unix end of line is LF and that is
exactly what is happening.

Your work around is to supply blobs where you can provide the exact
UTF-8 byte sequence you want and then use CAST to convert to or from a
string.


Alternatively you can write your own shell to handle things exactly the
way you want.  At the heart of the shell is a loop that processes
internal commands (.dump, .read etc) if the line starts with a dot, else
sqlite3_complete() is called until it returns true and then the SQL is
executed.

Roger
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkuw4x4ACgkQmOOfHg372QT6HACfR5LnemoEQvmWV3lYu+K//pmh
wB8An0oB8d6LPP90TLZkrhlwPVCaEJma
=oToI
-----END PGP SIGNATURE-----
_______________________________________________
sqlite-users mailing list
[hidden email]
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users