-
Task
-
-
Minor
-
Resolution:
Unresolved
-
None
-
None
-
Idea
User functions (UDF-like) that return a table, rows and columns. It should be possible to use it in other statements. For example
SELECT * FROM t1, tf(15,"foobar") AS t2 WHERE t1.a=t2.b
|
We might (or might not) specify that all function arguments must be constants.
UDF
- It won't be a UDF, of course, but a new plugin type.
- it'll use a generator interface
SQL
SQL Standard says
this is my understanding of the standard. it might be wrong
To define a table function one uses
CREATE FUNCTION ... RETURNS TABLE (column type [, column type ...])
|
It should return a table expression, which pretty much means either
or
CREATE LOCAL TEMPORARY TABLE t1 (...)
|
INSERT t1 VALUES (...)
|
RETURN t1;
|
and it's used as
SELECT ... FROM TABLE(func(arg1, arg2, ...)) ...
|
Optimizations
Trivial function (with the body of only RETURN SELECT) can be treated as view. But I'm not sure it's a use case worth optimizing.
Complex function can be changed from materializing to streaming if we can be sure that every inserted row is guaranteed to be returned. That is:
- it uses exactly the second pattern above. CREATE/INSERT/RETURN.
- CREATE and RETURN are not conditional.
- No DELETE, no UPDATE, no TRUNCATE, no ALTER, etc.
- No dynamic SQL
{"report":{"fcp":923.9000000953674,"ttfb":243.90000009536743,"pageVisibility":"visible","entityId":26200,"key":"jira.project.issue.view-issue","isInitial":true,"threshold":1000,"elementTimings":{},"userDeviceMemory":8,"userDeviceProcessors":64,"apdex":0.5,"journeyId":"79203283-ef73-481f-9622-9ce315be82df","navigationType":0,"readyForUser":1001.5,"redirectCount":0,"resourceLoadedEnd":1089.7000000476837,"resourceLoadedStart":256.7000000476837,"resourceTiming":[{"duration":120,"initiatorType":"link","name":"https://jira.mariadb.org/s/2c21342762a6a02add1c328bed317ffd-CDN/lu2bu7/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/css/_super/batch.css","startTime":256.7000000476837,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":256.7000000476837,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":376.7000000476837,"responseStart":0,"secureConnectionStart":0},{"duration":119.89999985694885,"initiatorType":"link","name":"https://jira.mariadb.org/s/7ebd35e77e471bc30ff0eba799ebc151-CDN/lu2bu7/820016/12ta74/8679b4946efa1a0bb029a3a22206fb5d/_/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":256.90000009536743,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":256.90000009536743,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":376.7999999523163,"responseStart":0,"secureConnectionStart":0},{"duration":181.10000014305115,"initiatorType":"script","name":"https://jira.mariadb.org/s/fbf975c0cce4b1abf04784eeae9ba1f4-CDN/lu2bu7/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/js/_super/batch.js?locale=en","startTime":257,"connectEnd":257,"connectStart":257,"domainLookupEnd":257,"domainLookupStart":257,"fetchStart":257,"redirectEnd":0,"redirectStart":0,"requestStart":257,"responseEnd":438.10000014305115,"responseStart":438.10000014305115,"secureConnectionStart":257},{"duration":298.5,"initiatorType":"script","name":"https://jira.mariadb.org/s/099b33461394b8015fc36c0a4b96e19f-CDN/lu2bu7/820016/12ta74/8679b4946efa1a0bb029a3a22206fb5d/_/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":257.10000014305115,"connectEnd":257.10000014305115,"connectStart":257.10000014305115,"domainLookupEnd":257.10000014305115,"domainLookupStart":257.10000014305115,"fetchStart":257.10000014305115,"redirectEnd":0,"redirectStart":0,"requestStart":257.10000014305115,"responseEnd":555.6000001430511,"responseStart":555.6000001430511,"secureConnectionStart":257.10000014305115},{"duration":302.5,"initiatorType":"script","name":"https://jira.mariadb.org/s/94c15bff32baef80f4096a08aceae8bc-CDN/lu2bu7/820016/12ta74/c92c0caa9a024ae85b0ebdbed7fb4bd7/_/download/contextbatch/js/atl.global,-_super/batch.js?locale=en","startTime":257.2000000476837,"connectEnd":257.2000000476837,"connectStart":257.2000000476837,"domainLookupEnd":257.2000000476837,"domainLookupStart":257.2000000476837,"fetchStart":257.2000000476837,"redirectEnd":0,"redirectStart":0,"requestStart":257.2000000476837,"responseEnd":559.7000000476837,"responseStart":559.7000000476837,"secureConnectionStart":257.2000000476837},{"duration":303.2000000476837,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2bu7/820016/12ta74/1.0/_/download/batch/jira.webresources:calendar-en/jira.webresources:calendar-en.js","startTime":257.2999999523163,"connectEnd":257.2999999523163,"connectStart":257.2999999523163,"domainLookupEnd":257.2999999523163,"domainLookupStart":257.2999999523163,"fetchStart":257.2999999523163,"redirectEnd":0,"redirectStart":0,"requestStart":257.2999999523163,"responseEnd":560.5,"responseStart":560.5,"secureConnectionStart":257.2999999523163},{"duration":303.5,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2bu7/820016/12ta74/1.0/_/download/batch/jira.webresources:calendar-localisation-moment/jira.webresources:calendar-localisation-moment.js","startTime":257.2999999523163,"connectEnd":257.2999999523163,"connectStart":257.2999999523163,"domainLookupEnd":257.2999999523163,"domainLookupStart":257.2999999523163,"fetchStart":257.2999999523163,"redirectEnd":0,"redirectStart":0,"requestStart":257.2999999523163,"responseEnd":560.7999999523163,"responseStart":560.7999999523163,"secureConnectionStart":257.2999999523163},{"duration":303.7999999523163,"initiatorType":"link","name":"https://jira.mariadb.org/s/b04b06a02d1959df322d9cded3aeecc1-CDN/lu2bu7/820016/12ta74/a2ff6aa845ffc9a1d22fe23d9ee791fc/_/download/contextbatch/css/jira.global.look-and-feel,-_super/batch.css","startTime":257.5,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":257.5,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":561.2999999523163,"responseStart":0,"secureConnectionStart":0},{"duration":303.69999980926514,"initiatorType":"script","name":"https://jira.mariadb.org/rest/api/1.0/shortcuts/820016/47140b6e0a9bc2e4913da06536125810/shortcuts.js?context=issuenavigation&context=issueaction","startTime":257.60000014305115,"connectEnd":257.60000014305115,"connectStart":257.60000014305115,"domainLookupEnd":257.60000014305115,"domainLookupStart":257.60000014305115,"fetchStart":257.60000014305115,"redirectEnd":0,"redirectStart":0,"requestStart":257.60000014305115,"responseEnd":561.2999999523163,"responseStart":561.2999999523163,"secureConnectionStart":257.60000014305115},{"duration":304,"initiatorType":"link","name":"https://jira.mariadb.org/s/3ac36323ba5e4eb0af2aa7ac7211b4bb-CDN/lu2bu7/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":257.7000000476837,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":257.7000000476837,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":561.7000000476837,"responseStart":0,"secureConnectionStart":0},{"duration":304,"initiatorType":"script","name":"https://jira.mariadb.org/s/3339d87fa2538a859872f2df449bf8d0-CDN/lu2bu7/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":257.90000009536743,"connectEnd":257.90000009536743,"connectStart":257.90000009536743,"domainLookupEnd":257.90000009536743,"domainLookupStart":257.90000009536743,"fetchStart":257.90000009536743,"redirectEnd":0,"redirectStart":0,"requestStart":257.90000009536743,"responseEnd":561.9000000953674,"responseStart":561.9000000953674,"secureConnectionStart":257.90000009536743},{"duration":506.59999990463257,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2bu7/820016/12ta74/1.0/_/download/batch/jira.webresources:bigpipe-js/jira.webresources:bigpipe-js.js","startTime":270.7000000476837,"connectEnd":270.7000000476837,"connectStart":270.7000000476837,"domainLookupEnd":270.7000000476837,"domainLookupStart":270.7000000476837,"fetchStart":270.7000000476837,"redirectEnd":0,"redirectStart":0,"requestStart":270.7000000476837,"responseEnd":777.2999999523163,"responseStart":777.2999999523163,"secureConnectionStart":270.7000000476837},{"duration":817.7000000476837,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2bu7/820016/12ta74/1.0/_/download/batch/jira.webresources:bigpipe-init/jira.webresources:bigpipe-init.js","startTime":270.7999999523163,"connectEnd":270.7999999523163,"connectStart":270.7999999523163,"domainLookupEnd":270.7999999523163,"domainLookupStart":270.7999999523163,"fetchStart":270.7999999523163,"redirectEnd":0,"redirectStart":0,"requestStart":270.7999999523163,"responseEnd":1088.5,"responseStart":1088.5,"secureConnectionStart":270.7999999523163},{"duration":186.90000009536743,"initiatorType":"xmlhttprequest","name":"https://jira.mariadb.org/rest/webResources/1.0/resources","startTime":625,"connectEnd":625,"connectStart":625,"domainLookupEnd":625,"domainLookupStart":625,"fetchStart":625,"redirectEnd":0,"redirectStart":0,"requestStart":625,"responseEnd":811.9000000953674,"responseStart":811.9000000953674,"secureConnectionStart":625},{"duration":223,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2bu7/820016/12ta74/e65b778d185daf5aee24936755b43da6/_/download/contextbatch/js/browser-metrics-plugin.contrib,-_super,-project.issue.navigator,-jira.view.issue,-atl.general/batch.js?agile_global_admin_condition=true&jag=true&jira.create.linked.issue=true&slack-enabled=true","startTime":866.7000000476837,"connectEnd":866.7000000476837,"connectStart":866.7000000476837,"domainLookupEnd":866.7000000476837,"domainLookupStart":866.7000000476837,"fetchStart":866.7000000476837,"redirectEnd":0,"redirectStart":0,"requestStart":866.7000000476837,"responseEnd":1089.7000000476837,"responseStart":1089.7000000476837,"secureConnectionStart":866.7000000476837},{"duration":192.29999995231628,"initiatorType":"script","name":"https://www.google-analytics.com/analytics.js","startTime":916.6000001430511,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":916.6000001430511,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":1108.9000000953674,"responseStart":0,"secureConnectionStart":0}],"fetchStart":0,"domainLookupStart":0,"domainLookupEnd":0,"connectStart":0,"connectEnd":0,"requestStart":118,"responseStart":244,"responseEnd":270,"domLoading":248,"domInteractive":1151,"domContentLoadedEventStart":1151,"domContentLoadedEventEnd":1199,"domComplete":1751,"loadEventStart":1751,"loadEventEnd":1752,"userAgent":"Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)","marks":[{"name":"bigPipe.sidebar-id.start","time":1126.1000001430511},{"name":"bigPipe.sidebar-id.end","time":1127},{"name":"bigPipe.activity-panel-pipe-id.start","time":1127.2000000476837},{"name":"bigPipe.activity-panel-pipe-id.end","time":1129.7999999523163},{"name":"activityTabFullyLoaded","time":1209.2000000476837}],"measures":[],"correlationId":"d0ed7dd58d43e4","effectiveType":"4g","downlink":9.3,"rtt":0,"serverDuration":73,"dbReadsTimeInMs":13,"dbConnsTimeInMs":20,"applicationHash":"9d11dbea5f4be3d4cc21f03a88dd11d8c8687422","experiments":[]}}