28 lines
533 B
SQL
28 lines
533 B
SQL
DROP FUNCTION IF EXISTS account.myUser_getName;
|
|
|
|
DELIMITER $$
|
|
$$
|
|
CREATE DEFINER=`root`@`%` FUNCTION `account`.`myUser_getName`() RETURNS varchar(30) CHARSET utf8
|
|
NO SQL
|
|
DETERMINISTIC
|
|
BEGIN
|
|
/**
|
|
* Returns the current user name.
|
|
*
|
|
* @return The user name
|
|
*/
|
|
DECLARE vUser VARCHAR(30) DEFAULT NULL;
|
|
|
|
IF myUser_checkLogin()
|
|
THEN
|
|
SET vUser = @userName;
|
|
ELSE
|
|
SET vUser = LEFT(USER(), INSTR(USER(), '@') - 1);
|
|
END IF;
|
|
|
|
RETURN vUser;
|
|
END$$
|
|
DELIMITER ;
|
|
|
|
GRANT EXECUTE ON FUNCTION account.myUser_getName TO guest@localhost;
|