Bug #17244 GRANT gives strange error message when used in a stored function
Submitted: 8 Feb 2006 21:04 Modified: 9 Oct 2007 17:58
Reporter: Mats Kindahl Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Locking Severity:S3 (Non-critical)
Version:5.1 OS:Linux (linux)
Assigned to: Davi Arnaut CPU Architecture:Any

[8 Feb 2006 21:04] Mats Kindahl
Description:
When using a GRANT inside a stored procedure, a strange error message is printed. If row-based replication is enabled, the changes to the mysql.user table is logged to the binary log.

How to repeat:
CREATE FUNCTION foo(x INT)
    RETURNS INT
BEGIN
    GRANT SELECT ON t1 TO mysqltest@localhost;
    RETURN x;
END

mysql> SELECT foo(3);
ERROR 1100 (HY000): Table 'user' was not locked with LOCK TABLES
[8 Feb 2006 21:33] Mats Kindahl
It is not a stored procedure, as I wrote, it is a stored function. The example is still correct.
[11 Feb 2006 10:54] Konstantin Osipov
Hartmut, why didn't you verify it using the earliest version possible?
[26 Jul 2006 10:40] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/9578
[26 Jul 2006 14:01] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/9589
[29 Aug 2007 20:51] Konstantin Osipov
Fixed by the patch for Bug#21975 Grant and revoke statements are non-transactional
[7 Sep 2007 8:08] Bugs System
Pushed into 5.1.23-beta
[9 Oct 2007 17:58] Paul DuBois
Noted in 5.1.23 changelog.

Incompatible change: GRANT and REVOKE statements now cause an
implicit commit, and thus are prohibited within stored functions and
triggers.