Details
-
Bug
-
Status: Closed (View Workflow)
-
Major
-
Resolution: Fixed
-
5.3.9, 5.3.12, 5.5(EOL), 10.0(EOL), 10.3(EOL), 10.4(EOL), 10.5, 10.6, 10.7(EOL), 10.8(EOL), 10.9(EOL), 10.10(EOL)
Description
The problem is reproducible on all of MariaDB 5.1, 5.2, 5.3, 5.5, MySQL 5.1, 5.5, 5.6, and has also been filed as http://bugs.mysql.com/bug.php?id=64574.
A stored procedure or a trigger, having been executed once, on the second run might not take into account changes in a table structure, which causes a wrong result on the server where it is run, and also might cause SQL slave abort if the master wrongly returns OK after such a change, while the slave throws the expected error.
Below are two test cases. The first one is for the basic scenario: the initial execution of the stored procedure ends with the expected error, then the table structure gets fixed, but the procedure fails anyway, with
query 'CALL p()' failed: 1054: Unknown column 'test.t2.b' in 'field list'
|
The second test case is a reversed scenario – first execution of the procedure runs fine (correctly), then the table structure is altered, and the second execution must fail, but it does not on master; instead, the statement is written in the binlog with error code 0 and later fails on slave, thus causing a replication failure:
1136 Error 'Column count doesn't match value count at row 1' on query.
|
I found the ancient bug http://bugs.mysql.com/bug.php?id=6120 which looks similar, only for views, but it was fixed ages ago.
Test case 1 (wrong result - the last procedure call fails while it shouldn't)
CREATE TABLE t1 (a INT); |
CREATE TABLE t2 (b INT, c INT); |
|
--delimiter |
|
CREATE PROCEDURE p() |
BEGIN
|
INSERT INTO t1 SELECT * FROM t2; |
END | |
--delimiter ;
|
|
--error ER_WRONG_VALUE_COUNT_ON_ROW
|
CALL p();
|
ALTER TABLE t2 DROP COLUMN b; |
CALL p();
|
|
Test case 2 (replication failure)
--source include/master-slave.inc
|
CREATE TABLE t1 (a INT); |
CREATE TABLE t2 (b INT); |
|
--delimiter |
|
CREATE PROCEDURE p() |
BEGIN
|
INSERT INTO t1 SELECT * FROM t2; |
END | |
--delimiter ;
|
|
CALL p();
|
ALTER TABLE t2 ADD COLUMN c INT; |
CALL p();
|
--sync_slave_with_master
|
|
Attachments
Issue Links
- duplicates
-
MDEV-11652 SP with cursors does not work well in combination with ALTER TABLE
- Closed
- is duplicated by
-
MDEV-15097 Stored procedures are unaware of metadata changes
- Closed
- is part of
-
MDEV-5242 merge 5.6 bugfixes into 10.0
- Open
-
MDEV-5816 MySQL WL#4179 - Stored programs: validation of stored program statements
- Closed
- relates to
-
MDEV-6488 Autodiscover + CONNECT + OR REPLACE
- Closed
-
MDEV-12166 PROCEDURE using a SELECT from a temporary table does not work well
- Closed
-
MDEV-21234 Server crashes in in setup_on_expr upon 3rd execution of SP
- Closed
- links to