1
0
mirror of https://github.com/MariaDB/server.git synced 2025-08-08 11:22:35 +03:00

MDEV-36179 Assertion `0' failed in virtual bool Type_handler_row::Item_save_in_value(THD*, Item*, st_value*) const

sp_head::execute_procedure() and sp_head::execute_function() did not
check that Item_param could be passed as an actual parameter to a ROW type
formal parameter of a stored routine. Example:

CREATE PROCEDURE p0(OUT a ROW(a INT,b INT)) ...;
PREPARE s0 'CALL p0(?)';
EXECUTE p0 USING @a;

In case of passing a user variable as an OUT parameter it led to
a crash after executing routine instructions, when copying formal
OUT parameters to the bound actual parameters.

Fix:
Check cases when Item_param is being bound to a ROW type formal parameter.
Raise an error if so. The new check is done for all parameter modes:
IN, OUT, INOUT, for a consistent error message.

The new check is done before executing the routine instructions.
This commit is contained in:
Alexander Barkov
2025-03-19 16:05:35 +04:00
parent 1756b0f37d
commit 2ae721f2ad
3 changed files with 139 additions and 0 deletions

View File

@@ -2313,3 +2313,44 @@ SELECT 1 LIKE 2 ESCAPE a;
END;
$$
ERROR 21000: Operand should contain 1 column(s)
# Start of 10.6 tests
#
# MDEV-36179 Assertion `0' failed in virtual bool Type_handler_row::Item_save_in_value(THD*, Item*, st_value*) const
#
CREATE PROCEDURE p0 (IN a ROW(a INT,b INT))
BEGIN
SET a=ROW(0,0);
END;
/
PREPARE s0 FROM 'CALL p0(?)';
EXECUTE s0 USING @a;
ERROR HY000: Illegal parameter data type row for operation 'EXECUTE ... USING ?'
DROP PROCEDURE p0;
CREATE PROCEDURE p0 (INOUT a ROW(a INT,b INT))
BEGIN
SET a=ROW(0,0);
END;
/
PREPARE s0 FROM 'CALL p0(?)';
EXECUTE s0 USING @a;
ERROR HY000: Illegal parameter data type row for operation 'EXECUTE ... USING ?'
DROP PROCEDURE p0;
CREATE PROCEDURE p0 (OUT a ROW(a INT,b INT))
BEGIN
SET a=ROW(0,0);
END;
/
PREPARE s0 FROM 'CALL p0(?)';
EXECUTE s0 USING @a;
ERROR HY000: Illegal parameter data type row for operation 'EXECUTE ... USING ?'
DROP PROCEDURE p0;
CREATE FUNCTION f0(a ROW(a INT,b INT)) RETURNS BOOLEAN
BEGIN
RETURN FALSE;
END;
/
PREPARE s0 FROM 'SELECT f0(?)';
EXECUTE s0 USING @a;
ERROR HY000: Illegal parameter data type row for operation 'EXECUTE ... USING ?'
DROP FUNCTION f0;
# End of 10.6 tests