Bug #120003 column name unexpectedly change because of '1' as a column

Submitted: 7 Mar 12:14 Modified: 9 Mar 9:40
Reporter: cl hl Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: Optimizer Severity:S3 (Non-critical)
Version:8.0.45 OS:Any
Assigned to: CPU Architecture:Any

[7 Mar 12:14] cl hl
Description:
the first column's value should be c2, but it's c2_1 because of the second column and the '1' as a column

mysql> SELECT DISTINCT subq.c2 AS c2, subq.c2 AS c2_1 FROM (SELECT 1 AS c2 FROM t2 AS s467) AS subq;
+------+------+
| c2_1 | c2_1 |
+------+------+
|    1 |    1 |
+------+------+
1 row in set (0.00 sec)

How to repeat:
DROP DATABASE IF EXISTS test;
CREATE DATABASE IF NOT EXISTS test;
SET GLOBAL sort_buffer_size = 64 * 1024 * 1024;
SET GLOBAL read_rnd_buffer_size = 8 * 1024 * 1024;
USE test;

CREATE TABLE t2 (
    c1 INT NOT NULL AUTO_INCREMENT,
    PRIMARY KEY (c1)
);

INSERT INTO t2 (c1) VALUES (9921);

SELECT DISTINCT subq.c2 AS c2, subq.c2 AS c2_1 FROM (SELECT 1 AS c2 FROM t2 AS s467) AS subq;
[9 Mar 9:40] Roy Lyseng
Thank you for the bug report.
Verified as described.

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

Page generated in 0.037 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.