The problem appeared on 5.5 tree with the following revision:
revno: 4030
|
revision-id: monty@askmonty.org-20140124125018-qwln430o4bu3pued
|
parent: monty@askmonty.org-20140124123019-2ts6q2ip6076gmqg
|
committer: Michael Widenius <monty@askmonty.org>
|
branch nick: maria-5.5
|
timestamp: Fri 2014-01-24 14:50:18 +0200
|
message:
|
Fix for MDEV-5531: double call procedure in one session - hard shutdown the server
|
Main fix was to not cache derivied tables as they may be temporary tables that are deleted before the next query.
|
This was a bit tricky as Item_field::fix_fields depended on cached_tables to be set to resolve some columns.
|
Test case
|
CREATE TABLE t (a INT NOT NULL) ENGINE=MyISAM;
|
INSERT INTO t VALUES (0),(8);
|
|
PREPARE stmt FROM "
|
SELECT a FROM ( SELECT DISTINCT t1.* FROM t AS t1, t AS t2 ) AS sq
|
WHERE a IN ( SELECT MIN(t3.a) FROM ( t AS t3 INNER JOIN t AS t4 ON (t3.a = t4.a) ) ) ORDER BY a LIMIT 10
|
";
|
|
execute stmt;
|
execute stmt;
|
Results
|
MariaDB [test]> execute stmt;
|
+---+
|
| a |
|
+---+
|
| 0 |
|
| 8 |
|
+---+
|
2 rows in set (0.01 sec)
|
|
MariaDB [test]> execute stmt;
|
Empty set (0.00 sec)
|
Both results are incorrect.
When the query is executed directly, without a PS, it produces the expected result:
MariaDB [test]> SELECT a FROM ( SELECT DISTINCT t1.* FROM t AS t1, t AS t2 ) AS sq
|
-> WHERE a IN ( SELECT MIN(t3.a) FROM t AS t3 INNER JOIN t AS t4 ON (t3.a = t4.a) ) ORDER BY a LIMIT 10
|
-> ;
|
+---+
|
| a |
|
+---+
|
| 0 |
|
+---+
|
1 row in set (0.00 sec)
|
{"report":{"fcp":956.1999998092651,"ttfb":254.80000019073486,"pageVisibility":"visible","entityId":50554,"key":"jira.project.issue.view-issue","isInitial":true,"threshold":1000,"elementTimings":{},"userDeviceMemory":8,"userDeviceProcessors":64,"apdex":0.5,"journeyId":"fb434a2c-806b-419f-83db-9dabdb70c27a","navigationType":0,"readyForUser":1052,"redirectCount":0,"resourceLoadedEnd":1080.5999994277954,"resourceLoadedStart":260,"resourceTiming":[{"duration":146.30000019073486,"initiatorType":"link","name":"https://jira.mariadb.org/s/2c21342762a6a02add1c328bed317ffd-CDN/lu2cib/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/css/_super/batch.css","startTime":260,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":260,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":406.30000019073486,"responseStart":0,"secureConnectionStart":0},{"duration":146.29999923706055,"initiatorType":"link","name":"https://jira.mariadb.org/s/7ebd35e77e471bc30ff0eba799ebc151-CDN/lu2cib/820016/12ta74/2bf333562ca6724060a9d5f1535471f6/_/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":260.30000019073486,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":260.30000019073486,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":406.5999994277954,"responseStart":0,"secureConnectionStart":0},{"duration":154.69999980926514,"initiatorType":"script","name":"https://jira.mariadb.org/s/0917945aaa57108d00c5076fea35e069-CDN/lu2cib/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/js/_super/batch.js?locale=en","startTime":260.5,"connectEnd":260.5,"connectStart":260.5,"domainLookupEnd":260.5,"domainLookupStart":260.5,"fetchStart":260.5,"redirectEnd":0,"redirectStart":0,"requestStart":260.5,"responseEnd":415.19999980926514,"responseStart":415.19999980926514,"secureConnectionStart":260.5},{"duration":223.69999980926514,"initiatorType":"script","name":"https://jira.mariadb.org/s/2d8175ec2fa4c816e8023260bd8c1786-CDN/lu2cib/820016/12ta74/2bf333562ca6724060a9d5f1535471f6/_/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":260.80000019073486,"connectEnd":260.80000019073486,"connectStart":260.80000019073486,"domainLookupEnd":260.80000019073486,"domainLookupStart":260.80000019073486,"fetchStart":260.80000019073486,"redirectEnd":0,"redirectStart":0,"requestStart":260.80000019073486,"responseEnd":484.5,"responseStart":484.5,"secureConnectionStart":260.80000019073486},{"duration":228.5,"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":261,"connectEnd":261,"connectStart":261,"domainLookupEnd":261,"domainLookupStart":261,"fetchStart":261,"redirectEnd":0,"redirectStart":0,"requestStart":261,"responseEnd":489.5,"responseStart":489.5,"secureConnectionStart":261},{"duration":229.0999994277954,"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":261.30000019073486,"connectEnd":261.30000019073486,"connectStart":261.30000019073486,"domainLookupEnd":261.30000019073486,"domainLookupStart":261.30000019073486,"fetchStart":261.30000019073486,"redirectEnd":0,"redirectStart":0,"requestStart":261.30000019073486,"responseEnd":490.3999996185303,"responseStart":490.3999996185303,"secureConnectionStart":261.30000019073486},{"duration":229.5999994277954,"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":261.5,"connectEnd":261.5,"connectStart":261.5,"domainLookupEnd":261.5,"domainLookupStart":261.5,"fetchStart":261.5,"redirectEnd":0,"redirectStart":0,"requestStart":261.5,"responseEnd":491.0999994277954,"responseStart":491.0999994277954,"secureConnectionStart":261.5},{"duration":300.20000076293945,"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":261.5999994277954,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":261.5999994277954,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":561.8000001907349,"responseStart":0,"secureConnectionStart":0},{"duration":229.89999961853027,"initiatorType":"script","name":"https://jira.mariadb.org/rest/api/1.0/shortcuts/820016/47140b6e0a9bc2e4913da06536125810/shortcuts.js?context=issuenavigation&context=issueaction","startTime":261.80000019073486,"connectEnd":261.80000019073486,"connectStart":261.80000019073486,"domainLookupEnd":261.80000019073486,"domainLookupStart":261.80000019073486,"fetchStart":261.80000019073486,"redirectEnd":0,"redirectStart":0,"requestStart":261.80000019073486,"responseEnd":491.69999980926514,"responseStart":491.69999980926514,"secureConnectionStart":261.80000019073486},{"duration":300.19999980926514,"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":262,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":262,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":562.1999998092651,"responseStart":0,"secureConnectionStart":0},{"duration":230.30000019073486,"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":262.0999994277954,"connectEnd":262.0999994277954,"connectStart":262.0999994277954,"domainLookupEnd":262.0999994277954,"domainLookupStart":262.0999994277954,"fetchStart":262.0999994277954,"redirectEnd":0,"redirectStart":0,"requestStart":262.0999994277954,"responseEnd":492.3999996185303,"responseStart":492.3999996185303,"secureConnectionStart":262.0999994277954},{"duration":390.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":267.69999980926514,"connectEnd":267.69999980926514,"connectStart":267.69999980926514,"domainLookupEnd":267.69999980926514,"domainLookupStart":267.69999980926514,"fetchStart":267.69999980926514,"redirectEnd":0,"redirectStart":0,"requestStart":267.69999980926514,"responseEnd":658.1999998092651,"responseStart":658.1999998092651,"secureConnectionStart":267.69999980926514},{"duration":812.7999992370605,"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":267.80000019073486,"connectEnd":267.80000019073486,"connectStart":267.80000019073486,"domainLookupEnd":267.80000019073486,"domainLookupStart":267.80000019073486,"fetchStart":267.80000019073486,"redirectEnd":0,"redirectStart":0,"requestStart":267.80000019073486,"responseEnd":1080.5999994277954,"responseStart":1080.5999994277954,"secureConnectionStart":267.80000019073486},{"duration":140.69999980926514,"initiatorType":"xmlhttprequest","name":"https://jira.mariadb.org/rest/webResources/1.0/resources","startTime":574.8000001907349,"connectEnd":574.8000001907349,"connectStart":574.8000001907349,"domainLookupEnd":574.8000001907349,"domainLookupStart":574.8000001907349,"fetchStart":574.8000001907349,"redirectEnd":0,"redirectStart":0,"requestStart":574.8000001907349,"responseEnd":715.5,"responseStart":715.5,"secureConnectionStart":574.8000001907349}],"fetchStart":0,"domainLookupStart":0,"domainLookupEnd":0,"connectStart":0,"connectEnd":0,"requestStart":91,"responseStart":255,"responseEnd":265,"domLoading":258,"domInteractive":1172,"domContentLoadedEventStart":1172,"domContentLoadedEventEnd":1230,"domComplete":1599,"loadEventStart":1599,"loadEventEnd":1599,"userAgent":"Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)","marks":[{"name":"bigPipe.sidebar-id.start","time":1157.3999996185303},{"name":"bigPipe.sidebar-id.end","time":1158.1999998092651},{"name":"bigPipe.activity-panel-pipe-id.start","time":1158.3999996185303},{"name":"bigPipe.activity-panel-pipe-id.end","time":1159.3999996185303},{"name":"activityTabFullyLoaded","time":1247.8000001907349}],"measures":[],"correlationId":"adfd49ad82e95c","effectiveType":"4g","downlink":10,"rtt":0,"serverDuration":96,"dbReadsTimeInMs":13,"dbConnsTimeInMs":20,"applicationHash":"9d11dbea5f4be3d4cc21f03a88dd11d8c8687422","experiments":[]}}
Problem was that for cases like:
SELECT ... WHERE XX IN (SELECT YY)
this was transformed to something like:
SELECT ... WHERE IF_EXISTS(SELECT ... HAVING XX=YY)
The bug was that for normal execution XX was fixed in the original outer SELECT context while in PS it was fixed in the sub query context and this confused the optimizer.
Fixed by ensuring that XX is always fixed in the outer context.