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":990.5,"ttfb":304.3999996185303,"pageVisibility":"visible","entityId":57012,"key":"jira.project.issue.view-issue","isInitial":true,"threshold":1000,"elementTimings":{},"userDeviceMemory":8,"userDeviceProcessors":64,"apdex":0.5,"journeyId":"9dc4323c-d784-45ad-af45-9192f9b496bc","navigationType":0,"readyForUser":1068.3999996185303,"redirectCount":0,"resourceLoadedEnd":1081.8999996185303,"resourceLoadedStart":310.09999990463257,"resourceTiming":[{"duration":161.7999997138977,"initiatorType":"link","name":"https://jira.mariadb.org/s/2c21342762a6a02add1c328bed317ffd-CDN/lu2cib/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/css/_super/batch.css","startTime":310.09999990463257,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":310.09999990463257,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":471.8999996185303,"responseStart":0,"secureConnectionStart":0},{"duration":162.40000009536743,"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":310.2999997138977,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":310.2999997138977,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":472.69999980926514,"responseStart":0,"secureConnectionStart":0},{"duration":219.39999961853027,"initiatorType":"script","name":"https://jira.mariadb.org/s/0917945aaa57108d00c5076fea35e069-CDN/lu2cib/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/js/_super/batch.js?locale=en","startTime":310.5,"connectEnd":310.5,"connectStart":310.5,"domainLookupEnd":310.5,"domainLookupStart":310.5,"fetchStart":310.5,"redirectEnd":0,"redirectStart":0,"requestStart":310.5,"responseEnd":529.8999996185303,"responseStart":529.8999996185303,"secureConnectionStart":310.5},{"duration":283,"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":310.69999980926514,"connectEnd":310.69999980926514,"connectStart":310.69999980926514,"domainLookupEnd":310.69999980926514,"domainLookupStart":310.69999980926514,"fetchStart":310.69999980926514,"redirectEnd":0,"redirectStart":0,"requestStart":310.69999980926514,"responseEnd":593.6999998092651,"responseStart":593.6999998092651,"secureConnectionStart":310.69999980926514},{"duration":286.7000002861023,"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":310.8999996185303,"connectEnd":310.8999996185303,"connectStart":310.8999996185303,"domainLookupEnd":310.8999996185303,"domainLookupStart":310.8999996185303,"fetchStart":310.8999996185303,"redirectEnd":0,"redirectStart":0,"requestStart":310.8999996185303,"responseEnd":597.5999999046326,"responseStart":597.5999999046326,"secureConnectionStart":310.8999996185303},{"duration":286.90000009536743,"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":311.09999990463257,"connectEnd":311.09999990463257,"connectStart":311.09999990463257,"domainLookupEnd":311.09999990463257,"domainLookupStart":311.09999990463257,"fetchStart":311.09999990463257,"redirectEnd":0,"redirectStart":0,"requestStart":311.09999990463257,"responseEnd":598,"responseStart":598,"secureConnectionStart":311.09999990463257},{"duration":287,"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":311.3999996185303,"connectEnd":311.3999996185303,"connectStart":311.3999996185303,"domainLookupEnd":311.3999996185303,"domainLookupStart":311.3999996185303,"fetchStart":311.3999996185303,"redirectEnd":0,"redirectStart":0,"requestStart":311.3999996185303,"responseEnd":598.3999996185303,"responseStart":598.3999996185303,"secureConnectionStart":311.3999996185303},{"duration":363.59999990463257,"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":311.5,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":311.5,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":675.0999999046326,"responseStart":0,"secureConnectionStart":0},{"duration":287.30000019073486,"initiatorType":"script","name":"https://jira.mariadb.org/rest/api/1.0/shortcuts/820016/47140b6e0a9bc2e4913da06536125810/shortcuts.js?context=issuenavigation&context=issueaction","startTime":311.69999980926514,"connectEnd":311.69999980926514,"connectStart":311.69999980926514,"domainLookupEnd":311.69999980926514,"domainLookupStart":311.69999980926514,"fetchStart":311.69999980926514,"redirectEnd":0,"redirectStart":0,"requestStart":311.69999980926514,"responseEnd":599,"responseStart":599,"secureConnectionStart":311.69999980926514},{"duration":363.5,"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":311.7999997138977,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":311.7999997138977,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":675.2999997138977,"responseStart":0,"secureConnectionStart":0},{"duration":287.5,"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":312,"connectEnd":312,"connectStart":312,"domainLookupEnd":312,"domainLookupStart":312,"fetchStart":312,"redirectEnd":0,"redirectStart":0,"requestStart":312,"responseEnd":599.5,"responseStart":599.5,"secureConnectionStart":312},{"duration":760.9000000953674,"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":312.7999997138977,"connectEnd":312.7999997138977,"connectStart":312.7999997138977,"domainLookupEnd":312.7999997138977,"domainLookupStart":312.7999997138977,"fetchStart":312.7999997138977,"redirectEnd":0,"redirectStart":0,"requestStart":312.7999997138977,"responseEnd":1073.6999998092651,"responseStart":1073.6999998092651,"secureConnectionStart":312.7999997138977},{"duration":761.8000001907349,"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":312.7999997138977,"connectEnd":312.7999997138977,"connectStart":312.7999997138977,"domainLookupEnd":312.7999997138977,"domainLookupStart":312.7999997138977,"fetchStart":312.7999997138977,"redirectEnd":0,"redirectStart":0,"requestStart":312.7999997138977,"responseEnd":1074.5999999046326,"responseStart":1074.5999999046326,"secureConnectionStart":312.7999997138977},{"duration":174,"initiatorType":"xmlhttprequest","name":"https://jira.mariadb.org/rest/webResources/1.0/resources","startTime":687,"connectEnd":687,"connectStart":687,"domainLookupEnd":687,"domainLookupStart":687,"fetchStart":687,"redirectEnd":0,"redirectStart":0,"requestStart":687,"responseEnd":861,"responseStart":861,"secureConnectionStart":687},{"duration":135.19999980926514,"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":946.6999998092651,"connectEnd":946.6999998092651,"connectStart":946.6999998092651,"domainLookupEnd":946.6999998092651,"domainLookupStart":946.6999998092651,"fetchStart":946.6999998092651,"redirectEnd":0,"redirectStart":0,"requestStart":946.6999998092651,"responseEnd":1081.8999996185303,"responseStart":1081.8999996185303,"secureConnectionStart":946.6999998092651},{"duration":139.19999980926514,"initiatorType":"script","name":"https://www.google-analytics.com/analytics.js","startTime":984.5,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":984.5,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":1123.6999998092651,"responseStart":0,"secureConnectionStart":0}],"fetchStart":0,"domainLookupStart":0,"domainLookupEnd":0,"connectStart":0,"connectEnd":0,"requestStart":136,"responseStart":304,"responseEnd":306,"domLoading":307,"domInteractive":1197,"domContentLoadedEventStart":1197,"domContentLoadedEventEnd":1240,"domComplete":1301,"loadEventStart":1301,"loadEventEnd":1302,"userAgent":"Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)","marks":[{"name":"bigPipe.sidebar-id.start","time":1166.5999999046326},{"name":"bigPipe.sidebar-id.end","time":1167.5999999046326},{"name":"bigPipe.activity-panel-pipe-id.start","time":1167.6999998092651},{"name":"bigPipe.activity-panel-pipe-id.end","time":1169.5},{"name":"activityTabFullyLoaded","time":1254.8999996185303}],"measures":[],"correlationId":"4d9b0cec69fa1c","effectiveType":"4g","downlink":10,"rtt":0,"serverDuration":101,"dbReadsTimeInMs":11,"dbConnsTimeInMs":21,"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.