mirror of
https://github.com/MariaDB/server.git
synced 2026-10-23 18:49:29 +03:00
MDEV-36057: Assertion failure on 2nd execution of parameterized PS
Followup to fix for MDEV-35318: In Prepared_statement::execute_loop(),
if we enter this function with lex->needs_reprepare=true, we need to
re-prepare the statement.
We also need to call set_parameters() to get PS parameter values. We
failed to do this and that's the bug.
Note that we need to also handle the other reprepare scenario: when
we get into Prepared_statement::execute_loop(), call set_parameters()
and then hit a "DDL was changed" error with reprepare_observer,
we should NOT call set_parameters() again.
The parameters have already been transferred to the reprepared statement
in Prepared_statement::reprepare()|swap_parameter_array().
(cherry picked from commit 80067a69fe)
This commit is contained in:
committed by
Khaled Riyad
parent
0c9a924040
commit
3d1b0270d1
@@ -2127,4 +2127,16 @@ Warnings:
|
||||
Note 1051 Unknown table 'test.tmp'
|
||||
DROP PROCEDURE sp1;
|
||||
DROP TABLE t;
|
||||
#
|
||||
# MDEV-36057: Assertion failure or unexpected outcome upon 2nd execution
|
||||
# of parameterized PS (continues the above)
|
||||
#
|
||||
CREATE TABLE t (a INT);
|
||||
INSERT INTO t VALUES (1),(2);
|
||||
PREPARE stmt FROM 'UPDATE t SET a = 3 WHERE a IN (SELECT "" UNION SELECT ?)';
|
||||
EXECUTE stmt USING 4;
|
||||
ERROR 22007: Truncated incorrect DECIMAL value: ''
|
||||
EXECUTE stmt USING 4;
|
||||
ERROR 22007: Truncated incorrect DECIMAL value: ''
|
||||
DROP TABLE t;
|
||||
# End of 11.4 tests
|
||||
|
||||
@@ -2007,4 +2007,18 @@ call sp1();
|
||||
DROP PROCEDURE sp1;
|
||||
DROP TABLE t;
|
||||
|
||||
--echo #
|
||||
--echo # MDEV-36057: Assertion failure or unexpected outcome upon 2nd execution
|
||||
--echo # of parameterized PS (continues the above)
|
||||
--echo #
|
||||
CREATE TABLE t (a INT);
|
||||
INSERT INTO t VALUES (1),(2);
|
||||
|
||||
PREPARE stmt FROM 'UPDATE t SET a = 3 WHERE a IN (SELECT "" UNION SELECT ?)';
|
||||
--error ER_TRUNCATED_WRONG_VALUE
|
||||
EXECUTE stmt USING 4;
|
||||
--error ER_TRUNCATED_WRONG_VALUE
|
||||
EXECUTE stmt USING 4;
|
||||
DROP TABLE t;
|
||||
|
||||
--echo # End of 11.4 tests
|
||||
|
||||
@@ -4459,6 +4459,7 @@ Prepared_statement::execute_loop(String *expanded_query,
|
||||
Reprepare_observer reprepare_observer;
|
||||
bool error;
|
||||
iterations= FALSE;
|
||||
bool params_are_set= false;
|
||||
|
||||
/*
|
||||
- In mysql_sql_stmt_execute() we hide all "external" Items
|
||||
@@ -4484,8 +4485,10 @@ Prepared_statement::execute_loop(String *expanded_query,
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if (set_parameters(expanded_query, packet, packet_end))
|
||||
reexecute:
|
||||
if (!params_are_set && set_parameters(expanded_query, packet, packet_end))
|
||||
return TRUE;
|
||||
params_are_set= true;
|
||||
#ifdef WITH_WSREP
|
||||
if (thd->wsrep_delayed_BF_abort)
|
||||
{
|
||||
@@ -4493,7 +4496,7 @@ Prepared_statement::execute_loop(String *expanded_query,
|
||||
return TRUE;
|
||||
}
|
||||
#endif /* WITH_WSREP */
|
||||
reexecute:
|
||||
|
||||
// Make sure that reprepare() did not create any new Items.
|
||||
DBUG_ASSERT(thd->free_list == NULL);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user