I have a problem with existing database code (a trigger) that call a function trigger that use the NOTIFY command, which is not supported in the context of a prepared transaction .
My question is simple : from the function trigger, is there a way to detect that we are in the context of a prepared transaction ?
Thanks in advance.
There is no way to detect that the current transaction will be committed using prepared transactions and two-phase commit, because you haven't PREPARE
d the transaction yet; the transaction has no idea it's going to be subjected to two-phase commit until after your trigger runs. PostgreSQL doesn't require that you BEGIN TRANSACTION FOR TWO PHASE COMMIT
(imaginary syntax) or anything like that.
You can test for max_prepared_transactions
> 0 in pg_settings
to see if prepared transactions are enabled , but there's no way to know if 2PC will be used until it happens.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.