Use mysql user in trigger

I am creating a trigger in MySQL to tell me that WHO (which mysql user) is updating in a specific table.

I know that MySQL has the CURRENT_USER () function, but do I need to insert a username during CREATED start or during a CALLED call?

This is my trigger so far. I want to insert the username in the column "content".

delimiter | CREATE TRIGGER update_product_procedure BEFORE UPDATE ON product_procedure FOR EACH ROW BEGIN INSERT INTO trigger_logs SET content = 'This is a test', postDate=NOW(); END; | 
+4
source share
1 answer

I would put a lot of money into being an invoker, but from http://bugs.mysql.com/bug.php?id=5861 :

The SQL standard says that: "A triggered action is always performed to authorize the owner of the schema that includes the trigger." This means that in MySQL we must execute the trigger body when authorizing the user who created the trigger, and not the one who issued the statement that called this trigger.

Apologies, I suggested that this was an obvious question: - (

Hi

EDIT: user () provides invoker

+4
source

All Articles