[MDEV-10170] Misleading "Statements writing to a table with an auto-increment column after selecting from another table are unsafe" on DELETE ... SELECT Created: 2016-06-02 Updated: 2018-10-30 |
|
| Status: | Confirmed |
| Project: | MariaDB Server |
| Component/s: | Data Manipulation - Delete, Replication |
| Affects Version/s: | 10.1.14, 5.5, 10.0, 10.1, 10.2 |
| Fix Version/s: | 10.2 |
| Type: | Bug | Priority: | Minor |
| Reporter: | Hartmut Holzgraefe | Assignee: | Andrei Elkin |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | upstream | ||
| Description |
|
The following warning is raised with binlog_format=STATEMENT when deleting rows from an auto_increment table with a subquery: "Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statements writing to a table with an auto-increment column after selecting from another table are unsafe because the order in which rows are retrieved determines what (if any) rows will be written. This order cannot be predicted and may differ on master and the slave. Statement: DELETE FROM table WHERE some_col IN (SELECT some_id FROM other_table)" As far as I can tell this should only be an issue with INSERT, but not with UPDATE and especially not with DELETE, as in these cases no new auto_increment IDs will be generated. So SELECT result order should not matter unless actual row insertions happen. The current code only seems to check for "table we write to has auto increment, and there's also another table we select from" See https://github.com/MariaDB/server/blob/10.1/sql/sql_class.cc#L5758 |
| Comments |
| Comment by Elena Stepanova [ 2016-06-02 ] | ||||||||||
|
Also reproducible with MySQL 5.6, but not MySQL 5.7. | ||||||||||
| Comment by Elena Stepanova [ 2016-06-28 ] | ||||||||||
|
| ||||||||||
| Comment by Elena Stepanova [ 2016-06-28 ] | ||||||||||
|
Sorry, my bad. Reproducible on 5.7 too. | ||||||||||
| Comment by Valerii Kravchuk [ 2016-12-04 ] | ||||||||||
|
So, it is NOT upstream-fixed, isn't it? Do we have upstream MySQL bug report for this? | ||||||||||
| Comment by Valerii Kravchuk [ 2016-12-13 ] | ||||||||||
|
I've reported http://bugs.mysql.com/bug.php?id=84185 for this. MySQL 5.7.17 and 8.0.0 are still affected. | ||||||||||
| Comment by Hartmut Holzgraefe [ 2017-09-19 ] | ||||||||||
|
The original link above does not point to the right place anymore. The message is raised in THD::decide_logging_format() in sql/sql_class.cc at this point:
|