Details
-
Bug
-
Status: Open (View Workflow)
-
Major
-
Resolution: Unresolved
-
10.11, 11.4, 11.8, 12.3, 13.1, 13.2, 13.3
-
None
Description
Likely cause: old code, not a recent change. CS 10.4.25 has the bug too, while MySQL 5.5 to 9.1 find both rows.
--source include/have_partition.inc
|
--source include/have_innodb.inc
|
SET sql_mode=''; |
CREATE TABLE t1 (a INT, b INT) ENGINE=InnoDB PARTITION BY LIST (a) (PARTITION pn VALUES IN (NULL), PARTITION p0 VALUES IN (0)); |
INSERT INTO t1 VALUES (NULL, 1), (0, 2); |
ALTER TABLE t1 MODIFY a INT NOT NULL; |
--let $n= `SELECT COUNT(*) FROM t1 WHERE a = 0`
|
if ($n != 2) |
{
|
--die The row whose NULL became 0 stays in the NULL partition, and a = 0 finds $n of the 2 rows |
}
|
DROP TABLE t1; |
Leads to:
|
CS 13.1.2 87e62ca17270e163a6d41b3fc8d6f4d440f1bb88 (Optimized, Clang 22.1.8-20260622) Build 05/10/2026 |
mysqltest: At line 10: The row whose NULL became 0 stays in the NULL partition, and a = 0 finds 1 of the 2 rows
|
Partitioning changes the query result. Without partitioning, WHERE a = 0 finds both rows.
The ALTER TABLE changes the NULL to 0 in place, with warning 1265, but the row stays in pn. WHERE a = 0 finds 1 of the 2 rows, and CHECK TABLE reports "Found a misplaced row". The same happens with ALGORITHM=INPLACE, LOCK=NONE, with ALTER IGNORE TABLE under the default strict sql_mode, and with RANGE and KEY partitioning. ALGORITHM=COPY, and MyISAM, give the right result. Debug builds give the same result.
|
MySQL |
+--------+--------+--------+
|
| MySQL | Finds | Engine |
|
+--------+--------+--------+
|
| 5.5.62 | 2 rows | InnoDB |
|
| 5.6.51 | 2 rows | InnoDB |
|
| 5.7.44 | 2 rows | InnoDB |
|
| 8.0.36 | 2 rows | InnoDB |
|
| 9.1.0 | 2 rows | InnoDB |
|
+--------+--------+--------+
|
From the code it seems that ha_partition::check_if_supported_inplace_alter() lets InnoDB make the change in place, and that nothing checks whether the column is a partitioning column.
Attachments
Issue Links
- relates to
-
MDEV-41479 Partitioning changes the query result after an ALTER TABLE to another collation of a partitioning column
-
- Open
-