diff --git a/mysql-test/main/sp.result b/mysql-test/main/sp.result index 567597383bb..2f733107e8a 100644 --- a/mysql-test/main/sp.result +++ b/mysql-test/main/sp.result @@ -8960,5 +8960,20 @@ DROP FUNCTION f1; DROP FUNCTION f2; DROP FUNCTION f3; DROP VIEW v1; +# +# MDEV-33270: Call of SP invoking another SP with a parameter +# requiring type conversion +# +SET NAMES latin1; +CREATE PROCEDURE p1 (a text) BEGIN SELECT a; END | +CREATE PROCEDURE p2 () CALL p1(concat('x',_utf8'x')) | +CALL p2(); +a +xx +CALL p2(); +a +xx +DROP PROCEDURE p1; +DROP PROCEDURE p2; # End of 10.4 tests # diff --git a/mysql-test/main/sp.test b/mysql-test/main/sp.test index c11ea23080b..50d9a611db9 100644 --- a/mysql-test/main/sp.test +++ b/mysql-test/main/sp.test @@ -10567,5 +10567,25 @@ DROP FUNCTION f2; DROP FUNCTION f3; DROP VIEW v1; +--echo # +--echo # MDEV-33270: Call of SP invoking another SP with a parameter +--echo # requiring type conversion +--echo # + +SET NAMES latin1; + +--delimiter | + +CREATE PROCEDURE p1 (a text) BEGIN SELECT a; END | +CREATE PROCEDURE p2 () CALL p1(concat('x',_utf8'x')) | + +--delimiter ; + +CALL p2(); +CALL p2(); + +DROP PROCEDURE p1; +DROP PROCEDURE p2; + --echo # End of 10.4 tests --echo # diff --git a/sql/item.cc b/sql/item.cc index 6d30d63bc11..04b689f51af 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -2586,7 +2586,10 @@ bool Type_std_attributes::agg_item_set_converter(const DTCollation &coll, return TRUE; if (!thd->stmt_arena->is_conventional() && - thd->lex->current_select->first_cond_optimization) + ((!thd->lex->current_select && + (thd->stmt_arena->is_stmt_prepare_or_first_sp_execute() || + thd->stmt_arena->is_stmt_prepare_or_first_stmt_execute())) || + thd->lex->current_select->first_cond_optimization)) { Query_arena *arena, backup; arena= thd->activate_stmt_arena_if_needed(&backup);