Bug #16375 | Query fails to produce parse error (and runs) on incorrect syntax | ||
---|---|---|---|
Submitted: | 11 Jan 2006 14:27 | Modified: | 11 Jan 2006 15:00 |
Reporter: | Charlie Farrow | Email Updates: | |
Status: | Not a Bug | Impact on me: | |
Category: | MySQL Server | Severity: | S3 (Non-critical) |
Version: | 5.0.18 | OS: | Windows (Windows XP) |
Assigned to: | CPU Architecture: | Any |
[11 Jan 2006 14:27]
Charlie Farrow
[11 Jan 2006 15:00]
Valeriy Kravchuk
Thank you for a problem report. Sorry, but it is not a bug, although may cause misunderstanding and problems. Look: mysql> create table test (a int auto_increment primary key, b int, c int); Query OK, 0 rows affected (0.01 sec) mysql> insert into test (b,c) values(20, 20), (21, 21), (22, 22); Query OK, 3 rows affected (0.00 sec) Records: 3 Duplicates: 0 Warnings: 0 mysql> select * from test; +---+------+------+ | a | b | c | +---+------+------+ | 1 | 20 | 20 | | 2 | 21 | 21 | | 3 | 22 | 22 | +---+------+------+ 3 rows in set (0.01 sec) mysql> update test set b=11 and c=1 where a=1; Query OK, 1 row affected (0.03 sec) Rows matched: 1 Changed: 1 Warnings: 0 mysql> select * from test; +---+------+------+ | a | b | c | +---+------+------+ | 1 | 0 | 20 | | 2 | 21 | 21 | | 3 | 22 | 22 | +---+------+------+ 3 rows in set (0.00 sec) mysql> update test set b=11 and c=20 where a=1; Query OK, 1 row affected (0.00 sec) Rows matched: 1 Changed: 1 Warnings: 0 mysql> select * from test; +---+------+------+ | a | b | c | +---+------+------+ | 1 | 1 | 20 | | 2 | 21 | 21 | | 3 | 22 | 22 | +---+------+------+ 3 rows in set (0.00 sec) mysql> select 1=1 and 1=0; +-------------+ | 1=1 and 1=0 | +-------------+ | 0 | +-------------+ 1 row in set (0.00 sec) mysql> select 1=1 and 2=2; +-------------+ | 1=1 and 2=2 | +-------------+ | 1 | +-------------+ 1 row in set (0.00 sec) I hope, you got it? Everything after "set b=" and before "where" (or ",") is the expression to be evaluated and set as a value of b: update test set b=11 and c=1 where a=1; is the same as: update test set b=(11 and c=1) where a=1; It is impossible for parser to decide is it what you wanted or not. So, the expression is just evaluated.