Hi all,

I seem to have found a bug, possibly related to
http://www.sqlite.org/cvstrac/tktview?tn=234 and the linked checkin
http://www.sqlite.org/cvstrac/chngview?cn=940

A 'C' style block comment that is not all on one line does not get ignored
properly.  If the line immediately after the comment is a dot command, a
syntax error results.  It appears that the dot command is no longer being
treated AS a dot command, probably because of the bogus 'white space' before
the dot.  That means that a real sql statement following the dot command is
not processed either (the dot command and the following line(s) [up to the
first semi-colon] are being parsed as a single sql statement).

simple work around (see test5) : add a semi-colon after the block comment
terminator

Environment:
Windows XP Professional SP3, all important windows updates
SQLite version 3.6.23
sqlite is running on a USB memory stick, although that should have no effect
here

Files to use for testing and error demonstration (listing whitespace
manually edited) shown below, followed by session capture.  test4.sql moved
to end of session, because if actually aborts sqlite3.

Notes for specific test cases:
teset1.sql : base, everything fine here.
test2.sql : the comment is echoed to the screen; a good indication it has
not being 'eaten'.
test3.sql : block comment on single line with dot command after works
properly
test4.sql : block comment with termination on 2nd line breaks things, in my
test case nastily
test5.sql : adding a semi-colon after the the block comment terminator got
everything back in sync.  It terminated the bogus line, and even got the
comment to NOT display in the session
tests 7, 8 and 9 repeat some earlier test using single line comments
reported in ticket 234, and fixed in check 940.  No problems seen
test 10 and 11 check comments at the end of the file.  With no commands
after the comment, no problem seen

$ type test*.sql
test1.sql
/* test */
attach database "players.db" as players;
detach database players;

test2.sql
* test
*/
attach database "players.db" as players;
detach database players;

test3.sql
/* test */
.echo on
attach database "players.db" as players;
detach database players;

test4.sql
/* test
*/
.echo on
attach database "players.db" as players;
detach database players;

test5.sql
/* test
*/;
.echo on
attach database "players.db" as players;
detach database players;

test6.sql
/* test */;
attach database "players.db" as players;
detach database players;

test7.sql
-- test
attach database "players.db" as players;
detach database players;

test8.sql
-- test
.echo on
attach database "players.db" as players;
detach database players;

test9.sql
-- test
.echo on
attach database "players.db" as players;
detach database players;
-- test2

test10.sql
-- test
.echo on
attach database "players.db" as players;
detach database players;
/* test2 */

test11.sql
-- test
.echo on
attach database "players.db" as players;
detach database players;
/* test2
*/

** end of test files **

$ sqlite3 test.db
SQLite version 3.6.23
Enter ".help" for instructions
Enter SQL statements terminated with a ";"
sqlite> .echo on
sqlite> .read "test1.sql"
.read "test1.sql"
attach database "players.db" as players;
detach database players;
sqlite> .read "test2.sql"
.read "test2.sql"
/* test
*/
attach database "players.db" as players;
detach database players;
sqlite> .read "test3.sql"
.read "test3.sql"
.echo on
attach database "players.db" as players;
detach database players;
sqlite> .read "test5.sql"
.read "test5.sql"
.echo on
attach database "players.db" as players;
detach database players;
sqlite> .read "test6.sql"
.read "test6.sql"
attach database "players.db" as players;
detach database players;
sqlite> .read "test7.sql"
.read "test7.sql"
attach database "players.db" as players;
detach database players;
sqlite> .read "test8.sql"
.read "test8.sql"
.echo on
attach database "players.db" as players;
detach database players;
sqlite> .read "test9.sql"
.read "test9.sql"
.echo on
attach database "players.db" as players;
detach database players;
sqlite> .read "test10.sql"
.read "test10.sql"
.echo on
attach database "players.db" as players;
detach database players;
sqlite> .read "test11.sql"
.read "test11.sql"
.echo on
attach database "players.db" as players;
detach database players;
sqlite> .read "test4.sql"
.read "test4.sql"
Error: near line 1: near ".": syntax error
detach database players;
Error: near line 5: no such database: players
$

*** end of session capture

--
mMerlin
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to