Bug #85633 C API prepared statement error 1370
Submitted: 27 Mar 2017 1:52 Modified: 11 Jun 2017 11:16
Reporter: Michael Buchberger Email Updates:
Status: No Feedback Impact on me:
None 
Category:MySQL Server: C API (client library) Severity:S2 (Serious)
Version:5.7.7 OS:SUSE
Assigned to: Assigned Account CPU Architecture:Any
Tags: 1370, C API, prepared statement

[27 Mar 2017 1:52] Michael Buchberger
Description:
mysql_stmt_bind_param() for a "call myfunction(?,?,?)" statement returns sporadically errno 1370 (execute denied).
Error occurs when several threads ( 8-10) within a small time slice execute the same code (different memory for vaiables of course). 
A functioning workaround is to repeat the statement.
From about 10 threads are usaually 2-4 threads impacted, but no specific order or rule for these cases is to be seen for me. The repeating by the same thread seems to succeed always.

I think, when I saw this error for the 1st time, it was justified as the function accessed a table of another schema for which the user had no permissions. But meanwhile the function is changed, the database was reloaded from a dump. So this is probably a mere coincidence.

How to repeat:
Occurs regularly in my setup.
[27 Mar 2017 6:45] Chiranjeevi Battula
Hello Michael,

Thank you for the bug report.
Error code 1370 is thrown if the user does not have privileges to execute routine/routines. Please check for the user have proper privileges or not.

Thanks,
Chiranjeevi.
[27 Mar 2017 9:24] Michael Buchberger
As described, the error occurs only sporadically. In most cases, the statement succeeds, and after a failure, i.e. receiving errno 1370, a repitition of exact the same statements succeeds. So, if the user had no permissions, it would be an even worse error. But the user has the needed privileges, smeaning that the failure is the error.
[27 Mar 2017 11:44] Chiranjeevi Battula
Thank you for your feedback.
Please check for show grants for all the connected users who are executing this routine.
https://dev.mysql.com/doc/refman/5.5/en/show-grants.html

Thanks,
Chiranjeevi.
[27 Mar 2017 12:45] Michael Buchberger
all threads are using the same credentials. Show grants is "GRANT SELECT, INSERT, UPDATE, DELETE, CREATE TEMPORARY TABLES, LOCK TABLES, EXECUTE, SHOW VIEW ON `database`.* TO 'user'@'localhost'"
And again: Within the same opened connection, without any reconnect, the statement that results to error 1370 is just repeated and is then successful.
So it is an error whatever the privileges are. And again: the needed privileges are granted. So when the statement returns "no error", it is as expected and correct and when the same statement with same user credentials within the same connection returns 1370 as error, it is the here reported bug.
[11 May 2017 11:16] Chiranjeevi Battula
Hello Michael,

Thank you for your feedback.
Could you please provide repeatable test case (exact steps/sample code, procedures/database details etc. - please make it as private if you prefer) to confirm this issue at our end?

Thanks,
Chiranjeevi.
[12 Jun 2017 1:00] Bugs System
No feedback was provided for this bug for over a month, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".