--disable_abort_on_error --disable_warnings DROP DATABASE IF EXISTS db_test1; DROP DATABASE IF EXISTS db_test2; --enable_warnings CREATE DATABASE db_test1; CREATE DATABASE db_test2; # # Create # FUNCTION db_test1.test_func1 (without query on any table) delimiter //; CREATE FUNCTION db_test1.test_func1 (f1 int) RETURNS CHAR(10) SQL SECURITY DEFINER IF f1 >= 0 THEN RETURN 'positive'; ELSEIF f1 < 0 THEN RETURN 'negative'; ELSEIF f1 IS NULL THEN RETURN NULL; ELSE RETURN 'error'; END IF// delimiter ;// # Show that the function basically works SELECT db_test1.test_func1 ( 1 ); # # Create the TESTUSER test_user@localhost ruling his own database (db_test2) only --error 0,1396 DROP USER test_user@localhost; CREATE USER test_user@localhost IDENTIFIED BY 'ABC'; # GRANT ALL ON db_test2.* TO test_user@localhost; # # Connect as the testuser --replace_result $MASTER_MYPORT MYSQL_PORT $MASTER_MYSOCK MYSQL_SOCK connect (test_user_a1,localhost,test_user,ABC,db_test2); # Who am I ? SELECT USER (); # # Check that the attempt to execute the function fails SELECT db_test1.test_func1( 1); #-------- Here comes the bug --------------- # This statement MUST fail. CREATE VIEW db_test2.v1 AS SELECT db_test1.test_func1(1); # Only for interest SELECT * FROM db_test2.v1; # Cleanup connection default; disconnect test_user_a1; DROP USER test_user@localhost; DROP DATABASE db_test1; DROP DATABASE db_test2;