Skip to content

Commit

Permalink
MDEV-28606 Server crashes in st_select_lex::add_table_to_list instead…
Browse files Browse the repository at this point in the history
… of error 1066: Not unique table/alias

10.2-only fix, 10.3+ uses LEX_STRING's and checks the length first
  • Loading branch information
vuvova committed May 18, 2022
1 parent 84984b7 commit 0ba528f
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
8 changes: 8 additions & 0 deletions mysql-test/r/parser.result
Original file line number Diff line number Diff line change
Expand Up @@ -1409,5 +1409,13 @@ Database Collation latin1_swedish_ci
drop function a;
set timestamp=default;
#
# MDEV-28606 Server crashes in st_select_lex::add_table_to_list instead of error 1066: Not unique table/alias
#
create table t1 (i int) ;
insert into t1 values (1),(2),(3) ;
with cte1 as (select i from t1) select i from cte1 natural join cte1;
ERROR 42000: Not unique table/alias: 'cte1'
drop table t1;
#
# End of 10.2 tests
#
9 changes: 9 additions & 0 deletions mysql-test/t/parser.test
Original file line number Diff line number Diff line change
Expand Up @@ -1432,6 +1432,15 @@ query_vertical show create function a;
drop function a;
set timestamp=default;

--echo #
--echo # MDEV-28606 Server crashes in st_select_lex::add_table_to_list instead of error 1066: Not unique table/alias
--echo #
create table t1 (i int) ;
insert into t1 values (1),(2),(3) ;
--error 1066
with cte1 as (select i from t1) select i from cte1 natural join cte1;
drop table t1;

--echo #
--echo # End of 10.2 tests
--echo #
2 changes: 1 addition & 1 deletion sql/sql_parse.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8040,7 +8040,7 @@ TABLE_LIST *st_select_lex::add_table_to_list(THD *thd,
tables=tables->next_local)
{
if (!my_strcasecmp(table_alias_charset, alias_str, tables->alias) &&
!strcmp(ptr->db, tables->db))
!strcmp(safe_str(ptr->db), safe_str(tables->db)))
{
my_error(ER_NONUNIQ_TABLE, MYF(0), alias_str); /* purecov: tested */
DBUG_RETURN(0); /* purecov: tested */
Expand Down

0 comments on commit 0ba528f

Please sign in to comment.