Your UPDATE statement does not mean what you think it means.

UPDATE test SET id=0 AND name='new_name' AND age=30 WHERE id=1;

Is parsed as:

UPDATE test SET id = (0 AND name='new_name' AND age=30) WHERE id=1;

The expression (0 AND ...) will always evaluate to 0.


-----Ursprüngliche Nachricht-----
Von: sqlite-users [mailto:sqlite-users-boun...@mailinglists.sqlite.org] Im 
Auftrag von flo
Gesendet: Mittwoch, 17. August 2016 09:05
An: sqlite-users@mailinglists.sqlite.org
Betreff: [sqlite] SQL Syntax fault on UPDATE statement

Hi everyone,

I found a reproducible bug on the SQL UPDATE statement parsing. Here is the 
details.

I 've try to update some data on a SQLite database with a outlandish syntax 
with "AND" between the columns to be update.  The SQL didn't fail but the data 
update was incomplete.


The SQLite version :

$ sqlite3 -version
3.13.0 2016-05-18 10:57:30 fc49f556e48970561d7ab6a2f24fdd7d9eb81ff2


The data base schema :

$ sqlite3 test.db ".schema"
CREATE TABLE test(id interger, name varchar, age integer)


The initial stat of the table :

$ sqlite3 test.db "SELECT * FROM test;"
1|toto|10
2|tita|10
2|tita|10
1|toto|10
2|tita|10


The oulandish SQL UPDATE :

$ sqlite3 test.db "UPDATE test SET id=0 AND name='new_name' AND age=30 WHERE 
id=1;"


The stat of the table after the outlandish update :

$ sqlite3 test.db "SELECT * FROM test;"
0|toto|10
2|tita|10
2|tita|10
0|toto|10
2|tita|10

==> The "id" column was updated but not the two other columns "name" and "age".


A common SQL Update syntaxe work perfectly :

$ sqlite3 test.db "UPDATE test SET id=6, name='new_name', age=30 WHERE id=2;"

$ sqlite3 test.db "SELECT * FROM test;"
0|toto|10
6|new_name|30
6|new_name|30
0|toto|10
6|new_name|30


Good Luck

der.nairolf
_______________________________________________
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users


___________________________________________
 Gunter Hick
Software Engineer
Scientific Games International GmbH
FN 157284 a, HG Wien
Klitschgasse 2-4, A-1130 Vienna, Austria
Tel: +43 1 80100 0
E-Mail: h...@scigames.at

This communication (including any attachments) is intended for the use of the 
intended recipient(s) only and may contain information that is confidential, 
privileged or legally protected. Any unauthorized use or dissemination of this 
communication is strictly prohibited. If you have received this communication 
in error, please immediately notify the sender by return e-mail message and 
delete all copies of the original communication. Thank you for your cooperation.


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

Reply via email to