Parsing bug with sqlite3.exe ?

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

Parsing bug with sqlite3.exe ?

Brown, Dave

I have a text file called "test.sql" which has the following two commands:

CREATE TABLE preference
(
        name TEXT UNIQUE NOT NULL,
        value TEXT
);

INSERT INTO preference (name, value) VALUES( 'test1', 1024 ); -- test
comment

Now I run sqlite3 to create the database:

C:\Temp\SQLite>sqlite3 test.db
SQLite version 3.2.1
Enter ".help" for instructions
sqlite> .read test.sql
Incomplete SQL: INSERT INTO preference (name, value) VALUES( 'test1', 1024
); --
 test comment
sqlite>

If I remove the comment at the end of the INSERT line, it works. I didn't
think having a comment after the statement was supposed to be a syntax
error. Is it?

-Dave
Reply | Threaded
Open this post in threaded view
|

Re: Parsing bug with sqlite3.exe ?

Kurt Welgehausen
The problem seems to be that sqlite is not recognizing
<newline> as a comment terminator (unless the comment
is alone on a line). I think you should write a bug
ticket; meanwhile, the work-around is to end your
comment with a semicolon.

sqlite> select * from t1; -- comment
   ...>
   ...> ;
a           c        
----------  ----------
1           One      
2           Two      
sqlite> select * from t1; -- comment ;
a           c        
----------  ----------
1           One      
2           Two      
sqlite> -- comment
sqlite>


Regards
Reply | Threaded
Open this post in threaded view
|

Re: Parsing bug with sqlite3.exe ?

Ralf Junker
In reply to this post by Brown, Dave
Hello Brown, Dave,

I don't receive any errors executing your SQL script with my SQLiteSpy database explorer, which uses version 3.2.2 of the SQLite library.

Maybe you have accidentally inserted a newline into your script which terminates the "--" comment?

Regards,

Ralf

PS: SQLiteSpy home: http://www.yunqa.de/delphi/sqlitespy/

>I have a text file called "test.sql" which has the following two commands:
>
>CREATE TABLE preference
>(
>        name TEXT UNIQUE NOT NULL,
>        value TEXT
>);
>
>INSERT INTO preference (name, value) VALUES( 'test1', 1024 ); -- test
>comment
>
>Now I run sqlite3 to create the database:
>
>C:\Temp\SQLite>sqlite3 test.db
>SQLite version 3.2.1
>Enter ".help" for instructions
>sqlite> .read test.sql
>Incomplete SQL: INSERT INTO preference (name, value) VALUES( 'test1', 1024
>); --
> test comment
>sqlite>
>
>If I remove the comment at the end of the INSERT line, it works. I didn't
>think having a comment after the statement was supposed to be a syntax
>error. Is it?
>
>-Dave