Details
-
Type:
Bug
-
Status: Closed
-
Priority:
Major
-
Resolution: Fixed
-
Affects Version/s: 5.5.37, 10.0.11
-
Component/s: None
-
Labels:
Description
I think this is the simplest way to repeat the bug:
MariaDB [test]> CREATE OR REPLACE TABLE t (
-> d DATE
-> )
-> ENGINE = InnoDB
-> PARTITION BY LIST COLUMNS (d)
-> (
-> PARTITION p0 VALUES IN ('1990-01-01','1991-01-01'),
-> PARTITION p1 VALUES IN ('1981-01-01')
-> );
Query OK, 0 rows affected (1.00 sec)
MariaDB [test]> INSERT INTO t (d) VALUES ('1991-01-01');
Query OK, 1 row affected (0.12 sec)
MariaDB [test]> EXPLAIN PARTITIONS SELECT * FROM t WHERE d = '1991-01-01';
+------+-------------+-------+------------+------+---------------+------+---------+------+------+-----------------------------------------------------+
| id | select_type | table | partitions | type | possible_keys | key | key_len | ref | rows | Extra |
+------+-------------+-------+------------+------+---------------+------+---------+------+------+-----------------------------------------------------+
| 1 | SIMPLE | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | Impossible WHERE noticed after reading const tables |
+------+-------------+-------+------------+------+---------------+------+---------+------+------+-----------------------------------------------------+
1 row in set (0.10 sec)
MariaDB [test]> SELECT * FROM t WHERE d = '1991-01-01';
Empty set (0.00 sec)
MariaDB [test]> SELECT * FROM t;
+------------+
| d |
+------------+
| 1991-01-01 |
+------------+
1 row in set (0.00 sec)
Notice that the inserted row DOES match the queries. Without the WHERE, the SELECT finds it.
If you re-define the table without the first value for p0, the bug disappears.
Gliffy Diagrams
Attachments
Issue Links
- is duplicated by
-
MDEV-6322 The PARTITION engine can return wrong query results
-
- Closed
-
- links to
Activity
- All
- Comments
- Work Log
- History
- Activity
- Transitions
In this case, an impossible where is NOT detected. I suspect it is the same bug, but if you want me to report it separately, please let me know.
MariaDB [test]> CREATE OR REPLACE TABLE t ( -> d DATE -> ) -> ENGINE = InnoDB -> PARTITION BY LIST COLUMNS (d) -> ( -> PARTITION p0 VALUES IN ('1981-01-01'), -> PARTITION p1 VALUES IN ('1990-01-01') -> ); Query OK, 0 rows affected (1.02 sec) MariaDB [test]> EXPLAIN PARTITIONS -> SELECT * FROM t WHERE d > '1990-01-01'; +------+-------------+-------+------------+------+---------------+------+---------+------+------+-------------+ | id | select_type | table | partitions | type | possible_keys | key | key_len | ref | rows | Extra | +------+-------------+-------+------------+------+---------------+------+---------+------+------+-------------+ | 1 | SIMPLE | t | p1 | ALL | NULL | NULL | NULL | NULL | 2 | Using where | +------+-------------+-------+------------+------+---------------+------+---------+------+------+-------------+ 1 row in set (0.01 sec)