When preparing an INSERT ... RETURNING ... statement with COM_STMT_PREPARE, the COM_STMT_PREPARE_OK response reports that the query returns 0 columns.
However, when subsequently executing the prepared statement with COM_STMT_EXECUTE, the resultset is correctly reported.
For example, against this table:
CREATE TABLE tweet
|
(
|
id BIGINT PRIMARY KEY AUTO_INCREMENT,
|
created_at TIMESTAMP NOT NULL DEFAULT NOW(),
|
text TEXT NOT NULL,
|
owner_id BIGINT
|
);
|
Preparing this statement:
INSERT INTO tweet ( text ) VALUES ( 'Hello, World' ) RETURNING *
|
The COM_STMT_PREPARE_OK response reports 0 for num_columns but the subsequent COM_STMT_EXECUTE_OK response correctly reports 4 columns.
Context: I'm a maintainer of SQLx, which is a SQL client library for Rust. We use the COM_STMT_PREPARE_OK response to construct a map of column names to column ordinals for lookup in the ResultsetRow response, and then cache that map with the prepared statement.
We also rely on the COM_STMT_PREPARE_OK response to generate code in the sqlx::query!() family of procedural macros. At compile time, we connect to a database with the same schema as the production database and use the metadata returned by prepared statements to emit code that maps the SQL row response to a Rust struct at runtime so the user can interact with the results of their query in Rust's strong, static type system.
Until this is fixed, the macros will think an INSERT ... RETURNING ... query returns 0 columns, and will thus generate incorrect code.
Related issue: https://github.com/launchbadge/sqlx/issues/1530
- relates to
-
MDEV-5092
Implement UPDATE with result set
-
-
In Review
- links to
-
-
{"report":{"fcp":630.7000000476837,"ttfb":140.30000007152557,"pageVisibility":"visible","entityId":104834,"key":"jira.project.issue.view-issue","isInitial":true,"threshold":1000,"elementTimings":{},"userDeviceMemory":8,"userDeviceProcessors":64,"apdex":1,"journeyId":"767e5d02-af61-47de-a5c5-ea60635e33ce","navigationType":0,"readyForUser":762.1000000238419,"redirectCount":0,"resourceLoadedEnd":809.3000000715256,"resourceLoadedStart":145.60000002384186,"resourceTiming":[{"duration":32.10000002384186,"initiatorType":"link","name":"https://jira.mariadb.org/s/2c21342762a6a02add1c328bed317ffd-CDN/lu2bu7/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/css/_super/batch.css","startTime":145.60000002384186,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":145.60000002384186,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":177.70000004768372,"responseStart":0,"secureConnectionStart":0},{"duration":32.09999990463257,"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":145.90000009536743,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":145.90000009536743,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":178,"responseStart":0,"secureConnectionStart":0},{"duration":87.30000007152557,"initiatorType":"script","name":"https://jira.mariadb.org/s/fbf975c0cce4b1abf04784eeae9ba1f4-CDN/lu2bu7/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/js/_super/batch.js?locale=en","startTime":146,"connectEnd":146,"connectStart":146,"domainLookupEnd":146,"domainLookupStart":146,"fetchStart":146,"redirectEnd":0,"redirectStart":0,"requestStart":146,"responseEnd":233.30000007152557,"responseStart":233.30000007152557,"secureConnectionStart":146},{"duration":167.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":146.10000002384186,"connectEnd":146.10000002384186,"connectStart":146.10000002384186,"domainLookupEnd":146.10000002384186,"domainLookupStart":146.10000002384186,"fetchStart":146.10000002384186,"redirectEnd":0,"redirectStart":0,"requestStart":146.10000002384186,"responseEnd":313.60000002384186,"responseStart":313.5,"secureConnectionStart":146.10000002384186},{"duration":171.70000004768372,"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":146.20000004768372,"connectEnd":146.20000004768372,"connectStart":146.20000004768372,"domainLookupEnd":146.20000004768372,"domainLookupStart":146.20000004768372,"fetchStart":146.20000004768372,"redirectEnd":0,"redirectStart":0,"requestStart":146.20000004768372,"responseEnd":317.90000009536743,"responseStart":317.90000009536743,"secureConnectionStart":146.20000004768372},{"duration":172.10000002384186,"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":146.30000007152557,"connectEnd":146.30000007152557,"connectStart":146.30000007152557,"domainLookupEnd":146.30000007152557,"domainLookupStart":146.30000007152557,"fetchStart":146.30000007152557,"redirectEnd":0,"redirectStart":0,"requestStart":146.30000007152557,"responseEnd":318.40000009536743,"responseStart":318.40000009536743,"secureConnectionStart":146.30000007152557},{"duration":172.29999995231628,"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":146.40000009536743,"connectEnd":146.40000009536743,"connectStart":146.40000009536743,"domainLookupEnd":146.40000009536743,"domainLookupStart":146.40000009536743,"fetchStart":146.40000009536743,"redirectEnd":0,"redirectStart":0,"requestStart":146.40000009536743,"responseEnd":318.7000000476837,"responseStart":318.7000000476837,"secureConnectionStart":146.40000009536743},{"duration":172.70000004768372,"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":146.5,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":146.5,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":319.2000000476837,"responseStart":0,"secureConnectionStart":0},{"duration":172.5,"initiatorType":"script","name":"https://jira.mariadb.org/rest/api/1.0/shortcuts/820016/47140b6e0a9bc2e4913da06536125810/shortcuts.js?context=issuenavigation&context=issueaction","startTime":146.60000002384186,"connectEnd":146.60000002384186,"connectStart":146.60000002384186,"domainLookupEnd":146.60000002384186,"domainLookupStart":146.60000002384186,"fetchStart":146.60000002384186,"redirectEnd":0,"redirectStart":0,"requestStart":146.60000002384186,"responseEnd":319.10000002384186,"responseStart":319.10000002384186,"secureConnectionStart":146.60000002384186},{"duration":172.79999995231628,"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":146.70000004768372,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":146.70000004768372,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":319.5,"responseStart":0,"secureConnectionStart":0},{"duration":172.89999997615814,"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":146.80000007152557,"connectEnd":146.80000007152557,"connectStart":146.80000007152557,"domainLookupEnd":146.80000007152557,"domainLookupStart":146.80000007152557,"fetchStart":146.80000007152557,"redirectEnd":0,"redirectStart":0,"requestStart":146.80000007152557,"responseEnd":319.7000000476837,"responseStart":319.7000000476837,"secureConnectionStart":146.80000007152557},{"duration":361.7999999523163,"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":154.20000004768372,"connectEnd":154.20000004768372,"connectStart":154.20000004768372,"domainLookupEnd":154.20000004768372,"domainLookupStart":154.20000004768372,"fetchStart":154.20000004768372,"redirectEnd":0,"redirectStart":0,"requestStart":154.20000004768372,"responseEnd":516,"responseStart":516,"secureConnectionStart":154.20000004768372},{"duration":433.39999997615814,"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":154.80000007152557,"connectEnd":154.80000007152557,"connectStart":154.80000007152557,"domainLookupEnd":154.80000007152557,"domainLookupStart":154.80000007152557,"fetchStart":154.80000007152557,"redirectEnd":0,"redirectStart":0,"requestStart":154.80000007152557,"responseEnd":588.2000000476837,"responseStart":588.2000000476837,"secureConnectionStart":154.80000007152557},{"duration":126.60000002384186,"initiatorType":"xmlhttprequest","name":"https://jira.mariadb.org/rest/webResources/1.0/resources","startTime":450.3000000715256,"connectEnd":450.3000000715256,"connectStart":450.3000000715256,"domainLookupEnd":450.3000000715256,"domainLookupStart":450.3000000715256,"fetchStart":450.3000000715256,"redirectEnd":0,"redirectStart":0,"requestStart":450.3000000715256,"responseEnd":576.9000000953674,"responseStart":576.9000000953674,"secureConnectionStart":450.3000000715256},{"duration":9.699999928474426,"initiatorType":"script","name":"https://www.google-analytics.com/analytics.js","startTime":623.8000000715256,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":623.8000000715256,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":633.5,"responseStart":0,"secureConnectionStart":0},{"duration":120.5,"initiatorType":"link","name":"https://jira.mariadb.org/s/d5715adaadd168a9002b108b2b039b50-CDN/lu2bu7/820016/12ta74/be4b45e9cec53099498fa61c8b7acba4/_/download/contextbatch/css/jira.project.sidebar,-_super,-project.issue.navigator,-jira.general,-jira.browse.project,-jira.view.issue,-jira.global,-atl.general,-com.atlassian.jira.projects.sidebar.init/batch.css?agile_global_admin_condition=true&jag=true&jira.create.linked.issue=true&slack-enabled=true","startTime":681.5,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":681.5,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":802,"responseStart":0,"secureConnectionStart":0},{"duration":120.19999992847443,"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":682.3000000715256,"connectEnd":682.3000000715256,"connectStart":682.3000000715256,"domainLookupEnd":682.3000000715256,"domainLookupStart":682.3000000715256,"fetchStart":682.3000000715256,"redirectEnd":0,"redirectStart":0,"requestStart":682.3000000715256,"responseEnd":802.5,"responseStart":802.5,"secureConnectionStart":682.3000000715256},{"duration":126.70000004768372,"initiatorType":"script","name":"https://jira.mariadb.org/s/f51ef5507eea4c158f257c66c93b2a3f-CDN/lu2bu7/820016/12ta74/be4b45e9cec53099498fa61c8b7acba4/_/download/contextbatch/js/jira.project.sidebar,-_super,-project.issue.navigator,-jira.general,-jira.browse.project,-jira.view.issue,-jira.global,-atl.general,-com.atlassian.jira.projects.sidebar.init/batch.js?agile_global_admin_condition=true&jag=true&jira.create.linked.issue=true&locale=en&slack-enabled=true","startTime":682.6000000238419,"connectEnd":682.6000000238419,"connectStart":682.6000000238419,"domainLookupEnd":682.6000000238419,"domainLookupStart":682.6000000238419,"fetchStart":682.6000000238419,"redirectEnd":0,"redirectStart":0,"requestStart":682.6000000238419,"responseEnd":809.3000000715256,"responseStart":809.3000000715256,"secureConnectionStart":682.6000000238419}],"fetchStart":0,"domainLookupStart":0,"domainLookupEnd":0,"connectStart":0,"connectEnd":0,"requestStart":19,"responseStart":140,"responseEnd":154,"domLoading":144,"domInteractive":823,"domContentLoadedEventStart":823,"domContentLoadedEventEnd":864,"domComplete":1490,"loadEventStart":1490,"loadEventEnd":1492,"userAgent":"Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)","marks":[{"name":"bigPipe.sidebar-id.start","time":797.2000000476837},{"name":"bigPipe.sidebar-id.end","time":798},{"name":"bigPipe.activity-panel-pipe-id.start","time":798.1000000238419},{"name":"bigPipe.activity-panel-pipe-id.end","time":800.6000000238419},{"name":"activityTabFullyLoaded","time":884.9000000953674}],"measures":[],"correlationId":"57f5e87c2b87a1","effectiveType":"4g","downlink":10,"rtt":0,"serverDuration":69,"dbReadsTimeInMs":10,"dbConnsTimeInMs":17,"applicationHash":"9d11dbea5f4be3d4cc21f03a88dd11d8c8687422","experiments":[]}}