-
Task
-
-
Major
-
Resolution:
Fixed
-
-
-
Under terms of this task we'll port a similar task MDEV-10597 (that was previously done for sql_mode=ORACLE) to the default sql_mode.
As of version 10.2, the cursor related statements look like:
DECLARE cursor_name CURSOR FOR select_statement;
|
OPEN cursor_name;
|
We'll extend this syntax to allow parameters.
DECLARE cursor_name [cursor_formal_parameter[,...]] CURSOR FOR select_statement;
|
|
OPEN cursor_name [expression[,...]];
|
|
cursor_formal_parameter:
|
name type [collate clause]
|
This is a non-standard SQL extension.
Cursor parameters can appear in any parts of select_statement where a stored procedure variable is allowed (select list, WHERE, HAVING, LIMIT etc)
Example:
DROP PROCEDURE IF EXISTS p1;
|
DROP TABLE IF EXISTS t1;
|
CREATE TABLE t1 (a INT, b VARCHAR(10));
|
INSERT INTO t1 VALUES (1,'old'),(2,'old'),(3,'old'),(4,'old'),(5,'old');
|
|
DELIMITER $$
|
CREATE PROCEDURE p1(min INT,max INT)
|
BEGIN
|
DECLARE done INT DEFAULT FALSE;
|
DECLARE va INT;
|
DECLARE cur CURSOR(pmin INT, pmax INT) FOR SELECT a FROM t1 WHERE a BETWEEN pmin AND pmax;
|
DECLARE CONTINUE HANDLER FOR NOT FOUND SET done=TRUE;
|
OPEN cur(min,max);
|
read_loop: LOOP
|
FETCH cur INTO va;
|
IF done THEN
|
LEAVE read_loop;
|
END IF;
|
INSERT INTO t1 VALUES (va,'new');
|
END LOOP;
|
CLOSE cur;
|
END;
|
$$
|
DELIMITER ;
|
CALL p1(2,4);
|
SELECT * FROM t1;
|
+------+------+
|
| a | b |
|
+------+------+
|
| 1 | old |
|
| 2 | old |
|
| 3 | old |
|
| 4 | old |
|
| 5 | old |
|
| 2 | new |
|
| 3 | new |
|
| 4 | new |
|
+------+------+
|
- relates to
-
MDEV-10597
sql_mode=ORACLE: Cursors with parameters
-
-
Closed
There are no comments yet on this issue.
{"report":{"fcp":1289.6000003814697,"ttfb":435.69999980926514,"pageVisibility":"visible","entityId":60853,"key":"jira.project.issue.view-issue","isInitial":true,"threshold":1000,"elementTimings":{},"userDeviceMemory":8,"userDeviceProcessors":64,"apdex":0.5,"journeyId":"c72e34a2-6490-41d4-9aeb-dee0e364fdba","navigationType":0,"readyForUser":1406.3999996185303,"redirectCount":0,"resourceLoadedEnd":1536.1999998092651,"resourceLoadedStart":441.6000003814697,"resourceTiming":[{"duration":231.5999994277954,"initiatorType":"link","name":"https://jira.mariadb.org/s/2c21342762a6a02add1c328bed317ffd-CDN/lu2cib/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/css/_super/batch.css","startTime":441.6000003814697,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":441.6000003814697,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":673.1999998092651,"responseStart":0,"secureConnectionStart":0},{"duration":231.60000038146973,"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":441.8999996185303,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":441.8999996185303,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":673.5,"responseStart":0,"secureConnectionStart":0},{"duration":260.69999980926514,"initiatorType":"script","name":"https://jira.mariadb.org/s/0917945aaa57108d00c5076fea35e069-CDN/lu2cib/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/js/_super/batch.js?locale=en","startTime":442.1000003814697,"connectEnd":442.1000003814697,"connectStart":442.1000003814697,"domainLookupEnd":442.1000003814697,"domainLookupStart":442.1000003814697,"fetchStart":442.1000003814697,"redirectEnd":0,"redirectStart":0,"requestStart":442.1000003814697,"responseEnd":702.8000001907349,"responseStart":702.8000001907349,"secureConnectionStart":442.1000003814697},{"duration":331.19999980926514,"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":442.19999980926514,"connectEnd":442.19999980926514,"connectStart":442.19999980926514,"domainLookupEnd":442.19999980926514,"domainLookupStart":442.19999980926514,"fetchStart":442.19999980926514,"redirectEnd":0,"redirectStart":0,"requestStart":442.19999980926514,"responseEnd":773.3999996185303,"responseStart":773.3999996185303,"secureConnectionStart":442.19999980926514},{"duration":336,"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":442.3999996185303,"connectEnd":442.3999996185303,"connectStart":442.3999996185303,"domainLookupEnd":442.3999996185303,"domainLookupStart":442.3999996185303,"fetchStart":442.3999996185303,"redirectEnd":0,"redirectStart":0,"requestStart":442.3999996185303,"responseEnd":778.3999996185303,"responseStart":778.3999996185303,"secureConnectionStart":442.3999996185303},{"duration":335.69999980926514,"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":443.19999980926514,"connectEnd":443.19999980926514,"connectStart":443.19999980926514,"domainLookupEnd":443.19999980926514,"domainLookupStart":443.19999980926514,"fetchStart":443.19999980926514,"redirectEnd":0,"redirectStart":0,"requestStart":443.19999980926514,"responseEnd":778.8999996185303,"responseStart":778.8999996185303,"secureConnectionStart":443.19999980926514},{"duration":336.1000003814697,"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":443.3999996185303,"connectEnd":443.3999996185303,"connectStart":443.3999996185303,"domainLookupEnd":443.3999996185303,"domainLookupStart":443.3999996185303,"fetchStart":443.3999996185303,"redirectEnd":0,"redirectStart":0,"requestStart":443.3999996185303,"responseEnd":779.5,"responseStart":779.5,"secureConnectionStart":443.3999996185303},{"duration":463.29999923706055,"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":443.6000003814697,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":443.6000003814697,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":906.8999996185303,"responseStart":0,"secureConnectionStart":0},{"duration":336.3999996185303,"initiatorType":"script","name":"https://jira.mariadb.org/rest/api/1.0/shortcuts/820016/47140b6e0a9bc2e4913da06536125810/shortcuts.js?context=issuenavigation&context=issueaction","startTime":443.80000019073486,"connectEnd":443.80000019073486,"connectStart":443.80000019073486,"domainLookupEnd":443.80000019073486,"domainLookupStart":443.80000019073486,"fetchStart":443.80000019073486,"redirectEnd":0,"redirectStart":0,"requestStart":443.80000019073486,"responseEnd":780.1999998092651,"responseStart":780.1999998092651,"secureConnectionStart":443.80000019073486},{"duration":463.20000076293945,"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":443.8999996185303,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":443.8999996185303,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":907.1000003814697,"responseStart":0,"secureConnectionStart":0},{"duration":336.79999923706055,"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":444.1000003814697,"connectEnd":444.1000003814697,"connectStart":444.1000003814697,"domainLookupEnd":444.1000003814697,"domainLookupStart":444.1000003814697,"fetchStart":444.1000003814697,"redirectEnd":0,"redirectStart":0,"requestStart":444.1000003814697,"responseEnd":780.8999996185303,"responseStart":780.8999996185303,"secureConnectionStart":444.1000003814697},{"duration":933.2000007629395,"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":452.3999996185303,"connectEnd":452.3999996185303,"connectStart":452.3999996185303,"domainLookupEnd":452.3999996185303,"domainLookupStart":452.3999996185303,"fetchStart":452.3999996185303,"redirectEnd":0,"redirectStart":0,"requestStart":452.3999996185303,"responseEnd":1385.6000003814697,"responseStart":1385.6000003814697,"secureConnectionStart":452.3999996185303},{"duration":1083.6999998092651,"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":452.5,"connectEnd":452.5,"connectStart":452.5,"domainLookupEnd":452.5,"domainLookupStart":452.5,"fetchStart":452.5,"redirectEnd":0,"redirectStart":0,"requestStart":452.5,"responseEnd":1536.1999998092651,"responseStart":1536.1999998092651,"secureConnectionStart":452.5},{"duration":459,"initiatorType":"xmlhttprequest","name":"https://jira.mariadb.org/rest/webResources/1.0/resources","startTime":927.6999998092651,"connectEnd":927.6999998092651,"connectStart":927.6999998092651,"domainLookupEnd":927.6999998092651,"domainLookupStart":927.6999998092651,"fetchStart":927.6999998092651,"redirectEnd":0,"redirectStart":0,"requestStart":927.6999998092651,"responseEnd":1386.6999998092651,"responseStart":1386.6999998092651,"secureConnectionStart":927.6999998092651},{"duration":265.30000019073486,"initiatorType":"script","name":"https://www.google-analytics.com/analytics.js","startTime":1281.8999996185303,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":1281.8999996185303,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":1547.1999998092651,"responseStart":0,"secureConnectionStart":0}],"fetchStart":0,"domainLookupStart":0,"domainLookupEnd":0,"connectStart":0,"connectEnd":0,"requestStart":253,"responseStart":436,"responseEnd":451,"domLoading":440,"domInteractive":1585,"domContentLoadedEventStart":1585,"domContentLoadedEventEnd":1645,"domComplete":2213,"loadEventStart":2213,"loadEventEnd":2214,"userAgent":"Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)","marks":[{"name":"bigPipe.sidebar-id.start","time":1551.1000003814697},{"name":"bigPipe.sidebar-id.end","time":1551.8999996185303},{"name":"bigPipe.activity-panel-pipe-id.start","time":1552.1000003814697},{"name":"bigPipe.activity-panel-pipe-id.end","time":1554.6000003814697},{"name":"activityTabFullyLoaded","time":1653}],"measures":[],"correlationId":"46883055382658","effectiveType":"4g","downlink":10,"rtt":0,"serverDuration":111,"dbReadsTimeInMs":16,"dbConnsTimeInMs":27,"applicationHash":"9d11dbea5f4be3d4cc21f03a88dd11d8c8687422","experiments":[]}}