The mysql_stmt_store_result function can return an error, even though mysql_stmt_errno(), mysql_stmt_sqlstate(), and mysql_stmt_error() do not actually contain information about an error. This may be related to running stored procedures that contain a cursor.
To reproduce, load the attached schema:
sudo mysql -u root db1 < cursortest.sql
|
And then build the attached program:
g++ -ggdb -c $(mariadb_config --cflags) cursortest.cpp
|
g++ -o cursortest cursortest.o $(mariadb_config --libs)
|
And then run the program.
At that point, you should see an empty error:
$ ./cursortest
|
Query: CALL testCursor()
|
Failed to store result. Error 0 (00000):
|
Result set #1 had 0 rows
|
Received 1 result sets
|
Query: CALL testNoCursor()
|
Segmentation fault
|
See CONC-425 about the segmentation fault.
{"report":{"fcp":911.8999996185303,"ttfb":246.39999961853027,"pageVisibility":"visible","entityId":77144,"key":"jira.project.issue.view-issue","isInitial":true,"threshold":1000,"elementTimings":{},"userDeviceMemory":8,"userDeviceProcessors":64,"apdex":1,"journeyId":"01932114-a916-4b55-915c-35065c2ab7ce","navigationType":0,"readyForUser":996.7999992370605,"redirectCount":0,"resourceLoadedEnd":826.7999992370605,"resourceLoadedStart":254.79999923706055,"resourceTiming":[{"duration":141.10000038146973,"initiatorType":"link","name":"https://jira.mariadb.org/s/2c21342762a6a02add1c328bed317ffd-CDN/lu2cib/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/css/_super/batch.css","startTime":254.79999923706055,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":254.79999923706055,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":395.8999996185303,"responseStart":0,"secureConnectionStart":0},{"duration":141.10000038146973,"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":255.0999994277954,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":255.0999994277954,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":396.19999980926514,"responseStart":0,"secureConnectionStart":0},{"duration":150,"initiatorType":"script","name":"https://jira.mariadb.org/s/0917945aaa57108d00c5076fea35e069-CDN/lu2cib/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/js/_super/batch.js?locale=en","startTime":255.29999923706055,"connectEnd":255.29999923706055,"connectStart":255.29999923706055,"domainLookupEnd":255.29999923706055,"domainLookupStart":255.29999923706055,"fetchStart":255.29999923706055,"redirectEnd":0,"redirectStart":0,"requestStart":255.29999923706055,"responseEnd":405.29999923706055,"responseStart":405.29999923706055,"secureConnectionStart":255.29999923706055},{"duration":197.89999961853027,"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":255.89999961853027,"connectEnd":255.89999961853027,"connectStart":255.89999961853027,"domainLookupEnd":255.89999961853027,"domainLookupStart":255.89999961853027,"fetchStart":255.89999961853027,"redirectEnd":0,"redirectStart":0,"requestStart":255.89999961853027,"responseEnd":453.79999923706055,"responseStart":453.79999923706055,"secureConnectionStart":255.89999961853027},{"duration":202.19999980926514,"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":256.0999994277954,"connectEnd":256.0999994277954,"connectStart":256.0999994277954,"domainLookupEnd":256.0999994277954,"domainLookupStart":256.0999994277954,"fetchStart":256.0999994277954,"redirectEnd":0,"redirectStart":0,"requestStart":256.0999994277954,"responseEnd":458.29999923706055,"responseStart":458.29999923706055,"secureConnectionStart":256.0999994277954},{"duration":202.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":256.19999980926514,"connectEnd":256.19999980926514,"connectStart":256.19999980926514,"domainLookupEnd":256.19999980926514,"domainLookupStart":256.19999980926514,"fetchStart":256.19999980926514,"redirectEnd":0,"redirectStart":0,"requestStart":256.19999980926514,"responseEnd":458.8999996185303,"responseStart":458.8999996185303,"secureConnectionStart":256.19999980926514},{"duration":203.19999980926514,"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":256.3999996185303,"connectEnd":256.3999996185303,"connectStart":256.3999996185303,"domainLookupEnd":256.3999996185303,"domainLookupStart":256.3999996185303,"fetchStart":256.3999996185303,"redirectEnd":0,"redirectStart":0,"requestStart":256.3999996185303,"responseEnd":459.5999994277954,"responseStart":459.5999994277954,"secureConnectionStart":256.3999996185303},{"duration":294.69999980926514,"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":256.5999994277954,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":256.5999994277954,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":551.2999992370605,"responseStart":0,"secureConnectionStart":0},{"duration":203.5,"initiatorType":"script","name":"https://jira.mariadb.org/rest/api/1.0/shortcuts/820016/47140b6e0a9bc2e4913da06536125810/shortcuts.js?context=issuenavigation&context=issueaction","startTime":256.69999980926514,"connectEnd":256.69999980926514,"connectStart":256.69999980926514,"domainLookupEnd":256.69999980926514,"domainLookupStart":256.69999980926514,"fetchStart":256.69999980926514,"redirectEnd":0,"redirectStart":0,"requestStart":256.69999980926514,"responseEnd":460.19999980926514,"responseStart":460.19999980926514,"secureConnectionStart":256.69999980926514},{"duration":294.6000003814697,"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":256.8999996185303,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":256.8999996185303,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":551.5,"responseStart":0,"secureConnectionStart":0},{"duration":203.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":257,"connectEnd":257,"connectStart":257,"domainLookupEnd":257,"domainLookupStart":257,"fetchStart":257,"redirectEnd":0,"redirectStart":0,"requestStart":257,"responseEnd":460.79999923706055,"responseStart":460.79999923706055,"secureConnectionStart":257},{"duration":305.8999996185303,"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":263.3999996185303,"connectEnd":263.3999996185303,"connectStart":263.3999996185303,"domainLookupEnd":263.3999996185303,"domainLookupStart":263.3999996185303,"fetchStart":263.3999996185303,"redirectEnd":0,"redirectStart":0,"requestStart":263.3999996185303,"responseEnd":569.2999992370605,"responseStart":569.2999992370605,"secureConnectionStart":263.3999996185303},{"duration":342.19999980926514,"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":265,"connectEnd":265,"connectStart":265,"domainLookupEnd":265,"domainLookupStart":265,"fetchStart":265,"redirectEnd":0,"redirectStart":0,"requestStart":265,"responseEnd":607.1999998092651,"responseStart":607.1999998092651,"secureConnectionStart":265},{"duration":28,"initiatorType":"xmlhttprequest","name":"https://jira.mariadb.org/rest/webResources/1.0/resources","startTime":579.8999996185303,"connectEnd":579.8999996185303,"connectStart":579.8999996185303,"domainLookupEnd":579.8999996185303,"domainLookupStart":579.8999996185303,"fetchStart":579.8999996185303,"redirectEnd":0,"redirectStart":0,"requestStart":579.8999996185303,"responseEnd":607.8999996185303,"responseStart":607.8999996185303,"secureConnectionStart":579.8999996185303},{"duration":215,"initiatorType":"link","name":"https://jira.mariadb.org/s/d5715adaadd168a9002b108b2b039b50-CDN/lu2cib/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":611.7999992370605,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":611.7999992370605,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":826.7999992370605,"responseStart":0,"secureConnectionStart":0}],"fetchStart":0,"domainLookupStart":0,"domainLookupEnd":0,"connectStart":0,"connectEnd":0,"requestStart":59,"responseStart":246,"responseEnd":265,"domLoading":250,"domInteractive":1053,"domContentLoadedEventStart":1053,"domContentLoadedEventEnd":1095,"domComplete":1384,"loadEventStart":1384,"loadEventEnd":1384,"userAgent":"Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)","marks":[{"name":"bigPipe.sidebar-id.start","time":1033.2999992370605},{"name":"bigPipe.sidebar-id.end","time":1034},{"name":"bigPipe.activity-panel-pipe-id.start","time":1034.1999998092651},{"name":"bigPipe.activity-panel-pipe-id.end","time":1035.5999994277954},{"name":"activityTabFullyLoaded","time":1109.3999996185303}],"measures":[],"correlationId":"c9b444f8d3929c","effectiveType":"4g","downlink":9.3,"rtt":0,"serverDuration":99,"dbReadsTimeInMs":15,"dbConnsTimeInMs":24,"applicationHash":"9d11dbea5f4be3d4cc21f03a88dd11d8c8687422","experiments":[]}}
Server sends the flag SERVER_STATUS_CURSOR_EXISTS to force the client to retrive rows by sending COM_STMT_FETCH. This doesn't work, since
This is a server bug in all versions (including MySQL server).
A workaround would be to check additionally for stmt->flags & CURSOR_TYPE_READ_ONLY to make sure, that the client opened a cursor.
Since text and binary protocol use the same function, the stmt->error is not updated correctly (which is a bug).