Bug #56510 ERROR 42000: FUNCTION does not exist if not-priv user reconnects
Submitted: 2 Sep 2010 17:24 Modified: 8 Jun 2011 14:57
Reporter: Sveta Smirnova Email Updates:
Status: Won't fix Impact on me:
None 
Category:MySQL Server Severity:S3 (Non-critical)
Version:5.1 OS:Any
Assigned to: CPU Architecture:Any

[2 Sep 2010 17:24] Sveta Smirnova
Description:
If there is exist a function with definer root, user with grants ALL on particular database this user can execute this function. But after it reconnects it can not execute the function until it tries to get information about it.

mysql-next-mr does not have this problem.

How to repeat:
GRANT SHOW DATABASES ON *.* TO 'basic'@'localhost';
GRANT ALL PRIVILEGES ON `MyDatabase 1.0.1.0`.* TO 'basic'@'localhost';

create database `MyDatabase 1.0.1.0`;
use `MyDatabase 1.0.1.0`;

delimiter |;

CREATE FUNCTION testbug10310ag(a float, b bigint, c int) RETURNS INT NO SQL
BEGIN
RETURN a;
END
|

delimiter ;|

select connection_id();

connect (addconbasic, localhost, basic,,);
connection addconbasic;

use `MyDatabase 1.0.1.0`;
--disable_abort_on_error
show function status like "testbug10310ag"; 
show create function "testbug10310ag"; 
show create function "MyDatabase 1.0.1.0"."testbug10310ag"; 
show create function `MyDatabase 1.0.1.0`.`testbug10310ag`; 
show create function testbug10310ag; 
SELECT testbug10310ag(2.0,1,1);
SELECT `MyDatabase 1.0.1.0`.testbug10310ag(2.0,1,1);
SELECT `MyDatabase 1.0.1.0`.`testbug10310ag`(2.0,1,1);

disconnect addconbasic;
connect (addconbasic, localhost, basic,,);
connection addconbasic;

use `MyDatabase 1.0.1.0`;
SELECT testbug10310ag(2.0,1,1);
SELECT `MyDatabase 1.0.1.0`.testbug10310ag(2.0,1,1);
SELECT `MyDatabase 1.0.1.0`.`testbug10310ag`(2.0,1,1);

show function status like "testbug10310ag"; 
show create function "testbug10310ag"; 
show create function "MyDatabase 1.0.1.0"."testbug10310ag"; 
show create function `MyDatabase 1.0.1.0`.`testbug10310ag`; 
show create function testbug10310ag; 
SELECT testbug10310ag(2.0,1,1);
SELECT `MyDatabase 1.0.1.0`.testbug10310ag(2.0,1,1);
SELECT `MyDatabase 1.0.1.0`.`testbug10310ag`(2.0,1,1);

Last part of output:

SELECT testbug10310ag(2.0,1,1);
testbug10310ag(2.0,1,1)
2
SELECT `MyDatabase 1.0.1.0`.testbug10310ag(2.0,1,1);
`MyDatabase 1.0.1.0`.testbug10310ag(2.0,1,1)
2
SELECT `MyDatabase 1.0.1.0`.`testbug10310ag`(2.0,1,1);
`MyDatabase 1.0.1.0`.`testbug10310ag`(2.0,1,1)
2
connect(localhost,basic,,test,13000,/Users/apple/bzr/mysql-5.1/mysql-test/var/tmp/mysqld.1.sock);
use `MyDatabase 1.0.1.0`;
SELECT testbug10310ag(2.0,1,1);
ERROR 42000: FUNCTION mydatabase 1.0.1.0.testbug10310ag does not exist
SELECT `MyDatabase 1.0.1.0`.testbug10310ag(2.0,1,1);
ERROR 42000: FUNCTION MyDatabase 1.0.1.0.testbug10310ag does not exist
SELECT `MyDatabase 1.0.1.0`.`testbug10310ag`(2.0,1,1);
ERROR 42000: FUNCTION MyDatabase 1.0.1.0.testbug10310ag does not exist
show function status like "testbug10310ag";
Db      Name    Type    Definer Modified        Created Security_type   Comment character_set_client    collation_connection    Database Collation
mydatabase 1.0.1.0      testbug10310ag  FUNCTION        root@localhost  2010-09-02 20:13:10     2010-09-02 20:13:10     DEFINER         latin1  latin1_swedish_ci       utf8_general_ci
show create function "testbug10310ag";
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '"testbug10310ag"' at line 1
show create function "MyDatabase 1.0.1.0"."testbug10310ag";
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '"MyDatabase 1.0.1.0"."testbug10310ag"' at line 1
show create function `MyDatabase 1.0.1.0`.`testbug10310ag`;
Function        sql_mode        Create
[8 Jun 2011 14:57] Dmitry Lenev
Hello!

This issue was fixed in 5.5 series of server by the same patch as bug #30977 "CONCURRENT STATEMENT USING STORED FUNCTION AND DROP FUNCTION BREAKS SBR".

Since it was decided that fix won't be back-ported to 5.1 I am closing this bug as "Won't fix".

Separate test case for this issue has been added to 5.5 tree.