Bug #111918 Auto increment column query wrong result

Submitted: 30 Jul 2023 6:12 Modified: 31 Jul 2023 6:29
Reporter: Pedro Ferreira Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: Optimizer Severity:S3 (Non-critical)
Version:8.1.0, 8.0.34, 5.7.43 OS:Ubuntu (22.04)
Assigned to: CPU Architecture:x86 (x86_64)
Tags: auto increment

[30 Jul 2023 6:12] Pedro Ferreira
Description:
Run these queries:

CREATE TABLE t1 (c0 INT AUTO_INCREMENT UNIQUE KEY);
INSERT INTO t1 VALUES ();
INSERT IGNORE INTO t1 VALUES ();

SELECT 1 FROM t1;
 -- 2 rows
SELECT 1 FROM t1 WHERE (t1.c0 > CAST(X'0B36' AS CHAR));
 -- empty
SELECT 1 FROM t1 WHERE (NOT (t1.c0 > CAST(X'0B36' AS CHAR)));
 -- empty
SELECT 1 FROM t1 WHERE ((t1.c0 > CAST(X'0B36' AS CHAR)) IS NULL);
 -- empty

The cardinalities of the predicate queries must match the predicate-less query. By looking more carefully, the query SELECT 1 FROM t1 WHERE (NOT (t1.c0 > CAST(X'0B36' AS CHAR))); has the wrong result, it should return 2 rows.

How to repeat:
Run the queries above.
[31 Jul 2023 6:29] MySQL Verification Team
Hello Pedro Ferreira,

Thank you for the report and test case.

regards,
Umesh

Portions of this website are copyright © 2001, 2002 The PHP Group

Page generated in 0.051 sec. using MySQL 8.4.7-u6-cloud

Timestamp references displayed by the system are UTC.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.