From efa311ab8eaa40b0d27691bd70a2ccab343d5477 Mon Sep 17 00:00:00 2001 From: Dmitry Shulga Date: Sun, 18 Jul 2021 21:08:23 +0700 Subject: [PATCH] MDEV-26147: The test main.sp-row fails in case it is run in PS mode In case a stored procedure is invoked in PS mode with argument of type ROW() like the following one: CALL p1(ROW(10,20)) such statement fails with the error ER_OPERAND_COLUMNS (1241): Operand should contain 1 column(s) The reason of emitting the error is that wrong method was invoked on fixing an item corresponding to an argument of stored procedure - the method fix_fields_if_needed_for_scalar() was called instead of fix_fields_if_needed() that should be called. --- mysql-test/main/ps.result | 14 ++++++++++++++ mysql-test/main/ps.test | 16 ++++++++++++++++ sql/sql_prepare.cc | 2 +- 3 files changed, 31 insertions(+), 1 deletion(-) diff --git a/mysql-test/main/ps.result b/mysql-test/main/ps.result index e1f8d03a156..051f40cfd78 100644 --- a/mysql-test/main/ps.result +++ b/mysql-test/main/ps.result @@ -5553,3 +5553,17 @@ DEALLOCATE PREPARE stmt; DROP TABLE t1, t2, t3; # End of 10.2 tests # +# +# MDEV-26147: The test main.sp-row fails in case it is run in PS mode +# +CREATE PROCEDURE p1(a ROW(a INT,b INT)) +BEGIN +SELECT a.a, a.b; +END; +$$ +PREPARE stmt FROM 'CALL p1(ROW(10, 20))'; +EXECUTE stmt; +a.a a.b +10 20 +DEALLOCATE PREPARE stmt; +DROP PROCEDURE p1; diff --git a/mysql-test/main/ps.test b/mysql-test/main/ps.test index 51531d4bb24..6920051b138 100644 --- a/mysql-test/main/ps.test +++ b/mysql-test/main/ps.test @@ -5000,3 +5000,19 @@ DROP TABLE t1, t2, t3; --echo # End of 10.2 tests --echo # + +--echo # +--echo # MDEV-26147: The test main.sp-row fails in case it is run in PS mode +--echo # +DELIMITER $$; +CREATE PROCEDURE p1(a ROW(a INT,b INT)) +BEGIN + SELECT a.a, a.b; +END; +$$ +DELIMITER ;$$ +PREPARE stmt FROM 'CALL p1(ROW(10, 20))'; +EXECUTE stmt; +DEALLOCATE PREPARE stmt; + +DROP PROCEDURE p1; diff --git a/sql/sql_prepare.cc b/sql/sql_prepare.cc index ea867e7b63f..ae070ec8db0 100644 --- a/sql/sql_prepare.cc +++ b/sql/sql_prepare.cc @@ -1741,7 +1741,7 @@ static bool mysql_test_call_fields(Prepared_statement *stmt, while ((item= it++)) { - if (item->fix_fields_if_needed_for_scalar(thd, it.ref())) + if (item->fix_fields_if_needed(thd, it.ref())) goto err; } DBUG_RETURN(FALSE);