Skip to content

Commit a80549e

Browse files
committed
Bug#35338776: Failure in find_item_in_list with unknown column in field list
The problem is that when a column reference given by table name and column name is looked up in the function find_item_in_list(), we ignored that the searched item may not have a table name, as it is not yet resolved. Now, we should really only search for strict alias names in find_item_in_list(), however removing this support would be a much larger change, so we restrict the fix to an explicit check for a null table name in the searched item. Change-Id: I216f478efe72545e30c61e56919419db8b81f60d
1 parent 97b7679 commit a80549e

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

mysql-test/r/subquery_bugs.result

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2310,3 +2310,6 @@ Warnings:
23102310
Note 1003 /* select#1 */ select (/* select#4 */ select (`test`.`t`.`f` = 1) AS `f` from `test`.`t`) AS `f` from `test`.`t` `t1` join `test`.`t` where false
23112311
DROP VIEW v;
23122312
DROP TABLE t;
2313+
# Bug#35338776: Failure in find_item_in_list with unknown column
2314+
SELECT(SELECT SIN(a.c7)),c7;
2315+
ERROR 42S22: Unknown column 'a.c7' in 'field list'

mysql-test/t/subquery_bugs.test

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1943,3 +1943,9 @@ eval explain $query;
19431943

19441944
DROP VIEW v;
19451945
DROP TABLE t;
1946+
1947+
--echo # Bug#35338776: Failure in find_item_in_list with unknown column
1948+
1949+
--error ER_BAD_FIELD_ERROR
1950+
SELECT(SELECT SIN(a.c7)),c7;
1951+

sql/sql_base.cc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8144,8 +8144,9 @@ bool find_item_in_list(THD *thd, Item *find, mem_root_deque<Item *> *items,
81448144
*/
81458145
if (!my_strcasecmp(system_charset_info, item_field->field_name,
81468146
find_ident->field_name) &&
8147-
!my_strcasecmp(table_alias_charset, item_field->table_name,
8148-
find_ident->table_name) &&
8147+
(item_field->table_name != nullptr &&
8148+
!my_strcasecmp(table_alias_charset, item_field->table_name,
8149+
find_ident->table_name)) &&
81498150
(find_ident->db_name == nullptr ||
81508151
(item_field->db_name != nullptr &&
81518152
!strcmp(item_field->db_name, find_ident->db_name)))) {

0 commit comments

Comments
 (0)