The following fails to produce the expected output.
(using example table from https://mariadb.com/kb/en/mariadb/oqgraph-examples/ )
CREATE TABLE oq_backing (
|
origid INT UNSIGNED NOT NULL,
|
destid INT UNSIGNED NOT NULL,
|
PRIMARY KEY (origid, destid),
|
KEY (destid)
|
);
|
INSERT INTO oq_backing(origid, destid)
|
VALUES (1,2), (2,3), (3,4), (4,5), (2,6), (5,6);
|
CREATE TABLE oq_graph (
|
latch VARCHAR(32) NULL,
|
origid BIGINT UNSIGNED NULL,
|
destid BIGINT UNSIGNED NULL,
|
weight DOUBLE NULL,
|
seq BIGINT UNSIGNED NULL,
|
linkid BIGINT UNSIGNED NULL,
|
KEY (latch, origid, destid) USING HASH,
|
KEY (latch, destid, origid) USING HASH
|
)
|
ENGINE=OQGRAPH
|
data_table='oq_backing' origid='origid' destid='destid';
|
select * from oq_backing;
|
+--------+--------+
|
| origid | destid |
|
+--------+--------+
|
| 1 | 2 |
|
| 2 | 3 |
|
| 2 | 6 |
|
| 3 | 4 |
|
| 4 | 5 |
|
| 5 | 6 |
|
+--------+--------+
|
|
This works:
SELECT GROUP_CONCAT(linkid ORDER BY seq) AS path FROM oq_graph WHERE latch='breadth_first' AND origid=4;
|
This fails:
select ob.origid, (select group_concat(pt.linkid order by pt.seq desc separator '>') from oq_graph as pt where pt.latch='breadth_first' and pt.origid=ob.origid) from oq_backing as ob;
|
|
+--------+------------------------------------------------------------------------------------------------------------------------------------------------+
|
| origid | (select group_concat(pt.linkid order by pt.seq desc separator '>') from oq_graph as pt where pt.latch='breadth_first' and pt.origid=ob.origid) |
|
+--------+------------------------------------------------------------------------------------------------------------------------------------------------+
|
| 1 | NULL |
|
| 2 | NULL |
|
| 2 | NULL |
|
| 3 | NULL |
|
| 4 | NULL |
|
| 5 | NULL |
|
+--------+------------------------------------------------------------------------------------------------------------------------------------------------+
|
6 rows in set (0.00 sec)
|
|
Ultimately what I'm trying to accomplish is to perform a query in a table that has a "location" field (the location is tree), I need to perform a subquery to return a "path" for each row.
Here is my "real world" query example:
select group_concat(l.Name order by pt.seq desc separator '>')
|
from Loc_graph as pt
|
join Location as l on l.id = pt.linkid
|
where pt.latch = 'breadth_first' and pt.origid=6;
|
Which returns:
However, when I embed the above as a subquery:
select loc.id,
|
( select group_concat(l.Name order by pt.seq desc separator '>')
|
from Loc_graph as pt
|
join Location as l on l.id = pt.linkid
|
where pt.latch = 'breadth_first' and pt.origid=loc.id) as path
|
from Location as loc;
|
I get the following
+----+------+
|
| id | path |
|
+----+------+
|
| 1 | NULL |
|
| 2 | NULL |
|
| 3 | NULL |
|
| 4 | NULL |
|
| 5 | NULL |
|
| 6 | NULL |
|
| 7 | NULL |
|
| 8 | NULL |
|
| 9 | NULL |
|
| 10 | NULL |
|
| 11 | NULL |
|
| 12 | NULL |
|
| 13 | NULL |
|
| 14 | NULL |
|
| 15 | NULL |
|
| 16 | NULL |
|
| 17 | NULL |
|
| 18 | NULL |
|
| 19 | NULL |
|
| 20 | NULL |
|
| 21 | NULL |
|
| 22 | NULL |
|
| 23 | NULL |
|
| 24 | NULL |
|
| 25 | NULL |
|
| 26 | NULL |
|
| 27 | NULL |
|
| 28 | NULL |
|
| 29 | NULL |
|
| 30 | NULL |
|
| 31 | NULL |
|
+----+------+
|
- relates to
-
MDEV-627
LP:837496 - Empty resultset when joining OQGRAPH tables
-
-
Open
{"report":{"fcp":1942.5999999046326,"ttfb":419.2999997138977,"pageVisibility":"visible","entityId":60933,"key":"jira.project.issue.view-issue","isInitial":true,"threshold":1000,"elementTimings":{},"userDeviceMemory":8,"userDeviceProcessors":64,"apdex":0.5,"journeyId":"71636e54-36a1-401b-9cb5-673df1cac6d2","navigationType":0,"readyForUser":2058,"redirectCount":0,"resourceLoadedEnd":2482,"resourceLoadedStart":432.2999997138977,"resourceTiming":[{"duration":867.8000001907349,"initiatorType":"link","name":"https://jira.mariadb.org/s/2c21342762a6a02add1c328bed317ffd-CDN/lu2cib/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/css/_super/batch.css","startTime":432.2999997138977,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":432.2999997138977,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":1300.0999999046326,"responseStart":0,"secureConnectionStart":0},{"duration":868,"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":432.59999990463257,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":432.59999990463257,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":1300.5999999046326,"responseStart":0,"secureConnectionStart":0},{"duration":876.6000003814697,"initiatorType":"script","name":"https://jira.mariadb.org/s/0917945aaa57108d00c5076fea35e069-CDN/lu2cib/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/js/_super/batch.js?locale=en","startTime":432.7999997138977,"connectEnd":432.7999997138977,"connectStart":432.7999997138977,"domainLookupEnd":432.7999997138977,"domainLookupStart":432.7999997138977,"fetchStart":432.7999997138977,"redirectEnd":0,"redirectStart":0,"requestStart":432.7999997138977,"responseEnd":1309.4000000953674,"responseStart":1309.4000000953674,"secureConnectionStart":432.7999997138977},{"duration":943.2999997138977,"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":433,"connectEnd":433,"connectStart":433,"domainLookupEnd":433,"domainLookupStart":433,"fetchStart":433,"redirectEnd":0,"redirectStart":0,"requestStart":433,"responseEnd":1376.2999997138977,"responseStart":1376.2999997138977,"secureConnectionStart":433},{"duration":951.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":433.19999980926514,"connectEnd":433.19999980926514,"connectStart":433.19999980926514,"domainLookupEnd":433.19999980926514,"domainLookupStart":433.19999980926514,"fetchStart":433.19999980926514,"redirectEnd":0,"redirectStart":0,"requestStart":433.19999980926514,"responseEnd":1384.9000000953674,"responseStart":1384.9000000953674,"secureConnectionStart":433.19999980926514},{"duration":951.8999996185303,"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":433.40000009536743,"connectEnd":433.40000009536743,"connectStart":433.40000009536743,"domainLookupEnd":433.40000009536743,"domainLookupStart":433.40000009536743,"fetchStart":433.40000009536743,"redirectEnd":0,"redirectStart":0,"requestStart":433.40000009536743,"responseEnd":1385.2999997138977,"responseStart":1385.2999997138977,"secureConnectionStart":433.40000009536743},{"duration":952.1999998092651,"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":433.59999990463257,"connectEnd":433.59999990463257,"connectStart":433.59999990463257,"domainLookupEnd":433.59999990463257,"domainLookupStart":433.59999990463257,"fetchStart":433.59999990463257,"redirectEnd":0,"redirectStart":0,"requestStart":433.59999990463257,"responseEnd":1385.7999997138977,"responseStart":1385.7999997138977,"secureConnectionStart":433.59999990463257},{"duration":1036.3000001907349,"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":433.69999980926514,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":433.69999980926514,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":1470,"responseStart":0,"secureConnectionStart":0},{"duration":952.5,"initiatorType":"script","name":"https://jira.mariadb.org/rest/api/1.0/shortcuts/820016/47140b6e0a9bc2e4913da06536125810/shortcuts.js?context=issuenavigation&context=issueaction","startTime":433.90000009536743,"connectEnd":433.90000009536743,"connectStart":433.90000009536743,"domainLookupEnd":433.90000009536743,"domainLookupStart":433.90000009536743,"fetchStart":433.90000009536743,"redirectEnd":0,"redirectStart":0,"requestStart":433.90000009536743,"responseEnd":1386.4000000953674,"responseStart":1386.2999997138977,"secureConnectionStart":433.90000009536743},{"duration":1036.0999999046326,"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":434.09999990463257,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":434.09999990463257,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":1470.1999998092651,"responseStart":0,"secureConnectionStart":0},{"duration":952.6000003814697,"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":434.2999997138977,"connectEnd":434.2999997138977,"connectStart":434.2999997138977,"domainLookupEnd":434.2999997138977,"domainLookupStart":434.2999997138977,"fetchStart":434.2999997138977,"redirectEnd":0,"redirectStart":0,"requestStart":434.2999997138977,"responseEnd":1386.9000000953674,"responseStart":1386.9000000953674,"secureConnectionStart":434.2999997138977},{"duration":1625.1999998092651,"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":435,"connectEnd":435,"connectStart":435,"domainLookupEnd":435,"domainLookupStart":435,"fetchStart":435,"redirectEnd":0,"redirectStart":0,"requestStart":435,"responseEnd":2060.199999809265,"responseStart":2060.199999809265,"secureConnectionStart":435},{"duration":2046.9000000953674,"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":435.09999990463257,"connectEnd":435.09999990463257,"connectStart":435.09999990463257,"domainLookupEnd":435.09999990463257,"domainLookupStart":435.09999990463257,"fetchStart":435.09999990463257,"redirectEnd":0,"redirectStart":0,"requestStart":435.09999990463257,"responseEnd":2482,"responseStart":2482,"secureConnectionStart":435.09999990463257},{"duration":602.5999999046326,"initiatorType":"xmlhttprequest","name":"https://jira.mariadb.org/rest/webResources/1.0/resources","startTime":1483.6999998092651,"connectEnd":1483.6999998092651,"connectStart":1483.6999998092651,"domainLookupEnd":1483.6999998092651,"domainLookupStart":1483.6999998092651,"fetchStart":1483.6999998092651,"redirectEnd":0,"redirectStart":0,"requestStart":1483.6999998092651,"responseEnd":2086.2999997138977,"responseStart":2086.2999997138977,"secureConnectionStart":1483.6999998092651}],"fetchStart":0,"domainLookupStart":0,"domainLookupEnd":0,"connectStart":0,"connectEnd":0,"requestStart":253,"responseStart":419,"responseEnd":423,"domLoading":429,"domInteractive":2529,"domContentLoadedEventStart":2529,"domContentLoadedEventEnd":2577,"domComplete":3301,"loadEventStart":3302,"loadEventEnd":3302,"userAgent":"Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)","marks":[{"name":"bigPipe.sidebar-id.start","time":2505.199999809265},{"name":"bigPipe.sidebar-id.end","time":2506.0999999046326},{"name":"bigPipe.activity-panel-pipe-id.start","time":2506.2999997138977},{"name":"bigPipe.activity-panel-pipe-id.end","time":2507.699999809265},{"name":"activityTabFullyLoaded","time":2593.4000000953674}],"measures":[],"correlationId":"505c1059a553cf","effectiveType":"4g","downlink":9.8,"rtt":0,"serverDuration":93,"dbReadsTimeInMs":11,"dbConnsTimeInMs":20,"applicationHash":"9d11dbea5f4be3d4cc21f03a88dd11d8c8687422","experiments":[]}}
As a work around, I was able to create a stored function:
READS SQL DATA
BEGIN