Bug #78450 Invalid column name is not detected in select list, but detected as unknown
Submitted: 16 Sep 2015 9:59 Modified: 18 Sep 2015 10:31
Reporter: Su Dylan Email Updates:
Status: Not a Bug Impact on me:
None 
Category:MySQL Server: DML Severity:S3 (Non-critical)
Version:5.6.22 OS:Any
Assigned to: MySQL Verification Team CPU Architecture:Any

[16 Sep 2015 9:59] Su Dylan
Description:
Output:
======
mysql> drop table if exists t1,t2;
Query OK, 0 rows affected, 1 warning (0.00 sec)

mysql> create table t1(c1 int);
Query OK, 0 rows affected (0.00 sec)

mysql> select `c1 ` from t1;
ERROR 1054 (42S22): Unknown column 'c1 ' in 'field list'
mysql> create table t2(`c1 ` int);
ERROR 1166 (42000): Incorrect column name 'c1 '
mysql> select * from `t1 `;
ERROR 1103 (42000): Incorrect table name 't1 '
mysql> ^Mdrop table if exists t1;
Query OK, 0 rows affected (0.00 sec)

mysql> select version();
+------------+
| version()  |
+------------+
| 5.6.22-log |
+------------+
1 row in set (0.00 sec)

Problem:
========
"select `c1 ` from t1;" is expected to fail with "1166 (42000): Incorrect column name 'c1 '", since it is not a valid column name.

How to repeat:
drop table if exists t1,t2;
create table t1(c1 int);
select `c1 ` from t1;
create table t2(`c1 ` int);
select * from `t1 `;

Suggested fix:
"select `c1 ` from t1;" is expected to fail with "1166 (42000): Incorrect column name 'c1 '", since it is not a valid column name.
[18 Sep 2015 10:31] MySQL Verification Team
Hi,

Your expectation is incorrect.

When you try to create a column with wrong name you will get incorrect column name error, for e.g.

mysql> create table `t1` (`c1 ` int);
ERROR 1166 (42000): Incorrect column name 'c1 '

but when you do try to use the `c1 ` in the select the "not found" is appropriate error.

all best
Bogdan Kecman