MDEV-36838 Oracle outer join syntax (+): server crash on derived tables

Find TABLE_LIST via Field.
This commit is contained in:
Oleksandr Byelkin 2025-05-20 13:57:46 +02:00 committed by Sergei Golubchik
parent ced8220532
commit fd1362ef5b
3 changed files with 77 additions and 2 deletions

View File

@ -649,3 +649,39 @@ ERROR 42000: You have an error in your SQL syntax; check the manual that corresp
set SQL_MODE= oracle;
drop view v1;
drop table t1,t2;
#
# MDEV-36830: Oracle outer join syntax (+): outer join not converted to inner
#
create table t1 (
a int not null,
b int not null
);
insert into t1 select seq,seq from seq_1_to_10;
create table t2 (
a int not null,
b int not null
);
insert into t2 select seq,seq from seq_1_to_3;
# Must be converted to inner join:
explain extended
select * from t1, t2
where
t1.a=1 and
t1.b=t2.b(+) and
t2.b=1;
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 10 100.00 Using where
1 SIMPLE t2 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (flat, BNL join)
Warnings:
Note 1003 select "test"."t1"."a" AS "a","test"."t1"."b" AS "b","test"."t2"."a" AS "a","test"."t2"."b" AS "b" from "test"."t1" left join "test"."t2" on("test"."t1"."b" = 1) where "test"."t1"."a" = 1 and "test"."t2"."b" = 1
drop table t1,t2;
#
# MDEV-36838: Oracle outer join syntax (+): server crash on derived tables
#
select a.a
from (select 1 as a) a,
(select 2 as b) b
where a.a=b.b(+);
a
1
# End of 12.0 tests

View File

@ -436,3 +436,42 @@ set SQL_MODE= oracle;
drop view v1;
drop table t1,t2;
--echo #
--echo # MDEV-36830: Oracle outer join syntax (+): outer join not converted to inner
--echo #
--source include/have_sequence.inc
create table t1 (
a int not null,
b int not null
);
insert into t1 select seq,seq from seq_1_to_10;
create table t2 (
a int not null,
b int not null
);
insert into t2 select seq,seq from seq_1_to_3;
--echo # Must be converted to inner join:
explain extended
select * from t1, t2
where
t1.a=1 and
t1.b=t2.b(+) and
t2.b=1;
drop table t1,t2;
--echo #
--echo # MDEV-36838: Oracle outer join syntax (+): server crash on derived tables
--echo #
select a.a
from (select 1 as a) a,
(select 2 as b) b
where a.a=b.b(+);
--echo # End of 12.0 tests

View File

@ -10258,9 +10258,9 @@ err:
bool Item_field::ora_join_processor(void *arg)
{
DBUG_ASSERT(cached_table);
DBUG_ASSERT(field->table->pos_in_table_list);
return Item_ident::ora_join_add_table_ref((ora_join_processor_param *)arg,
cached_table);
field->table->pos_in_table_list);
}