SP variable substitution does not work well in queries with the WITH ROLLUP clause.
As a result, a bad binary log is created and replication breaks.
I put this file into mysql-test/t/ directory:
--source include/not_embedded.inc
|
--source include/have_binlog_format_statement.inc
|
|
--disable_query_log
|
reset master; # get rid of previous tests binlog
|
--enable_query_log
|
|
|
CREATE TABLE t1 (d DATE);
|
INSERT INTO t1 VALUES ('1985-05-13'),('1989-12-24');
|
CREATE TABLE t2 (d DATE, c BIGINT);
|
DELIMITER $$;
|
BEGIN NOT ATOMIC
|
DECLARE var INT;
|
INSERT INTO t2 SELECT d, COUNT(*) FROM t1 GROUP BY d, var;
|
INSERT INTO t2 SELECT d, COUNT(*) FROM t1 GROUP BY d, var WITH ROLLUP;
|
END;
|
$$
|
DELIMITER ;$$
|
DROP TABLE t1,t2;
|
|
--let $binlog_file = LAST
|
source include/show_binlog_events.inc;
|
and run "mtr" on it.
It produced the following output:
TEST RESULT TIME (ms) or COMMENT
|
--------------------------------------------------------------------------
|
|
worker[1] Using MTR_BUILD_THREAD 300, with reserved ports 16000..16019
|
CREATE TABLE t1 (d DATE);
|
INSERT INTO t1 VALUES ('1985-05-13'),('1989-12-24');
|
CREATE TABLE t2 (d DATE, c BIGINT);
|
BEGIN NOT ATOMIC
|
DECLARE var INT;
|
INSERT INTO t2 SELECT d, COUNT(*) FROM t1 GROUP BY d, var;
|
INSERT INTO t2 SELECT d, COUNT(*) FROM t1 GROUP BY d, var WITH ROLLUP;
|
END;
|
$$
|
DROP TABLE t1,t2;
|
include/show_binlog_events.inc
|
Log_name Pos Event_type Server_id End_log_pos Info
|
master-bin.000001 # Gtid # # GTID #-#-#
|
master-bin.000001 # Query # # use `test`; CREATE TABLE t1 (d DATE)
|
master-bin.000001 # Gtid # # BEGIN GTID #-#-#
|
master-bin.000001 # Query # # use `test`; INSERT INTO t1 VALUES ('1985-05-13'),('1989-12-24')
|
master-bin.000001 # Query # # COMMIT
|
master-bin.000001 # Gtid # # GTID #-#-#
|
master-bin.000001 # Query # # use `test`; CREATE TABLE t2 (d DATE, c BIGINT)
|
master-bin.000001 # Gtid # # BEGIN GTID #-#-#
|
master-bin.000001 # Query # # use `test`; INSERT INTO t2 SELECT d, COUNT(*) FROM t1 GROUP BY d, NAME_CONST('var',NULL)
|
master-bin.000001 # Query # # COMMIT
|
master-bin.000001 # Gtid # # BEGIN GTID #-#-#
|
master-bin.000001 # Query # # use `test`; INSERT INTO t2 SELECT d, COUNT(*) FROM t1 GROUP BY d, var NAME_CONST('var',NULL) ROLLUP
|
master-bin.000001 # Query # # COMMIT
|
master-bin.000001 # Gtid # # GTID #-#-#
|
master-bin.000001 # Query # # use `test`; DROP TABLE `t1`,`t2` /* generated by server */
|
main.AAA [ pass ] 54
|
--------------------------------------------------------------------------
|
Notice:
- in the first INSERT query the variable var was correctly replaced to the NAME_CONST expression:
... GROUP BY d, NAME_CONST('var',NULL)
|
- in the second INSERT query the variable was not removed and the NAME_CONST expression was put on a wrong place.
... GROUP BY d, var NAME_CONST('var',NULL) ROLLUP
|
The logged query for the second INSERT does not even get parsed:
MariaDB [test]> INSERT INTO t2 SELECT d, COUNT(*) FROM t1 GROUP BY d, var NAME_CONST('var',NULL) ROLLUP;
|
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'NAME_CONST('var',NULL) ROLLUP' at line 1
|
There are no comments yet on this issue.
{"report":{"fcp":1164,"ttfb":295.69999980926514,"pageVisibility":"visible","entityId":67072,"key":"jira.project.issue.view-issue","isInitial":true,"threshold":1000,"elementTimings":{},"userDeviceMemory":8,"userDeviceProcessors":64,"apdex":0.5,"journeyId":"567c3e8d-3074-4453-8a1b-c24eb8b00e98","navigationType":0,"readyForUser":1276.2999992370605,"redirectCount":0,"resourceLoadedEnd":1382,"resourceLoadedStart":302.29999923706055,"resourceTiming":[{"duration":224.4000005722046,"initiatorType":"link","name":"https://jira.mariadb.org/s/2c21342762a6a02add1c328bed317ffd-CDN/lu2cib/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/css/_super/batch.css","startTime":302.29999923706055,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":302.29999923706055,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":526.6999998092651,"responseStart":0,"secureConnectionStart":0},{"duration":224.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":302.5999994277954,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":302.5999994277954,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":527.0999994277954,"responseStart":0,"secureConnectionStart":0},{"duration":283,"initiatorType":"script","name":"https://jira.mariadb.org/s/0917945aaa57108d00c5076fea35e069-CDN/lu2cib/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/js/_super/batch.js?locale=en","startTime":302.79999923706055,"connectEnd":302.79999923706055,"connectStart":302.79999923706055,"domainLookupEnd":302.79999923706055,"domainLookupStart":302.79999923706055,"fetchStart":302.79999923706055,"redirectEnd":0,"redirectStart":0,"requestStart":302.79999923706055,"responseEnd":585.7999992370605,"responseStart":585.7999992370605,"secureConnectionStart":302.79999923706055},{"duration":362.30000019073486,"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":302.8999996185303,"connectEnd":302.8999996185303,"connectStart":302.8999996185303,"domainLookupEnd":302.8999996185303,"domainLookupStart":302.8999996185303,"fetchStart":302.8999996185303,"redirectEnd":0,"redirectStart":0,"requestStart":302.8999996185303,"responseEnd":665.1999998092651,"responseStart":665.1999998092651,"secureConnectionStart":302.8999996185303},{"duration":367.0999994277954,"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":303.19999980926514,"connectEnd":303.19999980926514,"connectStart":303.19999980926514,"domainLookupEnd":303.19999980926514,"domainLookupStart":303.19999980926514,"fetchStart":303.19999980926514,"redirectEnd":0,"redirectStart":0,"requestStart":303.19999980926514,"responseEnd":670.2999992370605,"responseStart":670.2999992370605,"secureConnectionStart":303.19999980926514},{"duration":367.3999996185303,"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":303.3999996185303,"connectEnd":303.3999996185303,"connectStart":303.3999996185303,"domainLookupEnd":303.3999996185303,"domainLookupStart":303.3999996185303,"fetchStart":303.3999996185303,"redirectEnd":0,"redirectStart":0,"requestStart":303.3999996185303,"responseEnd":670.7999992370605,"responseStart":670.7999992370605,"secureConnectionStart":303.3999996185303},{"duration":367.6000003814697,"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":303.5999994277954,"connectEnd":303.5999994277954,"connectStart":303.5999994277954,"domainLookupEnd":303.5999994277954,"domainLookupStart":303.5999994277954,"fetchStart":303.5999994277954,"redirectEnd":0,"redirectStart":0,"requestStart":303.5999994277954,"responseEnd":671.1999998092651,"responseStart":671.1999998092651,"secureConnectionStart":303.5999994277954},{"duration":444,"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":303.79999923706055,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":303.79999923706055,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":747.7999992370605,"responseStart":0,"secureConnectionStart":0},{"duration":367.80000019073486,"initiatorType":"script","name":"https://jira.mariadb.org/rest/api/1.0/shortcuts/820016/47140b6e0a9bc2e4913da06536125810/shortcuts.js?context=issuenavigation&context=issueaction","startTime":303.8999996185303,"connectEnd":303.8999996185303,"connectStart":303.8999996185303,"domainLookupEnd":303.8999996185303,"domainLookupStart":303.8999996185303,"fetchStart":303.8999996185303,"redirectEnd":0,"redirectStart":0,"requestStart":303.8999996185303,"responseEnd":671.6999998092651,"responseStart":671.6999998092651,"secureConnectionStart":303.8999996185303},{"duration":445.69999980926514,"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":304.0999994277954,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":304.0999994277954,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":749.7999992370605,"responseStart":0,"secureConnectionStart":0},{"duration":367.9000005722046,"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":304.29999923706055,"connectEnd":304.29999923706055,"connectStart":304.29999923706055,"domainLookupEnd":304.29999923706055,"domainLookupStart":304.29999923706055,"fetchStart":304.29999923706055,"redirectEnd":0,"redirectStart":0,"requestStart":304.29999923706055,"responseEnd":672.1999998092651,"responseStart":672.1999998092651,"secureConnectionStart":304.29999923706055},{"duration":899.5,"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":305.29999923706055,"connectEnd":305.29999923706055,"connectStart":305.29999923706055,"domainLookupEnd":305.29999923706055,"domainLookupStart":305.29999923706055,"fetchStart":305.29999923706055,"redirectEnd":0,"redirectStart":0,"requestStart":305.29999923706055,"responseEnd":1204.7999992370605,"responseStart":1204.7999992370605,"secureConnectionStart":305.29999923706055},{"duration":1076.6000003814697,"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":305.3999996185303,"connectEnd":305.3999996185303,"connectStart":305.3999996185303,"domainLookupEnd":305.3999996185303,"domainLookupStart":305.3999996185303,"fetchStart":305.3999996185303,"redirectEnd":0,"redirectStart":0,"requestStart":305.3999996185303,"responseEnd":1382,"responseStart":1382,"secureConnectionStart":305.3999996185303},{"duration":425.6000003814697,"initiatorType":"xmlhttprequest","name":"https://jira.mariadb.org/rest/webResources/1.0/resources","startTime":781.0999994277954,"connectEnd":781.0999994277954,"connectStart":781.0999994277954,"domainLookupEnd":781.0999994277954,"domainLookupStart":781.0999994277954,"fetchStart":781.0999994277954,"redirectEnd":0,"redirectStart":0,"requestStart":781.0999994277954,"responseEnd":1206.6999998092651,"responseStart":1206.6999998092651,"secureConnectionStart":781.0999994277954},{"duration":338.6000003814697,"initiatorType":"script","name":"https://www.google-analytics.com/analytics.js","startTime":1157.3999996185303,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":1157.3999996185303,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":1496,"responseStart":0,"secureConnectionStart":0}],"fetchStart":0,"domainLookupStart":0,"domainLookupEnd":0,"connectStart":0,"connectEnd":0,"requestStart":129,"responseStart":295,"responseEnd":298,"domLoading":299,"domInteractive":1407,"domContentLoadedEventStart":1407,"domContentLoadedEventEnd":1455,"domComplete":1771,"loadEventStart":1771,"loadEventEnd":1772,"userAgent":"Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)","marks":[{"name":"bigPipe.sidebar-id.start","time":1393.8999996185303},{"name":"bigPipe.sidebar-id.end","time":1394.8999996185303},{"name":"bigPipe.activity-panel-pipe-id.start","time":1395},{"name":"bigPipe.activity-panel-pipe-id.end","time":1395.5},{"name":"activityTabFullyLoaded","time":1500.5}],"measures":[],"correlationId":"b43045bd97e195","effectiveType":"4g","downlink":10,"rtt":0,"serverDuration":96,"dbReadsTimeInMs":12,"dbConnsTimeInMs":20,"applicationHash":"9d11dbea5f4be3d4cc21f03a88dd11d8c8687422","experiments":[]}}