Skip to content

Commit 0ba528f

Browse files
committed
MDEV-28606 Server crashes in st_select_lex::add_table_to_list instead of error 1066: Not unique table/alias
10.2-only fix, 10.3+ uses LEX_STRING's and checks the length first
1 parent 84984b7 commit 0ba528f

File tree

3 files changed

+18
-1
lines changed

3 files changed

+18
-1
lines changed

mysql-test/r/parser.result

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1409,5 +1409,13 @@ Database Collation latin1_swedish_ci
14091409
drop function a;
14101410
set timestamp=default;
14111411
#
1412+
# MDEV-28606 Server crashes in st_select_lex::add_table_to_list instead of error 1066: Not unique table/alias
1413+
#
1414+
create table t1 (i int) ;
1415+
insert into t1 values (1),(2),(3) ;
1416+
with cte1 as (select i from t1) select i from cte1 natural join cte1;
1417+
ERROR 42000: Not unique table/alias: 'cte1'
1418+
drop table t1;
1419+
#
14121420
# End of 10.2 tests
14131421
#

mysql-test/t/parser.test

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1432,6 +1432,15 @@ query_vertical show create function a;
14321432
drop function a;
14331433
set timestamp=default;
14341434

1435+
--echo #
1436+
--echo # MDEV-28606 Server crashes in st_select_lex::add_table_to_list instead of error 1066: Not unique table/alias
1437+
--echo #
1438+
create table t1 (i int) ;
1439+
insert into t1 values (1),(2),(3) ;
1440+
--error 1066
1441+
with cte1 as (select i from t1) select i from cte1 natural join cte1;
1442+
drop table t1;
1443+
14351444
--echo #
14361445
--echo # End of 10.2 tests
14371446
--echo #

sql/sql_parse.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8040,7 +8040,7 @@ TABLE_LIST *st_select_lex::add_table_to_list(THD *thd,
80408040
tables=tables->next_local)
80418041
{
80428042
if (!my_strcasecmp(table_alias_charset, alias_str, tables->alias) &&
8043-
!strcmp(ptr->db, tables->db))
8043+
!strcmp(safe_str(ptr->db), safe_str(tables->db)))
80448044
{
80458045
my_error(ER_NONUNIQ_TABLE, MYF(0), alias_str); /* purecov: tested */
80468046
DBUG_RETURN(0); /* purecov: tested */

0 commit comments

Comments
 (0)