diff --git a/mysql-test/suite/compat/oracle/r/ora_outer_join.result b/mysql-test/suite/compat/oracle/r/ora_outer_join.result index 13a71cd03e5..c8e22b3e176 100644 --- a/mysql-test/suite/compat/oracle/r/ora_outer_join.result +++ b/mysql-test/suite/compat/oracle/r/ora_outer_join.result @@ -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 diff --git a/mysql-test/suite/compat/oracle/t/ora_outer_join.test b/mysql-test/suite/compat/oracle/t/ora_outer_join.test index 27783a9681b..e4a9f102405 100644 --- a/mysql-test/suite/compat/oracle/t/ora_outer_join.test +++ b/mysql-test/suite/compat/oracle/t/ora_outer_join.test @@ -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 diff --git a/sql/item.cc b/sql/item.cc index 50b0ac6534a..9e13669992d 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -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); }