The below diff shows incorrect outputs on the federatedx storage engine:
diff --git a/mysql-test/suite/federated/federatedx_create_handlers.result b/mysql-test/suite/federated/federatedx_create_handlers.result
|
index 044f64c796f..8da86fdd016 100644
|
--- a/mysql-test/suite/federated/federatedx_create_handlers.result
|
+++ b/mysql-test/suite/federated/federatedx_create_handlers.result
|
@@ -550,6 +550,36 @@ CREATE TABLE t3 (a varchar(30)) ENGINE=MyISAM;
|
CREATE TABLE t4 (a varchar(30)) ENGINE=MyISAM;
|
INSERT INTO t3 VALUES ('t3_myisam1'), ('t3_myisam2'), ('t3_myisam3');
|
INSERT INTO t4 VALUES ('t4_myisam1'), ('t4_myisam2'), ('t4_myisam3');
|
+SELECT 1, a FROM federated.t1 UNION ALL SELECT 2, a FROM federated.t2 ORDER BY 3;
|
+1 a
|
+1 abc
|
+1 bcd
|
+1 cde
|
+2 abc
|
+2 bcd
|
+2 cde
|
+2 def
|
+2 efg
|
+SELECT a FROM federated.t1 UNION ALL SELECT a FROM federated.t2 ORDER BY 2;
|
+a
|
+abc
|
+bcd
|
+cde
|
+abc
|
+bcd
|
+cde
|
+def
|
+efg
|
+SELECT a FROM federated.t1 UNION ALL SELECT a FROM federated.t2 ORDER BY 1;
|
+a
|
+abc
|
+bcd
|
+cde
|
+abc
|
+bcd
|
+cde
|
+def
|
+efg
|
# Pushdown of the whole UNION
|
SELECT * from federated.t1 UNION SELECT * from federated.t2;
|
a
|
diff --git a/mysql-test/suite/federated/federatedx_create_handlers.test b/mysql-test/suite/federated/federatedx_create_handlers.test
|
index 8ad3172b35d..f9bdb9cf04e 100644
|
--- a/mysql-test/suite/federated/federatedx_create_handlers.test
|
+++ b/mysql-test/suite/federated/federatedx_create_handlers.test
|
@@ -421,6 +421,10 @@ CREATE TABLE t4 (a varchar(30)) ENGINE=MyISAM;
|
INSERT INTO t3 VALUES ('t3_myisam1'), ('t3_myisam2'), ('t3_myisam3');
|
INSERT INTO t4 VALUES ('t4_myisam1'), ('t4_myisam2'), ('t4_myisam3');
|
|
+SELECT 1, a FROM federated.t1 UNION ALL SELECT 2, a FROM federated.t2 ORDER BY 3;
|
+SELECT a FROM federated.t1 UNION ALL SELECT a FROM federated.t2 ORDER BY 2;
|
+SELECT a FROM federated.t1 UNION ALL SELECT a FROM federated.t2 ORDER BY 1;
|
+
|
--echo # Pushdown of the whole UNION
|
SELECT * from federated.t1 UNION SELECT * from federated.t2;
|
EXPLAIN SELECT * from federated.t1 UNION SELECT * from federated.t2;
|
The expected output for the above 3 queries should be as follows (here i1 and i2 are equivalent InnoDB tables):
MariaDB [test]> SELECT 1, a FROM i1 UNION ALL SELECT 2, a FROM i2 ORDER BY 3;
|
ERROR 1054 (42S22): Unknown column '3' in 'order clause'
|
MariaDB [test]> SELECT a FROM i1 UNION ALL SELECT a FROM i2 ORDER BY 2;
|
ERROR 1054 (42S22): Unknown column '2' in 'order clause'
|
MariaDB [test]> SELECT a FROM i1 UNION ALL SELECT a FROM i2 ORDER BY 1;
|
+------+
|
| a |
|
+------+
|
| abc |
|
| abc |
|
| bcd |
|
| bcd |
|
| cde |
|
| cde |
|
| def |
|
| efg |
|
+------+
|
8 rows in set (0.003 sec)
|
It is possible query 3 is currently not supported by the federatedx storage engine. But for queries 1 and 2, the server should error out (as is the case with InnoDB) before attempting to pushdown the query to the foreign engine.
{"report":{"fcp":886.8999996185303,"ttfb":279.5,"pageVisibility":"visible","entityId":120047,"key":"jira.project.issue.view-issue","isInitial":true,"threshold":1000,"elementTimings":{},"userDeviceMemory":8,"userDeviceProcessors":64,"apdex":1,"journeyId":"945bdf72-cce6-43cf-bf95-dbb165d0b3f8","navigationType":0,"readyForUser":988.8999996185303,"redirectCount":0,"resourceLoadedEnd":620.2999992370605,"resourceLoadedStart":284.5999994277954,"resourceTiming":[{"duration":18.199999809265137,"initiatorType":"link","name":"https://jira.mariadb.org/s/2c21342762a6a02add1c328bed317ffd-CDN/lu2cib/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/css/_super/batch.css","startTime":284.5999994277954,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":284.5999994277954,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":302.79999923706055,"responseStart":0,"secureConnectionStart":0},{"duration":18.300000190734863,"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":284.8999996185303,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":284.8999996185303,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":303.19999980926514,"responseStart":0,"secureConnectionStart":0},{"duration":197.0999994277954,"initiatorType":"script","name":"https://jira.mariadb.org/s/0917945aaa57108d00c5076fea35e069-CDN/lu2cib/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/js/_super/batch.js?locale=en","startTime":285,"connectEnd":285,"connectStart":285,"domainLookupEnd":285,"domainLookupStart":285,"fetchStart":285,"redirectEnd":0,"redirectStart":0,"requestStart":305.29999923706055,"responseEnd":482.0999994277954,"responseStart":338.5,"secureConnectionStart":285},{"duration":335.0999994277954,"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":285.19999980926514,"connectEnd":285.19999980926514,"connectStart":285.19999980926514,"domainLookupEnd":285.19999980926514,"domainLookupStart":285.19999980926514,"fetchStart":285.19999980926514,"redirectEnd":0,"redirectStart":0,"requestStart":307.19999980926514,"responseEnd":620.2999992370605,"responseStart":339.29999923706055,"secureConnectionStart":285.19999980926514},{"duration":61.69999980926514,"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":285.3999996185303,"connectEnd":285.3999996185303,"connectStart":285.3999996185303,"domainLookupEnd":285.3999996185303,"domainLookupStart":285.3999996185303,"fetchStart":285.3999996185303,"redirectEnd":0,"redirectStart":0,"requestStart":310.5,"responseEnd":347.0999994277954,"responseStart":344.5,"secureConnectionStart":285.3999996185303},{"duration":59.90000057220459,"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":285.5999994277954,"connectEnd":285.5999994277954,"connectStart":285.5999994277954,"domainLookupEnd":285.5999994277954,"domainLookupStart":285.5999994277954,"fetchStart":285.5999994277954,"redirectEnd":0,"redirectStart":0,"requestStart":310.29999923706055,"responseEnd":345.5,"responseStart":343.3999996185303,"secureConnectionStart":285.5999994277954},{"duration":61.59999942779541,"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":285.69999980926514,"connectEnd":285.69999980926514,"connectStart":285.69999980926514,"domainLookupEnd":285.69999980926514,"domainLookupStart":285.69999980926514,"fetchStart":285.69999980926514,"redirectEnd":0,"redirectStart":0,"requestStart":310.79999923706055,"responseEnd":347.29999923706055,"responseStart":345.5999994277954,"secureConnectionStart":285.69999980926514},{"duration":22.5,"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":286,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":286,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":308.5,"responseStart":0,"secureConnectionStart":0},{"duration":65.39999961853027,"initiatorType":"script","name":"https://jira.mariadb.org/rest/api/1.0/shortcuts/820016/47140b6e0a9bc2e4913da06536125810/shortcuts.js?context=issuenavigation&context=issueaction","startTime":286.19999980926514,"connectEnd":286.19999980926514,"connectStart":286.19999980926514,"domainLookupEnd":286.19999980926514,"domainLookupStart":286.19999980926514,"fetchStart":286.19999980926514,"redirectEnd":0,"redirectStart":0,"requestStart":313.69999980926514,"responseEnd":351.5999994277954,"responseStart":349.29999923706055,"secureConnectionStart":286.19999980926514},{"duration":23.199999809265137,"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":286.3999996185303,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":286.3999996185303,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":309.5999994277954,"responseStart":0,"secureConnectionStart":0},{"duration":67.19999980926514,"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":286.5,"connectEnd":286.5,"connectStart":286.5,"domainLookupEnd":286.5,"domainLookupStart":286.5,"fetchStart":286.5,"redirectEnd":0,"redirectStart":0,"requestStart":313.8999996185303,"responseEnd":353.69999980926514,"responseStart":350.69999980926514,"secureConnectionStart":286.5},{"duration":267,"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":292.5999994277954,"connectEnd":292.5999994277954,"connectStart":292.5999994277954,"domainLookupEnd":292.5999994277954,"domainLookupStart":292.5999994277954,"fetchStart":292.5999994277954,"redirectEnd":0,"redirectStart":0,"requestStart":324.8999996185303,"responseEnd":559.5999994277954,"responseStart":552.2999992370605,"secureConnectionStart":292.5999994277954},{"duration":268.80000019073486,"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":292.79999923706055,"connectEnd":292.79999923706055,"connectStart":292.79999923706055,"domainLookupEnd":292.79999923706055,"domainLookupStart":292.79999923706055,"fetchStart":292.79999923706055,"redirectEnd":0,"redirectStart":0,"requestStart":333.79999923706055,"responseEnd":561.5999994277954,"responseStart":557.1999998092651,"secureConnectionStart":292.79999923706055},{"duration":170,"initiatorType":"xmlhttprequest","name":"https://jira.mariadb.org/rest/webResources/1.0/resources","startTime":624,"connectEnd":624,"connectStart":624,"domainLookupEnd":624,"domainLookupStart":624,"fetchStart":624,"redirectEnd":0,"redirectStart":0,"requestStart":755.1999998092651,"responseEnd":794,"responseStart":792.2999992370605,"secureConnectionStart":624},{"duration":181,"initiatorType":"xmlhttprequest","name":"https://jira.mariadb.org/rest/webResources/1.0/resources","startTime":843.5,"connectEnd":843.5,"connectStart":843.5,"domainLookupEnd":843.5,"domainLookupStart":843.5,"fetchStart":843.5,"redirectEnd":0,"redirectStart":0,"requestStart":987.0999994277954,"responseEnd":1024.5,"responseStart":1023.3999996185303,"secureConnectionStart":843.5},{"duration":194.69999980926514,"initiatorType":"script","name":"https://www.google-analytics.com/analytics.js","startTime":880.8999996185303,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":880.8999996185303,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":1075.5999994277954,"responseStart":0,"secureConnectionStart":0}],"fetchStart":0,"domainLookupStart":0,"domainLookupEnd":0,"connectStart":0,"connectEnd":0,"requestStart":69,"responseStart":279,"responseEnd":289,"domLoading":282,"domInteractive":1109,"domContentLoadedEventStart":1109,"domContentLoadedEventEnd":1170,"domComplete":1476,"loadEventStart":1476,"loadEventEnd":1476,"userAgent":"Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)","marks":[{"name":"bigPipe.sidebar-id.start","time":1080.8999996185303},{"name":"bigPipe.sidebar-id.end","time":1081.6999998092651},{"name":"bigPipe.activity-panel-pipe-id.start","time":1081.7999992370605},{"name":"bigPipe.activity-panel-pipe-id.end","time":1083.6999998092651},{"name":"activityTabFullyLoaded","time":1187.5}],"measures":[],"correlationId":"a7449f9eb36d97","effectiveType":"4g","downlink":9.2,"rtt":0,"serverDuration":114,"dbReadsTimeInMs":17,"dbConnsTimeInMs":25,"applicationHash":"9d11dbea5f4be3d4cc21f03a88dd11d8c8687422","experiments":[]}}
select a from t1 union all select a from t2 order by 2;
>> Server execution not reaching find_order_in_list() in sql/sql_select.cc is the problem/bug here
Such a union is processed in MariaDB in the following way (when there is no pushdown).
First results from parts of the union are stored into a temporary table (select a from t1 union select a from t2). Then a special structure fake_select_lex is created which is responsible for retrieving data from that temporary table applying ORDER BY. So the error about wrong ORDER BY appears only at the stage of fake_select_lex processing.
In the case of pushdown fake_select_lex is not involved in processing that's why there is no error on MariaDB side either.
find_order_in_list() is called for a JOIN corresponding to the execution of fake_select_lex mentioned above. When fake_select_lex isn't employed there's no call to find_order_in_list().
So it's more an architectural drawback than a bug. We'll think whether this can be solved without significant rework of unions processing.