Description:
Event scheduler looks for the first @ sign to separate user name from host name.
MySQL can create users with @ side in the middle of user name:
create user `test@usr`@localhost;
https://github.com/mysql/mysql-server/blob/mysql-5.7.37/sql/event_data_objects.cc#L449
ptr= strchr(definer.str, '@');
if (! ptr)
ptr= definer.str;
len= ptr - definer.str;
definer_user.str= strmake_root(&mem_root, definer.str, len);
Produces following error message:
How to repeat:
The event:
create database test;
use test;
CREATE DEFINER=`test@usr`@`localhost` EVENT tevnt3 ON SCHEDULE AT CURRENT_TIMESTAMP + INTERVAL 1 MINUTE ON COMPLETION PRESERVE DO INSERT INTO test.tbl1 VALUES(103);
SHOW CREATE EVENT tevnt3:
Create Event: CREATE DEFINER=`test`@`usr@localhost` EVENT `tevnt3` ON SCHEDULE AT '2022-03-15 02:28:48' ON COMPLETION PRESERVE ENABLE DO INSERT INTO test.tbl1 VALUES(103)
Error message:
2022-03-15T02:28:48.297637Z 1 [Note] Event Scheduler: Last execution of test.tevnt3.
2022-03-15T02:28:48.300370Z 11 [ERROR] Event Scheduler: [test@usr@localhost].[test.tevnt3] execution failed, failed to authenticate the user.
2022-03-15T02:28:48.300427Z 11 [ERROR] Event Scheduler: [test@usr@localhost][test.tevnt3] The user specified as a definer ('test'@'usr@localhost') does not exist
2022-03-15T02:28:48.300448Z 11 [Note] Event Scheduler: [test@usr@localhost].[test.tevnt3] event execution failed.
Suggested fix:
Replace both occurrence of strchr(definer.str, '@') in event_data_objects.cc with
find_last_of or "rstrchr".