[MDEV-14291] UPDATE works even if SELECT subquery has wrong syntax (that shouldn't compile at all) Created: 2017-11-05 Updated: 2017-11-07 Resolved: 2017-11-07 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | Data Manipulation - Update |
| Affects Version/s: | 5.5.52-galera |
| Fix Version/s: | N/A |
| Type: | Bug | Priority: | Major |
| Reporter: | Devaliano | Assignee: | Unassigned |
| Resolution: | Not a Bug | Votes: | 0 |
| Labels: | innodb | ||
| Environment: |
Centos 7 Linux server |
||
| Description |
|
Here is the table: it has two columns (termsNoticeId and dateOf)
The table is created and populated like this:
So table currently has one row. There is also 'user' table that has columns managerId, id and dateOfAssent:
You can insert into 'user' as:
Then UPDATE this table like this:
This query is INVALID. There is no 'id' column in termsNotice in SELECT subquery. Yet the query succeeded, and instead of an error message, the table was updated, and dateOfAssent was set to NULL! |
| Comments |
| Comment by Elena Stepanova [ 2017-11-07 ] | |
|
It's a normal correlated subquery which refers to the outer query. I expect you wouldn't claim it to be incorrect if it was
However, since your termsNotice table does not contain id column, the column name unambiguously resolves to the outer query and the qualifier can be skipped. The structure is perfectly fine, it works in all versions of MariaDB, MySQL, and in PostgreSQL too. |