[MDEV-774] LP:948583 - Stored procedure doesn't not take into account ALTER TABLE, causes wrong result or replication abort Created: 2012-03-07 Updated: 2023-11-28 |
|
| Status: | Confirmed |
| Project: | MariaDB Server |
| Component/s: | Data Definition - Alter Table |
| Affects Version/s: | 5.3.9, 5.3.12, 5.5, 10.0, 10.3, 10.4, 10.5, 10.6, 10.7, 10.8, 10.9, 10.10 |
| Fix Version/s: | 10.4, 10.5, 10.6 |
| Type: | Bug | Priority: | Major |
| Reporter: | Elena Stepanova | Assignee: | Dmitry Shulga |
| Resolution: | Unresolved | Votes: | 2 |
| Labels: | Launchpad, upstream-fixed, verified | ||
| Attachments: |
|
||||||||||||||||||||||||||||||||||||
| Issue Links: |
|
||||||||||||||||||||||||||||||||||||
| 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
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:
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)
Test case 2 (replication failure)
|
| Comments |
| Comment by Rasmus Johansson (Inactive) [ 2012-03-12 ] | ||||||||||||||||||||||||||
|
Launchpad bug id: 948583 | ||||||||||||||||||||||||||
| Comment by Sergei Golubchik [ 2013-01-01 ] | ||||||||||||||||||||||||||
|
fixed in mysql-5.6.6 | ||||||||||||||||||||||||||
| Comment by Elena Stepanova [ 2013-05-08 ] | ||||||||||||||||||||||||||
|
The upstream bug was fixed in 5.6.6. I think it's okay to have the fix in 10.0 only (after the fix from 5.6 is merged in), so I'm removing 5.x from the 'Fix versions' list. | ||||||||||||||||||||||||||
| Comment by Elena Stepanova [ 2014-11-09 ] | ||||||||||||||||||||||||||
|
Still reproducible on current 10.0 (10.0.14+, revno 4471). Upstream bug was fixed in 5.6.6, apparently as a part of http://dev.mysql.com/worklog/task/?id=4179
It might be too big to get it in 10.0, but maybe 10.1 is okay, since it's not a feature as such, but a big fat bugfix. | ||||||||||||||||||||||||||
| Comment by Elena Stepanova [ 2016-04-14 ] | ||||||||||||||||||||||||||
|
serg, some time ago you unset 'Fix version/s' on this report, was there a reason for that – should we close it as 'Won't fix', or target for 10.2, or...? | ||||||||||||||||||||||||||
| Comment by Sergei Golubchik [ 2016-04-15 ] | ||||||||||||||||||||||||||
|
We'll fix it, but 10.2 is unlikely, that's why I've unset the version. | ||||||||||||||||||||||||||
| Comment by Alexander Barkov [ 2017-03-02 ] | ||||||||||||||||||||||||||
|
The same problem is repeatable with cursors:
The above script returns:
So far so good. Now I add a new column to the table and call the procedure again
Oops. It returns the result, like if the table still had 2 columns. | ||||||||||||||||||||||||||
| Comment by Hartmut Holzgraefe [ 2018-01-27 ] | ||||||||||||||||||||||||||
|
See also: http://alexandernozdrin.blogspot.de/2012/09/mysql-56-handling-metadata-changes-in.html |