Send an http request in mysql trigger after insertion in a table

前端 未结 1 1774
南笙
南笙 2021-01-12 09:47

I am working in PHP.I have to created a mysql trigger which fires an http request after insertion on table.Below is the code.

DELIMITER @@
CREATE TRIGGER Test         


        
相关标签:
1条回答
  • 2021-01-12 10:22

    Although it's technically possible I'd strongly discourage you from going this route for several reasons:

    1. Using UDFs is a security risk on its own. UDFs are available to all database users - you cannot grant EXECUTE privileges for them.

    2. Doing any non-transactional operations in a trigger is simply wrong. Data changes made by DML statement (in your case it's an update) can and will be rolled back in a real world scenario. You won't be able to undo your http calls.

    3. You're prolonging the time for insert transaction possibly causing lock-wait-timeouts for other update/insert operations.

    Highly recommended reading:

    • The Trouble with Triggers

    Now most likely what you need is a work queue e.g. beanstalked. Using such specialized middleware is much better than organizing queues with database.

    0 讨论(0)
提交回复
热议问题