Is there any way to know if the replication thread is executing the DML?

I have a slave-only trigger. It gets executed by the replication process. I also run other DML against the slave which I don't want the trigger to be executed for.

I was thinking that I could somehow find out who is doing the DML in the trigger: If it is replication then <do something> else <do nothing> end if;

Is there any way? Something similar to CURRENT_USER() or USER(), but which would return the MASTER_USER?

Answer Answered by Manu Anttila in this comment.

Okay. In the trigger I check if it is a local process that has executed the DML by querying the ID+HOST in information_schema.processlist and comparing them to CONNECTION_ID()+USER(). I can make the decision based on that.

MariaDB [xxx]> select LocalProcess();
| LocalProcess() |
|              1 |

This question can be removed or marked as answered on my behalf.


Comments loading...
Content reproduced on this site is the property of its respective owners, and this content is not reviewed in advance by MariaDB. The views, information and opinions expressed by this content do not necessarily represent those of MariaDB or any other party.