Type:
Bug
Priority:
Major
Resolution:
Fixed
Affects Version/s:
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)
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
{"report":{"fcp":1640.9000005722046,"ttfb":681.3000001907349,"pageVisibility":"visible","entityId":21215,"key":"jira.project.issue.view-issue","isInitial":true,"threshold":1000,"elementTimings":{},"userDeviceMemory":8,"userDeviceProcessors":64,"apdex":0.5,"journeyId":"5dd37b31-0f94-4688-b413-c472363ee5c6","navigationType":0,"readyForUser":1734.6000003814697,"redirectCount":0,"resourceLoadedEnd":2027.3000001907349,"resourceLoadedStart":691.8000001907349,"resourceTiming":[{"duration":429.69999980926514,"initiatorType":"link","name":"https://jira.mariadb.org/s/2c21342762a6a02add1c328bed317ffd-CDN/lu2bv2/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/css/_super/batch.css","startTime":691.8000001907349,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":691.8000001907349,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":1121.5,"responseStart":0,"secureConnectionStart":0},{"duration":429.9000005722046,"initiatorType":"link","name":"https://jira.mariadb.org/s/7ebd35e77e471bc30ff0eba799ebc151-CDN/lu2bv2/820016/12ta74/2380add21a9a1006587582385952de73/_/download/contextbatch/css/jira.browse.project,project.issue.navigator,jira.view.issue,jira.general,jira.global,atl.general,-_super/batch.css?agile_global_admin_condition=true&jag=true&jira.create.linked.issue=true&slack-enabled=true","startTime":692,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":692,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":1121.9000005722046,"responseStart":0,"secureConnectionStart":0},{"duration":482.4000005722046,"initiatorType":"script","name":"https://jira.mariadb.org/s/e9b27a47da5fb0f74a35acd57e9847fb-CDN/lu2bv2/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/js/_super/batch.js?locale=en","startTime":692.1999998092651,"connectEnd":692.1999998092651,"connectStart":692.1999998092651,"domainLookupEnd":692.1999998092651,"domainLookupStart":692.1999998092651,"fetchStart":692.1999998092651,"redirectEnd":0,"redirectStart":0,"requestStart":692.1999998092651,"responseEnd":1174.6000003814697,"responseStart":1174.6000003814697,"secureConnectionStart":692.1999998092651},{"duration":532.5,"initiatorType":"script","name":"https://jira.mariadb.org/s/c32eb0da7ad9831253f8397e6cc26afd-CDN/lu2bv2/820016/12ta74/2380add21a9a1006587582385952de73/_/download/contextbatch/js/jira.browse.project,project.issue.navigator,jira.view.issue,jira.general,jira.global,atl.general,-_super/batch.js?agile_global_admin_condition=true&jag=true&jira.create.linked.issue=true&locale=en&slack-enabled=true","startTime":692.4000005722046,"connectEnd":692.4000005722046,"connectStart":692.4000005722046,"domainLookupEnd":692.4000005722046,"domainLookupStart":692.4000005722046,"fetchStart":692.4000005722046,"redirectEnd":0,"redirectStart":0,"requestStart":692.4000005722046,"responseEnd":1224.9000005722046,"responseStart":1224.9000005722046,"secureConnectionStart":692.4000005722046},{"duration":536.9000005722046,"initiatorType":"script","name":"https://jira.mariadb.org/s/bc0bcb146314416123c992714ee00ff7-CDN/lu2bv2/820016/12ta74/c92c0caa9a024ae85b0ebdbed7fb4bd7/_/download/contextbatch/js/atl.global,-_super/batch.js?locale=en","startTime":692.6999998092651,"connectEnd":692.6999998092651,"connectStart":692.6999998092651,"domainLookupEnd":692.6999998092651,"domainLookupStart":692.6999998092651,"fetchStart":692.6999998092651,"redirectEnd":0,"redirectStart":0,"requestStart":692.6999998092651,"responseEnd":1229.6000003814697,"responseStart":1229.6000003814697,"secureConnectionStart":692.6999998092651},{"duration":539.1000003814697,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2bv2/820016/12ta74/1.0/_/download/batch/jira.webresources:calendar-en/jira.webresources:calendar-en.js","startTime":692.8000001907349,"connectEnd":692.8000001907349,"connectStart":692.8000001907349,"domainLookupEnd":692.8000001907349,"domainLookupStart":692.8000001907349,"fetchStart":692.8000001907349,"redirectEnd":0,"redirectStart":0,"requestStart":692.8000001907349,"responseEnd":1231.9000005722046,"responseStart":1231.9000005722046,"secureConnectionStart":692.8000001907349},{"duration":541.1999998092651,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2bv2/820016/12ta74/1.0/_/download/batch/jira.webresources:calendar-localisation-moment/jira.webresources:calendar-localisation-moment.js","startTime":693.1000003814697,"connectEnd":693.1000003814697,"connectStart":693.1000003814697,"domainLookupEnd":693.1000003814697,"domainLookupStart":693.1000003814697,"fetchStart":693.1000003814697,"redirectEnd":0,"redirectStart":0,"requestStart":693.1000003814697,"responseEnd":1234.3000001907349,"responseStart":1234.3000001907349,"secureConnectionStart":693.1000003814697},{"duration":627.5,"initiatorType":"link","name":"https://jira.mariadb.org/s/b04b06a02d1959df322d9cded3aeecc1-CDN/lu2bv2/820016/12ta74/a2ff6aa845ffc9a1d22fe23d9ee791fc/_/download/contextbatch/css/jira.global.look-and-feel,-_super/batch.css","startTime":693.1999998092651,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":693.1999998092651,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":1320.6999998092651,"responseStart":0,"secureConnectionStart":0},{"duration":543.1999998092651,"initiatorType":"script","name":"https://jira.mariadb.org/rest/api/1.0/shortcuts/820016/47140b6e0a9bc2e4913da06536125810/shortcuts.js?context=issuenavigation&context=issueaction","startTime":693.4000005722046,"connectEnd":693.4000005722046,"connectStart":693.4000005722046,"domainLookupEnd":693.4000005722046,"domainLookupStart":693.4000005722046,"fetchStart":693.4000005722046,"redirectEnd":0,"redirectStart":0,"requestStart":693.4000005722046,"responseEnd":1236.6000003814697,"responseStart":1236.6000003814697,"secureConnectionStart":693.4000005722046},{"duration":627.3000001907349,"initiatorType":"link","name":"https://jira.mariadb.org/s/3ac36323ba5e4eb0af2aa7ac7211b4bb-CDN/lu2bv2/820016/12ta74/d176f0986478cc64f24226b3d20c140d/_/download/contextbatch/css/com.atlassian.jira.projects.sidebar.init,-_super,-project.issue.navigator,-jira.view.issue/batch.css?jira.create.linked.issue=true","startTime":693.5,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":693.5,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":1320.8000001907349,"responseStart":0,"secureConnectionStart":0},{"duration":545.4000005722046,"initiatorType":"script","name":"https://jira.mariadb.org/s/719848dd97ebe0663199f49a3936487a-CDN/lu2bv2/820016/12ta74/d176f0986478cc64f24226b3d20c140d/_/download/contextbatch/js/com.atlassian.jira.projects.sidebar.init,-_super,-project.issue.navigator,-jira.view.issue/batch.js?jira.create.linked.issue=true&locale=en","startTime":693.6999998092651,"connectEnd":693.6999998092651,"connectStart":693.6999998092651,"domainLookupEnd":693.6999998092651,"domainLookupStart":693.6999998092651,"fetchStart":693.6999998092651,"redirectEnd":0,"redirectStart":0,"requestStart":693.6999998092651,"responseEnd":1239.1000003814697,"responseStart":1239.1000003814697,"secureConnectionStart":693.6999998092651},{"duration":959,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2bv2/820016/12ta74/1.0/_/download/batch/jira.webresources:bigpipe-js/jira.webresources:bigpipe-js.js","startTime":695.8000001907349,"connectEnd":695.8000001907349,"connectStart":695.8000001907349,"domainLookupEnd":695.8000001907349,"domainLookupStart":695.8000001907349,"fetchStart":695.8000001907349,"redirectEnd":0,"redirectStart":0,"requestStart":695.8000001907349,"responseEnd":1654.8000001907349,"responseStart":1654.8000001907349,"secureConnectionStart":695.8000001907349},{"duration":1331.3999996185303,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2bv2/820016/12ta74/1.0/_/download/batch/jira.webresources:bigpipe-init/jira.webresources:bigpipe-init.js","startTime":695.9000005722046,"connectEnd":695.9000005722046,"connectStart":695.9000005722046,"domainLookupEnd":695.9000005722046,"domainLookupStart":695.9000005722046,"fetchStart":695.9000005722046,"redirectEnd":0,"redirectStart":0,"requestStart":695.9000005722046,"responseEnd":2027.3000001907349,"responseStart":2027.1999998092651,"secureConnectionStart":695.9000005722046},{"duration":324.5,"initiatorType":"xmlhttprequest","name":"https://jira.mariadb.org/rest/webResources/1.0/resources","startTime":1333,"connectEnd":1333,"connectStart":1333,"domainLookupEnd":1333,"domainLookupStart":1333,"fetchStart":1333,"redirectEnd":0,"redirectStart":0,"requestStart":1333,"responseEnd":1657.5,"responseStart":1657.5,"secureConnectionStart":1333},{"duration":437.80000019073486,"initiatorType":"script","name":"https://www.google-analytics.com/analytics.js","startTime":1628.1999998092651,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":1628.1999998092651,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":2066,"responseStart":0,"secureConnectionStart":0}],"fetchStart":0,"domainLookupStart":0,"domainLookupEnd":0,"connectStart":0,"connectEnd":0,"requestStart":102,"responseStart":681,"responseEnd":687,"domLoading":688,"domInteractive":2066,"domContentLoadedEventStart":2066,"domContentLoadedEventEnd":2110,"domComplete":2956,"loadEventStart":2956,"loadEventEnd":2958,"userAgent":"Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)","marks":[{"name":"bigPipe.sidebar-id.start","time":2033.9000005722046},{"name":"bigPipe.sidebar-id.end","time":2034.6999998092651},{"name":"bigPipe.activity-panel-pipe-id.start","time":2034.9000005722046},{"name":"bigPipe.activity-panel-pipe-id.end","time":2037.1999998092651},{"name":"activityTabFullyLoaded","time":2118.5}],"measures":[],"correlationId":"8027b1bc9a8f80","effectiveType":"4g","downlink":10,"rtt":0,"serverDuration":511,"dbReadsTimeInMs":19,"dbConnsTimeInMs":29,"applicationHash":"9d11dbea5f4be3d4cc21f03a88dd11d8c8687422","experiments":[]}}