[MDEV-26745] sql_safe_updates blocks queries that actually do use a key column in WHERE Created: 2021-10-01 Updated: 2021-10-12 Resolved: 2021-10-12 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | Optimizer |
| Affects Version/s: | 10.5.12, 10.6.4 |
| Fix Version/s: | N/A |
| Type: | Bug | Priority: | Major |
| Reporter: | Hartmut Holzgraefe | Assignee: | Sergei Golubchik |
| Resolution: | Not a Bug | Votes: | 0 |
| Labels: | None | ||
| Issue Links: |
|
||||||||
| Description |
|
Create a simple test table, and enable sql_safe_updates:
DELETE without WHERE fails now, as expected:
DELETE with a simple WHERE 1=1 also fails as expected:
Now the following two queries fail, too, even though the primary key column is clearly referenced in them:
This one does work as expected though:
What I assume happening here is that the optimizer already optimized "id = id" and "id IS NOT NULL" away, knowing that these will always return "true" anyway, before the SQL_SAFE_UPDATES does even kick in? |
| Comments |
| Comment by Sergei Golubchik [ 2021-10-12 ] |
|
Yes, this is correct. Unless you specify a LIMIT clause, the statement must actually use an index to find rows. Simply mentioning an indexed column in the WHERE clause is not enough. |