Skip to content

sql return error:Unknown column 'a2.col_bigint' in 'field list' #60602

@showonlady

Description

@showonlady

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)


DROP TABLE /*! IF EXISTS*/ mysql_1;
CREATE TABLE `mysql_1` (
`col_int_auto_increment` int(10) AUTO_INCREMENT,
`col_pk_char` char(60)  not null,
`col_pk_varchar` varchar(60) not null,
`col_pk_date` date not null,
`col_int` int,
`col_int__1` int,
`col_int_8` int(8),
`col_int_8__1` int(8),
`col_bigint` bigint,
`col_smallint` smallint,
`col_tinyint` tinyint,
`col_float` float,
`col_double` double,
`col_numeric` numeric,
`col_bit` bit,
`col_bit__1` bit,
`col_enum` enum ('a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'),
`col_set` set ('a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'),
`col_char_3` char(3),
`col_char_255` char(255),
`col_varchar_1` varchar(1),
`col_varchar_64` varchar(64),
`col_varchar_2048` varchar(2048),
`col_binary_8` binary(8),
`col_varbinary_8` varbinary(8),
`col_date` date,
`col_time` time,
`col_datetime` datetime,
`col_timestamp` timestamp ,
`col_year` year,
`col_text` text,
`col_bool` bool,
`col_boolean` boolean,
`col_longtext` longtext,
`col_mediumtext` mediumtext,
`col_tinyblob` tinyblob,
`col_mediumblob` mediumblob,
`col_longblob` longblob,
`col_blob` blob,
/*Indices*/
KEY `prefix_index2` (`col_char_255`(10)),
KEY `prefix_index1` (`col_text`(15)),
KEY `functional_index2` (`col_datetime`,`col_date`),
KEY `functional_index1` (`col_enum`,`col_year`,`col_int`),
KEY k2 (`col_int`,`col_char_255`),
KEY k1 (`col_pk_varchar`),
primary key (`col_int_auto_increment`,`col_pk_varchar`,`col_datetime`,`col_int`,`col_date`))  PARTITION BY RANGE(`col_int`)SUBPARTITION BY HASH(year(col_date))(PARTITION p0 VALUES LESS THAN(30)(SUBPARTITION sp0,SUBPARTITION sp1,SUBPARTITION sp2),PARTITION p1 VALUES LESS THAN(50)(SUBPARTITION sp3,SUBPARTITION sp4,SUBPARTITION sp5),PARTITION p2 VALUES LESS THAN(200)(SUBPARTITION sp6,SUBPARTITION sp7,SUBPARTITION sp8));


select 0 from mysql_1 t1 where  ( EXISTS ( SELECT 1 FROM ( SELECT a2.col_bigint FROM mysql_partition_range_subpartition_hash_3 a1 NATURAL LEFT JOIN mysql_partition_range_subpartition_hash_3 a2 WHERE t1.col_bigint = ( SELECT MIN( col_bigint ) FROM ( SELECT DISTINCT a2.* FROM  mysql_partition_range_subpartition_hash_3 a2  WHERE  ( t1.col_numeric <> '0.0330047607421875' )  ) mm ) ) mm ) )  /* QNO 60004 CON_ID 1484783704 */;

2. What did you expect to see? (Required)

from mysql:

MySQL [test1]> select 0 from mysql_1 t1 where  ( EXISTS ( SELECT 1 FROM ( SELECT a2.col_bigint FROM mysql_partition_range_subpartition_hash_3 a1 NATURAL LEFT JOIN mysql_partition_range_subpartition_hash_3 a2 WHERE t1.col_bigint = ( SELECT MIN( col_bigint ) FROM ( SELECT DISTINCT a2.* FROM  mysql_partition_range_subpartition_hash_3 a2  WHERE  ( t1.col_numeric <> '0.0330047607421875' )  ) mm ) ) mm ) )  /* QNO 60004 CON_ID 1484783704 */;
Empty set (0.01 sec)

MySQL [test1]> select version();
+-----------+
| version() |
+-----------+
| 8.4.3     |
+-----------+
1 row in set (0.00 sec)

3. What did you see instead (Required)

mysql> select 0 from mysql_1 t1 where  ( EXISTS ( SELECT 1 FROM ( SELECT a2.col_bigint FROM mysql_partition_range_subpartition_hash_3 a1 NATURAL LEFT JOIN mysql_partition_range_subpartition_hash_3 a2 WHERE t1.col_bigint = ( SELECT MIN( col_bigint ) FROM ( SELECT DISTINCT a2.* FROM  mysql_partition_range_subpartition_hash_3 a2  WHERE  ( t1.col_numeric <> '0.0330047607421875' )  ) mm ) ) mm ) )  /* QNO 60004 CON_ID 1484783704 */;
ERROR 1054 (42S22): Unknown column 'a2.col_bigint' in 'field list'

4. What is your TiDB version? (Required)

mysql> SELECT tidb_version()
    -> ;
+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| tidb_version()                                                                                                                                                                                                                               |
+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Release Version: v8.5.1
Edition: Community
Git Commit Hash: fea86c8e35ad4a86a5e1160701f99493c2ee547c
Git Branch: HEAD
UTC Build Time: 2025-01-16 07:38:34
GoVersion: go1.23.4
Race Enabled: false
Check Table Before Drop: false
Store: tikv |
+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)

Metadata

Metadata

Assignees

No one assigned

    Labels

    affects-6.5This bug affects the 6.5.x(LTS) versions.affects-7.1This bug affects the 7.1.x(LTS) versions.affects-7.5This bug affects the 7.5.x(LTS) versions.affects-8.1This bug affects the 8.1.x(LTS) versions.affects-8.5This bug affects the 8.5.x(LTS) versions.affects-9.0This bug affects the 9.0.x versions.severity/majorsig/plannerSIG: Plannertype/bugThe issue is confirmed as a bug.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions