In upgrading my MariaDB Server from version 10.2.23 to 10.2.24 I ran into a problem that resulted in me having to revert my environment back to 10.2.23.
I have a table with a before update trigger that references a stored function. Prior to MariaDB 10.2.24, the following code ran successfully:
-- BUG TEST CASE
|
-- 1. test schema
|
DROP SCHEMA IF EXISTS testdata;
|
CREATE SCHEMA IF NOT EXISTS testdata;
|
USE testdata;
|
|
-- 2. test table with a column that is set by a trigger value
|
DROP TABLE IF EXISTS test_table;
|
CREATE TABLE test_table (
|
`ID` int(11) not null AUTO_INCREMENT,
|
`Name` varchar(150) not null,
|
`TriggerSet` varchar(75),
|
PRIMARY KEY (`ID`)
|
) ENGINE = InnoDB;
|
|
-- 3. stored function that does something
|
DELIMITER $$
|
DROP FUNCTION IF EXISTS test$$
|
CREATE DEFINER = `root`@`localhost` FUNCTION `test`()
|
RETURNS VARCHAR(50)
|
READS SQL DATA
|
BEGIN
|
RETURN 'Result';
|
END$$
|
DELIMITER ;
|
|
-- 4. the trigger that calls the stored function and sets the result to a column value
|
DELIMITER $$
|
DROP TRIGGER IF EXISTS testdata.test_table_update_before$$
|
CREATE TRIGGER testdata.test_table_update_before BEFORE UPDATE ON testdata.test_table
|
FOR EACH ROW
|
BEGIN
|
SET NEW.TriggerSet = (SELECT testdata.test());
|
END$$
|
|
DELIMITER ;
|
|
-- 5. test data
|
INSERT INTO testdata.test_table (Name)
|
VALUES
|
('1'), ('2'), ('3'), ('4'), ('5');
|
|
-- 6. a query to form another table that has modifications
|
DROP TABLE IF EXISTS scratch.`modify`;
|
CREATE TABLE scratch.modify (PRIMARY KEY (`ID`))
|
SELECT ID, CONCAT(Name,'_') Name FROM testdata.test_table WHERE ID BETWEEN 2 AND 4;
|
|
-- 7. this update FAILS in MariaDB 10.2.24 but not 10.2.23
|
UPDATE testdata.test_table t
|
INNER JOIN scratch.modify m USING (ID)
|
SET t.Name = m.Name;
|
|
-- 8. the resulting table that should have the modifications, but in 10.2.24, the update statement above fails
|
SELECT * FROM testdata.test_table;
|
|
-- 9. this is the same function that is called in the trigger, it succeeds when called on its own
|
SELECT testdata.test();
|
In MariaDB 10.2.24, the update statement in step 7 does not execute, you get the error "FUNCTION testdata.test does not exist". However, if you call the exact same function (what is done in step 9) it succeeds.
A couple of things that might be worth knowing. First, updating the table in a non-joined update statement works fine:
-- this functions in 10.2.24 and the triggerset column is populated with the result of the stored -- function
|
UPDATE testdata.test_table SET Name = '1_1' WHERE ID = 1;
|
Also potentially worth noting, if you run the non-joined update statement, the immediately execute the bug test case, everything works fine. However if you restart the MariaDB daemon and you re-run the test case it fails. This leads me to believe that the non-joined update statement is pulling the table into cache which allows the joined statement to succeed. However it only succeeds temporarily.
Please let me know if I can provide any additional information.
- duplicates
-
MDEV-19491
update query stopped working after mariadb upgrade 10.2.23 -> 10.2.24
-
-
Closed
{"report":{"fcp":681.5999999046326,"ttfb":197.09999990463257,"pageVisibility":"visible","entityId":76111,"key":"jira.project.issue.view-issue","isInitial":true,"threshold":1000,"elementTimings":{},"userDeviceMemory":8,"userDeviceProcessors":64,"apdex":1,"journeyId":"d1f4c937-793d-428b-9f28-ea7332ce1e34","navigationType":0,"readyForUser":770.2999997138977,"redirectCount":0,"resourceLoadedEnd":742.1999998092651,"resourceLoadedStart":202.19999980926514,"resourceTiming":[{"duration":13.099999904632568,"initiatorType":"link","name":"https://jira.mariadb.org/s/2c21342762a6a02add1c328bed317ffd-CDN/lu2bsh/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/css/_super/batch.css","startTime":202.19999980926514,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":202.19999980926514,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":215.2999997138977,"responseStart":0,"secureConnectionStart":0},{"duration":14.099999904632568,"initiatorType":"link","name":"https://jira.mariadb.org/s/7ebd35e77e471bc30ff0eba799ebc151-CDN/lu2bsh/820016/12ta74/eb142f92e4bd16bd1ef8b08c1b9d5d56/_/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":202.5,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":202.5,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":216.59999990463257,"responseStart":0,"secureConnectionStart":0},{"duration":81.90000009536743,"initiatorType":"script","name":"https://jira.mariadb.org/s/c54b129276d75dc2a3460e1d78f37913-CDN/lu2bsh/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/js/_super/batch.js?locale=en","startTime":202.59999990463257,"connectEnd":202.59999990463257,"connectStart":202.59999990463257,"domainLookupEnd":202.59999990463257,"domainLookupStart":202.59999990463257,"fetchStart":202.59999990463257,"redirectEnd":0,"redirectStart":0,"requestStart":202.59999990463257,"responseEnd":284.5,"responseStart":284.5,"secureConnectionStart":202.59999990463257},{"duration":162.80000019073486,"initiatorType":"script","name":"https://jira.mariadb.org/s/f867843cd2fdb209d4d1d4f760f86346-CDN/lu2bsh/820016/12ta74/eb142f92e4bd16bd1ef8b08c1b9d5d56/_/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":202.69999980926514,"connectEnd":202.69999980926514,"connectStart":202.69999980926514,"domainLookupEnd":202.69999980926514,"domainLookupStart":202.69999980926514,"fetchStart":202.69999980926514,"redirectEnd":0,"redirectStart":0,"requestStart":202.69999980926514,"responseEnd":365.5,"responseStart":365.5,"secureConnectionStart":202.69999980926514},{"duration":166.80000019073486,"initiatorType":"script","name":"https://jira.mariadb.org/s/ffdb17665775c5b4d6f097f3974ee359-CDN/lu2bsh/820016/12ta74/c92c0caa9a024ae85b0ebdbed7fb4bd7/_/download/contextbatch/js/atl.global,-_super/batch.js?locale=en","startTime":202.89999961853027,"connectEnd":202.89999961853027,"connectStart":202.89999961853027,"domainLookupEnd":202.89999961853027,"domainLookupStart":202.89999961853027,"fetchStart":202.89999961853027,"redirectEnd":0,"redirectStart":0,"requestStart":202.89999961853027,"responseEnd":369.69999980926514,"responseStart":369.69999980926514,"secureConnectionStart":202.89999961853027},{"duration":167.40000009536743,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2bsh/820016/12ta74/1.0/_/download/batch/jira.webresources:calendar-en/jira.webresources:calendar-en.js","startTime":202.89999961853027,"connectEnd":202.89999961853027,"connectStart":202.89999961853027,"domainLookupEnd":202.89999961853027,"domainLookupStart":202.89999961853027,"fetchStart":202.89999961853027,"redirectEnd":0,"redirectStart":0,"requestStart":202.89999961853027,"responseEnd":370.2999997138977,"responseStart":370.19999980926514,"secureConnectionStart":202.89999961853027},{"duration":168,"initiatorType":"link","name":"https://jira.mariadb.org/s/b04b06a02d1959df322d9cded3aeecc1-CDN/lu2bsh/820016/12ta74/a2ff6aa845ffc9a1d22fe23d9ee791fc/_/download/contextbatch/css/jira.global.look-and-feel,-_super/batch.css","startTime":203.09999990463257,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":203.09999990463257,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":371.09999990463257,"responseStart":0,"secureConnectionStart":0},{"duration":167.5,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2bsh/820016/12ta74/1.0/_/download/batch/jira.webresources:calendar-localisation-moment/jira.webresources:calendar-localisation-moment.js","startTime":203.09999990463257,"connectEnd":203.09999990463257,"connectStart":203.09999990463257,"domainLookupEnd":203.09999990463257,"domainLookupStart":203.09999990463257,"fetchStart":203.09999990463257,"redirectEnd":0,"redirectStart":0,"requestStart":203.09999990463257,"responseEnd":370.59999990463257,"responseStart":370.59999990463257,"secureConnectionStart":203.09999990463257},{"duration":167.90000009536743,"initiatorType":"script","name":"https://jira.mariadb.org/rest/api/1.0/shortcuts/820016/47140b6e0a9bc2e4913da06536125810/shortcuts.js?context=issuenavigation&context=issueaction","startTime":203.19999980926514,"connectEnd":203.19999980926514,"connectStart":203.19999980926514,"domainLookupEnd":203.19999980926514,"domainLookupStart":203.19999980926514,"fetchStart":203.19999980926514,"redirectEnd":0,"redirectStart":0,"requestStart":203.19999980926514,"responseEnd":371.09999990463257,"responseStart":371.09999990463257,"secureConnectionStart":203.19999980926514},{"duration":168.2000002861023,"initiatorType":"link","name":"https://jira.mariadb.org/s/3ac36323ba5e4eb0af2aa7ac7211b4bb-CDN/lu2bsh/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":203.2999997138977,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":203.2999997138977,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":371.5,"responseStart":0,"secureConnectionStart":0},{"duration":168,"initiatorType":"script","name":"https://jira.mariadb.org/s/81b5d7c27af3ebc078cc4a36383678ba-CDN/lu2bsh/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":203.59999990463257,"connectEnd":203.59999990463257,"connectStart":203.59999990463257,"domainLookupEnd":203.59999990463257,"domainLookupStart":203.59999990463257,"fetchStart":203.59999990463257,"redirectEnd":0,"redirectStart":0,"requestStart":203.59999990463257,"responseEnd":371.59999990463257,"responseStart":371.59999990463257,"secureConnectionStart":203.59999990463257},{"duration":484.80000019073486,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2bsh/820016/12ta74/1.0/_/download/batch/jira.webresources:bigpipe-js/jira.webresources:bigpipe-js.js","startTime":209.2999997138977,"connectEnd":209.2999997138977,"connectStart":209.2999997138977,"domainLookupEnd":209.2999997138977,"domainLookupStart":209.2999997138977,"fetchStart":209.2999997138977,"redirectEnd":0,"redirectStart":0,"requestStart":209.2999997138977,"responseEnd":694.0999999046326,"responseStart":694.0999999046326,"secureConnectionStart":209.2999997138977},{"duration":532.5999999046326,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2bsh/820016/12ta74/1.0/_/download/batch/jira.webresources:bigpipe-init/jira.webresources:bigpipe-init.js","startTime":209.59999990463257,"connectEnd":209.59999990463257,"connectStart":209.59999990463257,"domainLookupEnd":209.59999990463257,"domainLookupStart":209.59999990463257,"fetchStart":209.59999990463257,"redirectEnd":0,"redirectStart":0,"requestStart":209.59999990463257,"responseEnd":742.1999998092651,"responseStart":742.0999999046326,"secureConnectionStart":209.59999990463257},{"duration":254.89999961853027,"initiatorType":"xmlhttprequest","name":"https://jira.mariadb.org/rest/webResources/1.0/resources","startTime":439.5,"connectEnd":439.5,"connectStart":439.5,"domainLookupEnd":439.5,"domainLookupStart":439.5,"fetchStart":439.5,"redirectEnd":0,"redirectStart":0,"requestStart":439.5,"responseEnd":694.3999996185303,"responseStart":694.3999996185303,"secureConnectionStart":439.5},{"duration":71.2000002861023,"initiatorType":"script","name":"https://www.google-analytics.com/analytics.js","startTime":674.7999997138977,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":674.7999997138977,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":746,"responseStart":0,"secureConnectionStart":0}],"fetchStart":0,"domainLookupStart":0,"domainLookupEnd":0,"connectStart":0,"connectEnd":0,"requestStart":54,"responseStart":197,"responseEnd":208,"domLoading":200,"domInteractive":893,"domContentLoadedEventStart":893,"domContentLoadedEventEnd":941,"domComplete":1118,"loadEventStart":1118,"loadEventEnd":1119,"userAgent":"Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)","marks":[{"name":"bigPipe.sidebar-id.start","time":873.2999997138977},{"name":"bigPipe.sidebar-id.end","time":874.0999999046326},{"name":"bigPipe.activity-panel-pipe-id.start","time":874.2999997138977},{"name":"bigPipe.activity-panel-pipe-id.end","time":875.1999998092651},{"name":"activityTabFullyLoaded","time":958.2999997138977}],"measures":[],"correlationId":"2a16c39d49f489","effectiveType":"4g","downlink":9.6,"rtt":0,"serverDuration":83,"dbReadsTimeInMs":14,"dbConnsTimeInMs":23,"applicationHash":"9d11dbea5f4be3d4cc21f03a88dd11d8c8687422","experiments":[]}}
Thanks!
I added this test case to
MDEV-19491and closing this one. Please watchMDEV-19491, if you'd like to follow the progress