[MDEV-31785] UPDATE table_name SET column1 = value1 and column2 = value2 does not throw error Created: 2023-07-27 Updated: 2023-08-15 Resolved: 2023-07-31 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | Parser |
| Affects Version/s: | 10.5, 10.6 |
| Fix Version/s: | N/A |
| Type: | Bug | Priority: | Major |
| Reporter: | Allen Lee (Inactive) | Assignee: | Unassigned |
| Resolution: | Not a Bug | Votes: | 0 |
| Labels: | None | ||
| Description |
|
In MariaDB, the following statement does not throw an error, but it is executed successfully
Here is the example:
Above, a was updated with 0, which is incompatible with other databases such as SQL server or Oracle. |
| Comments |
| Comment by Elena Stepanova [ 2023-07-27 ] | |
|
There is no syntax error in the expression, that's why it is accepted. It just works differently from what one intuitively expects.
It is a boolean expression. As usual, implicit casts are applied, 3 casts to TRUE, b = 3 depends on the value of b, which in your case is FALSE for both rows, thus the result is FALSE, and it is cast back to integer 0. Something not working in SQL server or Oracle is not necessarily a sufficient reason to consider it incorrect. As I understand, neither Oracle nor SQL server have boolean types, so the comparison with them is difficult. MySQL accepts the same UPDATE with the same result. |