Bug #113491 The query statement unexpectedly returned a field that is not in this table.
Submitted: 22 Dec 2023 12:01 Modified: 25 Dec 2023 15:01
Reporter: azusa sor Email Updates:
Status: Can't repeat Impact on me:
None 
Category:MySQL Server: Prepared statements Severity:S3 (Non-critical)
Version:all OS:Any
Assigned to: MySQL Verification Team CPU Architecture:Any

[22 Dec 2023 12:01] azusa sor
Description:
I have two tables, a table A and a table B. When I use a query, I unexpectedly return the field of table A, but this field does not exist in table B.

How to repeat:
Examples are as follows

create table a (
      id char(36),
      mc char(36)
);

create table b (
    id char(36),
    lx char(36)
);

select (select mc from b where id = q.id ) from a q;

Suggested fix:
should prompt that the field does not exist.Because table b has no mc field.
[25 Dec 2023 15:01] MySQL Verification Team
Hi,

I cannot reproduce this:

mysql> select (select mc from b where id = q.id ) from a q;
ERROR 1054 (42S22): Unknown column 'mc' in 'field list'
mysql> 
mysql> PREPARE stmt1 FROM 'select (select mc from b where id = q.id ) from a q';
ERROR 1054 (42S22): Unknown column 'mc' in 'field list'
mysql>