Using SELECT INTO local routine variable, value is assigned to two distinct variables.
Test cast to reproduce issue;
Two tables with one row with different values
CREATE TABLE `test`.`A`(
|
`idA` BIGINT NOT NULL AUTO_INCREMENT,
|
`messageA` MEDIUMBLOB,
|
PRIMARY KEY (`idA`)
|
);
|
|
CREATE TABLE `test`.`B`(
|
`idB` BIGINT NOT NULL AUTO_INCREMENT,
|
`messageB` MEDIUMBLOB,
|
PRIMARY KEY (`idB`)
|
);
|
|
INSERT INTO A(messageA) VALUES (COMPRESS('messageA'));
|
INSERT INTO B(messageB) VALUES (COMPRESS('messageB'));
|
|
Stored procedure:
DELIMITER $$
|
|
CREATE PROCEDURE `procC`()
|
BEGIN
|
DECLARE pA MEDIUMBLOB;
|
DECLARE pB MEDIUMBLOB;
|
|
SElect messageA
|
into pA
|
FROM A;
|
|
SELECT messageB
|
into pB
|
from B;
|
|
select UNCOMPRESS(pA), UNCOMPRESS(pB);
|
END$$
|
|
DELIMITER ;
|
|
Calling procedure:
Expected result:
Result:
{"report":{"fcp":790.4000000059605,"ttfb":189.1000000089407,"pageVisibility":"visible","entityId":57012,"key":"jira.project.issue.view-issue","isInitial":true,"threshold":1000,"elementTimings":{},"userDeviceMemory":8,"userDeviceProcessors":64,"apdex":1,"journeyId":"43681ebd-0e52-41bb-868c-64785cefca8d","navigationType":0,"readyForUser":869.2000000029802,"redirectCount":0,"resourceLoadedEnd":899.2000000029802,"resourceLoadedStart":195.20000000298023,"resourceTiming":[{"duration":79.5,"initiatorType":"link","name":"https://jira.mariadb.org/s/2c21342762a6a02add1c328bed317ffd-CDN/lu2cib/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/css/_super/batch.css","startTime":195.20000000298023,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":195.20000000298023,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":274.70000000298023,"responseStart":0,"secureConnectionStart":0},{"duration":79.5,"initiatorType":"link","name":"https://jira.mariadb.org/s/7ebd35e77e471bc30ff0eba799ebc151-CDN/lu2cib/820016/12ta74/494e4c556ecbb29f90a3d3b4f09cb99c/_/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&whisper-enabled=true","startTime":195.5,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":195.5,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":275,"responseStart":0,"secureConnectionStart":0},{"duration":88.70000000298023,"initiatorType":"script","name":"https://jira.mariadb.org/s/0917945aaa57108d00c5076fea35e069-CDN/lu2cib/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/js/_super/batch.js?locale=en","startTime":195.70000000298023,"connectEnd":195.70000000298023,"connectStart":195.70000000298023,"domainLookupEnd":195.70000000298023,"domainLookupStart":195.70000000298023,"fetchStart":195.70000000298023,"redirectEnd":0,"redirectStart":0,"requestStart":195.70000000298023,"responseEnd":284.40000000596046,"responseStart":284.40000000596046,"secureConnectionStart":195.70000000298023},{"duration":162.6000000089407,"initiatorType":"script","name":"https://jira.mariadb.org/s/2d8175ec2fa4c816e8023260bd8c1786-CDN/lu2cib/820016/12ta74/494e4c556ecbb29f90a3d3b4f09cb99c/_/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&whisper-enabled=true","startTime":195.79999999701977,"connectEnd":195.79999999701977,"connectStart":195.79999999701977,"domainLookupEnd":195.79999999701977,"domainLookupStart":195.79999999701977,"fetchStart":195.79999999701977,"redirectEnd":0,"redirectStart":0,"requestStart":195.79999999701977,"responseEnd":358.40000000596046,"responseStart":358.40000000596046,"secureConnectionStart":195.79999999701977},{"duration":166.6000000089407,"initiatorType":"script","name":"https://jira.mariadb.org/s/a9324d6758d385eb45c462685ad88f1d-CDN/lu2cib/820016/12ta74/c92c0caa9a024ae85b0ebdbed7fb4bd7/_/download/contextbatch/js/atl.global,-_super/batch.js?locale=en","startTime":196,"connectEnd":196,"connectStart":196,"domainLookupEnd":196,"domainLookupStart":196,"fetchStart":196,"redirectEnd":0,"redirectStart":0,"requestStart":196,"responseEnd":362.6000000089407,"responseStart":362.6000000089407,"secureConnectionStart":196},{"duration":167.09999999403954,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2cib/820016/12ta74/1.0/_/download/batch/jira.webresources:calendar-en/jira.webresources:calendar-en.js","startTime":196.20000000298023,"connectEnd":196.20000000298023,"connectStart":196.20000000298023,"domainLookupEnd":196.20000000298023,"domainLookupStart":196.20000000298023,"fetchStart":196.20000000298023,"redirectEnd":0,"redirectStart":0,"requestStart":196.20000000298023,"responseEnd":363.29999999701977,"responseStart":363.29999999701977,"secureConnectionStart":196.20000000298023},{"duration":167.70000000298023,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2cib/820016/12ta74/1.0/_/download/batch/jira.webresources:calendar-localisation-moment/jira.webresources:calendar-localisation-moment.js","startTime":196.40000000596046,"connectEnd":196.40000000596046,"connectStart":196.40000000596046,"domainLookupEnd":196.40000000596046,"domainLookupStart":196.40000000596046,"fetchStart":196.40000000596046,"redirectEnd":0,"redirectStart":0,"requestStart":196.40000000596046,"responseEnd":364.1000000089407,"responseStart":364.1000000089407,"secureConnectionStart":196.40000000596046},{"duration":229.79999999701977,"initiatorType":"link","name":"https://jira.mariadb.org/s/b04b06a02d1959df322d9cded3aeecc1-CDN/lu2cib/820016/12ta74/a2ff6aa845ffc9a1d22fe23d9ee791fc/_/download/contextbatch/css/jira.global.look-and-feel,-_super/batch.css","startTime":196.6000000089407,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":196.6000000089407,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":426.40000000596046,"responseStart":0,"secureConnectionStart":0},{"duration":168.20000000298023,"initiatorType":"script","name":"https://jira.mariadb.org/rest/api/1.0/shortcuts/820016/47140b6e0a9bc2e4913da06536125810/shortcuts.js?context=issuenavigation&context=issueaction","startTime":196.70000000298023,"connectEnd":196.70000000298023,"connectStart":196.70000000298023,"domainLookupEnd":196.70000000298023,"domainLookupStart":196.70000000298023,"fetchStart":196.70000000298023,"redirectEnd":0,"redirectStart":0,"requestStart":196.70000000298023,"responseEnd":364.90000000596046,"responseStart":364.90000000596046,"secureConnectionStart":196.70000000298023},{"duration":229.70000000298023,"initiatorType":"link","name":"https://jira.mariadb.org/s/3ac36323ba5e4eb0af2aa7ac7211b4bb-CDN/lu2cib/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":196.90000000596046,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":196.90000000596046,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":426.6000000089407,"responseStart":0,"secureConnectionStart":0},{"duration":168.69999998807907,"initiatorType":"script","name":"https://jira.mariadb.org/s/5d5e8fe91fbc506585e83ea3b62ccc4b-CDN/lu2cib/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":197.1000000089407,"connectEnd":197.1000000089407,"connectStart":197.1000000089407,"domainLookupEnd":197.1000000089407,"domainLookupStart":197.1000000089407,"fetchStart":197.1000000089407,"redirectEnd":0,"redirectStart":0,"requestStart":197.1000000089407,"responseEnd":365.79999999701977,"responseStart":365.79999999701977,"secureConnectionStart":197.1000000089407},{"duration":574.2999999970198,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2cib/820016/12ta74/1.0/_/download/batch/jira.webresources:bigpipe-js/jira.webresources:bigpipe-js.js","startTime":198,"connectEnd":198,"connectStart":198,"domainLookupEnd":198,"domainLookupStart":198,"fetchStart":198,"redirectEnd":0,"redirectStart":0,"requestStart":198,"responseEnd":772.2999999970198,"responseStart":772.2999999970198,"secureConnectionStart":198},{"duration":571.1000000089407,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2cib/820016/12ta74/1.0/_/download/batch/jira.webresources:bigpipe-init/jira.webresources:bigpipe-init.js","startTime":202.29999999701977,"connectEnd":202.29999999701977,"connectStart":202.29999999701977,"domainLookupEnd":202.29999999701977,"domainLookupStart":202.29999999701977,"fetchStart":202.29999999701977,"redirectEnd":0,"redirectStart":0,"requestStart":202.29999999701977,"responseEnd":773.4000000059605,"responseStart":773.4000000059605,"secureConnectionStart":202.29999999701977},{"duration":214.40000000596046,"initiatorType":"xmlhttprequest","name":"https://jira.mariadb.org/rest/webResources/1.0/resources","startTime":437.29999999701977,"connectEnd":437.29999999701977,"connectStart":437.29999999701977,"domainLookupEnd":437.29999999701977,"domainLookupStart":437.29999999701977,"fetchStart":437.29999999701977,"redirectEnd":0,"redirectStart":0,"requestStart":437.29999999701977,"responseEnd":651.7000000029802,"responseStart":651.7000000029802,"secureConnectionStart":437.29999999701977},{"duration":204,"initiatorType":"link","name":"https://jira.mariadb.org/s/d5715adaadd168a9002b108b2b039b50-CDN/lu2cib/820016/12ta74/be4b45e9cec53099498fa61c8b7acba4/_/download/contextbatch/css/jira.project.sidebar,-_super,-project.issue.navigator,-jira.general,-jira.browse.project,-jira.view.issue,-jira.global,-atl.general,-com.atlassian.jira.projects.sidebar.init/batch.css?agile_global_admin_condition=true&jag=true&jira.create.linked.issue=true&slack-enabled=true&whisper-enabled=true","startTime":695.1000000089407,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":695.1000000089407,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":899.1000000089407,"responseStart":0,"secureConnectionStart":0},{"duration":203.70000000298023,"initiatorType":"link","name":"https://jira.mariadb.org/s/50bc9be5bfead1a25e72c1a9338c94f6-CDN/lu2cib/820016/12ta74/e108c7645258ccb43280ed3404e3e949/_/download/contextbatch/css/com.atlassian.jira.plugins.jira-development-integration-plugin:0,-_super,-jira.view.issue,-jira.global,-jira.general,-jira.browse.project,-project.issue.navigator,-atl.general/batch.css?agile_global_admin_condition=true&jag=true&jira.create.linked.issue=true&slack-enabled=true&whisper-enabled=true","startTime":695.5,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":695.5,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":899.2000000029802,"responseStart":0,"secureConnectionStart":0},{"duration":281.5,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2cib/820016/12ta74/e65b778d185daf5aee24936755b43da6/_/download/contextbatch/js/browser-metrics-plugin.contrib,-_super,-project.issue.navigator,-jira.view.issue,-atl.general/batch.js?agile_global_admin_condition=true&jag=true&jira.create.linked.issue=true&slack-enabled=true&whisper-enabled=true","startTime":696.4000000059605,"connectEnd":696.4000000059605,"connectStart":696.4000000059605,"domainLookupEnd":696.4000000059605,"domainLookupStart":696.4000000059605,"fetchStart":696.4000000059605,"redirectEnd":0,"redirectStart":0,"requestStart":696.4000000059605,"responseEnd":977.9000000059605,"responseStart":977.9000000059605,"secureConnectionStart":696.4000000059605},{"duration":296,"initiatorType":"script","name":"https://jira.mariadb.org/s/097ae97cb8fbec7d6ea4bbb1f26955b9-CDN/lu2cib/820016/12ta74/be4b45e9cec53099498fa61c8b7acba4/_/download/contextbatch/js/jira.project.sidebar,-_super,-project.issue.navigator,-jira.general,-jira.browse.project,-jira.view.issue,-jira.global,-atl.general,-com.atlassian.jira.projects.sidebar.init/batch.js?agile_global_admin_condition=true&jag=true&jira.create.linked.issue=true&locale=en&slack-enabled=true&whisper-enabled=true","startTime":696.7999999970198,"connectEnd":696.7999999970198,"connectStart":696.7999999970198,"domainLookupEnd":696.7999999970198,"domainLookupStart":696.7999999970198,"fetchStart":696.7999999970198,"redirectEnd":0,"redirectStart":0,"requestStart":696.7999999970198,"responseEnd":992.7999999970198,"responseStart":992.7999999970198,"secureConnectionStart":696.7999999970198},{"duration":297.19999998807907,"initiatorType":"script","name":"https://jira.mariadb.org/s/e0bf5781d46ea69fb123572974cf39de-CDN/lu2cib/820016/12ta74/e108c7645258ccb43280ed3404e3e949/_/download/contextbatch/js/com.atlassian.jira.plugins.jira-development-integration-plugin:0,-_super,-jira.view.issue,-jira.global,-jira.general,-jira.browse.project,-project.issue.navigator,-atl.general/batch.js?agile_global_admin_condition=true&jag=true&jira.create.linked.issue=true&locale=en&slack-enabled=true&whisper-enabled=true","startTime":697.1000000089407,"connectEnd":697.1000000089407,"connectStart":697.1000000089407,"domainLookupEnd":697.1000000089407,"domainLookupStart":697.1000000089407,"fetchStart":697.1000000089407,"redirectEnd":0,"redirectStart":0,"requestStart":697.1000000089407,"responseEnd":994.2999999970198,"responseStart":994.2999999970198,"secureConnectionStart":697.1000000089407}],"fetchStart":0,"domainLookupStart":0,"domainLookupEnd":0,"connectStart":0,"connectEnd":0,"requestStart":20,"responseStart":189,"responseEnd":196,"domLoading":192,"domInteractive":931,"domContentLoadedEventStart":931,"domContentLoadedEventEnd":981,"domComplete":1616,"loadEventStart":1616,"loadEventEnd":1617,"userAgent":"Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)","marks":[{"name":"bigPipe.sidebar-id.start","time":911.9000000059605},{"name":"bigPipe.sidebar-id.end","time":912.7000000029802},{"name":"bigPipe.activity-panel-pipe-id.start","time":912.7999999970198},{"name":"bigPipe.activity-panel-pipe-id.end","time":914.5},{"name":"activityTabFullyLoaded","time":995.2000000029802}],"measures":[],"correlationId":"81ea76035c3333","effectiveType":"4g","downlink":9.8,"rtt":0,"serverDuration":94,"dbReadsTimeInMs":10,"dbConnsTimeInMs":20,"applicationHash":"9d11dbea5f4be3d4cc21f03a88dd11d8c8687422","experiments":[]}}
The bug was fixed in 5.5.48 by the following commit (merged from upstream):
commit 863f7cebd79e76f90bd8f1e3e0c1a1de5fe77d07 3d1306f7b74077cfa197c8fa23baeb96c535af67
Author: Sreeharsha Ramanavarapu <sreeharsha.ramanavarapu@oracle.com>
Date: Fri Jan 8 06:46:59 2016 +0530
Bug #22232332: SAVING TEXT FIELD TO TEXT VARIABLE IN A
PROCEDURE RESULTS IN GARBAGE BYTES
Issue:
-----
This problem occurs under the following conditions:
a) Stored procedure has a variable is declared as TEXT/BLOB.
b) Data is copied into the the variable using the
SELECT...INTO syntax from a TEXT/BLOB column.
Data corruption can occur in such cases.
SOLUTION:
---------
The blob type does not allocate space for the string to be
stored. Instead it contains a pointer to the source string.
Since the source is deallocated immediately after the
select statement, this can cause data corruption.
As part of the fix for Bug #21143080, when the source was
part of the table's write-set, blob would allocate the
neccessary space. But this fix missed the possibility that,
as in the above case, the target might be a variable.
The fix will add the copy_blobs check that was removed by
the earlier fix.