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.
Geoff Montee (Inactive)
made changes -
2019-06-28 23:40
Description
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:
{noformat}
sudo mysql -u root db1 < cursortest.sql
{noformat}
And then build the attached program:
{noformat}
g++ -ggdb -c $(mariadb_config --cflags) cursortest.cpp
g++ -o cursortest cursortest.o $(mariadb_config --libs)
{noformat}
And then run the program.
At that point, you should see an empty error:
{noformat}
$ ./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
{noformat}
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:
{noformat}
sudo mysql -u root db1 < cursortest.sql
{noformat}
And then build the attached program:
{noformat}
g++ -ggdb -c $(mariadb_config --cflags) cursortest.cpp
g++ -o cursortest cursortest.o $(mariadb_config --libs)
{noformat}
And then run the program.
At that point, you should see an empty error:
{noformat}
$ ./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
{noformat}
See CONC-425 about the segmentation fault.
Georg Richter
made changes -
2019-06-30 10:51
Fix Version/s
3.0.11
[ 23716
]
Fix Version/s
3.1.3
[ 23743
]
Fix Version/s
3.1
[ 23223
]
Georg Richter
made changes -
2019-06-30 10:51
issue.field.resolutiondate
2019-06-30 10:51:50.0
2019-06-30 10:51:50.479
Georg Richter
made changes -
2019-06-30 10:51
Resolution
Fixed
[ 1
]
Status
Open
[ 1
]
Closed
[ 6
]
Julien Fritsch
made changes -
2022-01-11 15:33
Workflow
MariaDB connectors
[ 97863
]
MariaDB v4
[ 161177
]
{"report":{"fcp":1640,"ttfb":499.10000002384186,"pageVisibility":"visible","entityId":77144,"key":"jira.project.issue.view-issue","isInitial":true,"threshold":1000,"elementTimings":{},"userDeviceMemory":8,"userDeviceProcessors":64,"apdex":0.5,"journeyId":"c2bfb5f3-a240-4ef1-8a24-7cd226e44bac","navigationType":0,"readyForUser":1718.199999988079,"redirectCount":0,"resourceLoadedEnd":1895.9000000357628,"resourceLoadedStart":503.60000002384186,"resourceTiming":[{"duration":678.0999999642372,"initiatorType":"link","name":"https://jira.mariadb.org/s/2c21342762a6a02add1c328bed317ffd-CDN/lu2bu7/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/css/_super/batch.css","startTime":503.60000002384186,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":503.60000002384186,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":1181.699999988079,"responseStart":0,"secureConnectionStart":0},{"duration":678.1999999880791,"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":503.80000001192093,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":503.80000001192093,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":1182,"responseStart":0,"secureConnectionStart":0},{"duration":686.9000000357628,"initiatorType":"script","name":"https://jira.mariadb.org/s/fbf975c0cce4b1abf04784eeae9ba1f4-CDN/lu2bu7/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/js/_super/batch.js?locale=en","startTime":504,"connectEnd":504,"connectStart":504,"domainLookupEnd":504,"domainLookupStart":504,"fetchStart":504,"redirectEnd":0,"redirectStart":0,"requestStart":504,"responseEnd":1190.9000000357628,"responseStart":1190.9000000357628,"secureConnectionStart":504},{"duration":734.5999999642372,"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":504.10000002384186,"connectEnd":504.10000002384186,"connectStart":504.10000002384186,"domainLookupEnd":504.10000002384186,"domainLookupStart":504.10000002384186,"fetchStart":504.10000002384186,"redirectEnd":0,"redirectStart":0,"requestStart":504.10000002384186,"responseEnd":1238.699999988079,"responseStart":1238.699999988079,"secureConnectionStart":504.10000002384186},{"duration":738,"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":504.30000001192093,"connectEnd":504.30000001192093,"connectStart":504.30000001192093,"domainLookupEnd":504.30000001192093,"domainLookupStart":504.30000001192093,"fetchStart":504.30000001192093,"redirectEnd":0,"redirectStart":0,"requestStart":504.30000001192093,"responseEnd":1242.300000011921,"responseStart":1242.300000011921,"secureConnectionStart":504.30000001192093},{"duration":738,"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":504.60000002384186,"connectEnd":504.60000002384186,"connectStart":504.60000002384186,"domainLookupEnd":504.60000002384186,"domainLookupStart":504.60000002384186,"fetchStart":504.60000002384186,"redirectEnd":0,"redirectStart":0,"requestStart":504.60000002384186,"responseEnd":1242.6000000238419,"responseStart":1242.6000000238419,"secureConnectionStart":504.60000002384186},{"duration":738.3000000119209,"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":504.69999998807907,"connectEnd":504.69999998807907,"connectStart":504.69999998807907,"domainLookupEnd":504.69999998807907,"domainLookupStart":504.69999998807907,"fetchStart":504.69999998807907,"redirectEnd":0,"redirectStart":0,"requestStart":504.69999998807907,"responseEnd":1243,"responseStart":1243,"secureConnectionStart":504.69999998807907},{"duration":825.5999999642372,"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":504.9000000357628,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":504.9000000357628,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":1330.5,"responseStart":0,"secureConnectionStart":0},{"duration":738.3000000119209,"initiatorType":"script","name":"https://jira.mariadb.org/rest/api/1.0/shortcuts/820016/47140b6e0a9bc2e4913da06536125810/shortcuts.js?context=issuenavigation&context=issueaction","startTime":505.10000002384186,"connectEnd":505.10000002384186,"connectStart":505.10000002384186,"domainLookupEnd":505.10000002384186,"domainLookupStart":505.10000002384186,"fetchStart":505.10000002384186,"redirectEnd":0,"redirectStart":0,"requestStart":505.10000002384186,"responseEnd":1243.4000000357628,"responseStart":1243.4000000357628,"secureConnectionStart":505.10000002384186},{"duration":825.4000000357628,"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":505.19999998807907,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":505.19999998807907,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":1330.6000000238419,"responseStart":0,"secureConnectionStart":0},{"duration":738.5,"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":505.4000000357628,"connectEnd":505.4000000357628,"connectStart":505.4000000357628,"domainLookupEnd":505.4000000357628,"domainLookupStart":505.4000000357628,"fetchStart":505.4000000357628,"redirectEnd":0,"redirectStart":0,"requestStart":505.4000000357628,"responseEnd":1243.9000000357628,"responseStart":1243.9000000357628,"secureConnectionStart":505.4000000357628},{"duration":1020.6999999880791,"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":510.9000000357628,"connectEnd":510.9000000357628,"connectStart":510.9000000357628,"domainLookupEnd":510.9000000357628,"domainLookupStart":510.9000000357628,"fetchStart":510.9000000357628,"redirectEnd":0,"redirectStart":0,"requestStart":510.9000000357628,"responseEnd":1531.6000000238419,"responseStart":1531.5,"secureConnectionStart":510.9000000357628},{"duration":1376.699999988079,"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":513.9000000357628,"connectEnd":513.9000000357628,"connectStart":513.9000000357628,"domainLookupEnd":513.9000000357628,"domainLookupStart":513.9000000357628,"fetchStart":513.9000000357628,"redirectEnd":0,"redirectStart":0,"requestStart":513.9000000357628,"responseEnd":1890.6000000238419,"responseStart":1890.6000000238419,"secureConnectionStart":513.9000000357628},{"duration":190.30000001192093,"initiatorType":"xmlhttprequest","name":"https://jira.mariadb.org/rest/webResources/1.0/resources","startTime":1342.1000000238419,"connectEnd":1342.1000000238419,"connectStart":1342.1000000238419,"domainLookupEnd":1342.1000000238419,"domainLookupStart":1342.1000000238419,"fetchStart":1342.1000000238419,"redirectEnd":0,"redirectStart":0,"requestStart":1342.1000000238419,"responseEnd":1532.4000000357628,"responseStart":1532.4000000357628,"secureConnectionStart":1342.1000000238419},{"duration":300.19999998807907,"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":1595.4000000357628,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":1595.4000000357628,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":1895.6000000238419,"responseStart":0,"secureConnectionStart":0},{"duration":299.9000000357628,"initiatorType":"link","name":"https://jira.mariadb.org/s/50bc9be5bfead1a25e72c1a9338c94f6-CDN/lu2bu7/820016/12ta74/e108c7645258ccb43280ed3404e3e949/_/download/contextbatch/css/com.atlassian.jira.plugins.jira-development-integration-plugin:0,-_super,-jira.view.issue,-jira.global,-jira.general,-jira.browse.project,-project.issue.navigator,-atl.general/batch.css?agile_global_admin_condition=true&jag=true&jira.create.linked.issue=true&slack-enabled=true","startTime":1596,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":1596,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":1895.9000000357628,"responseStart":0,"secureConnectionStart":0},{"duration":329.10000002384186,"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":1596.800000011921,"connectEnd":1596.800000011921,"connectStart":1596.800000011921,"domainLookupEnd":1596.800000011921,"domainLookupStart":1596.800000011921,"fetchStart":1596.800000011921,"redirectEnd":0,"redirectStart":0,"requestStart":1596.800000011921,"responseEnd":1925.9000000357628,"responseStart":1925.9000000357628,"secureConnectionStart":1596.800000011921},{"duration":363,"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":1597.1000000238419,"connectEnd":1597.1000000238419,"connectStart":1597.1000000238419,"domainLookupEnd":1597.1000000238419,"domainLookupStart":1597.1000000238419,"fetchStart":1597.1000000238419,"redirectEnd":0,"redirectStart":0,"requestStart":1597.1000000238419,"responseEnd":1960.1000000238419,"responseStart":1960.1000000238419,"secureConnectionStart":1597.1000000238419},{"duration":365.4000000357628,"initiatorType":"script","name":"https://jira.mariadb.org/s/86ee9bbc76cd1bcd8556fcdcf46241c9-CDN/lu2bu7/820016/12ta74/e108c7645258ccb43280ed3404e3e949/_/download/contextbatch/js/com.atlassian.jira.plugins.jira-development-integration-plugin:0,-_super,-jira.view.issue,-jira.global,-jira.general,-jira.browse.project,-project.issue.navigator,-atl.general/batch.js?agile_global_admin_condition=true&jag=true&jira.create.linked.issue=true&locale=en&slack-enabled=true","startTime":1597.5,"connectEnd":1597.5,"connectStart":1597.5,"domainLookupEnd":1597.5,"domainLookupStart":1597.5,"fetchStart":1597.5,"redirectEnd":0,"redirectStart":0,"requestStart":1597.5,"responseEnd":1962.9000000357628,"responseStart":1962.800000011921,"secureConnectionStart":1597.5}],"fetchStart":0,"domainLookupStart":0,"domainLookupEnd":0,"connectStart":0,"connectEnd":0,"requestStart":264,"responseStart":499,"responseEnd":514,"domLoading":502,"domInteractive":1925,"domContentLoadedEventStart":1925,"domContentLoadedEventEnd":1969,"domComplete":2389,"loadEventStart":2389,"loadEventEnd":2390,"userAgent":"Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)","marks":[{"name":"bigPipe.sidebar-id.start","time":1899.800000011921},{"name":"bigPipe.sidebar-id.end","time":1900.699999988079},{"name":"bigPipe.activity-panel-pipe-id.start","time":1900.9000000357628},{"name":"bigPipe.activity-panel-pipe-id.end","time":1903.9000000357628},{"name":"activityTabFullyLoaded","time":1987.9000000357628}],"measures":[],"correlationId":"21bbcca9622af5","effectiveType":"4g","downlink":9.6,"rtt":0,"serverDuration":172,"dbReadsTimeInMs":63,"dbConnsTimeInMs":73,"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).