I would like to call several plproxy functions one after another (which
will call plpgsql functions in different target partitions), and in case
one of them fails, i want to roll back changes in every one.
That is exactly how two-phase-commit (2PC) should work.
As far as I understand, the postgres' group of statements like PREPARE
TRANSACTION can do this job. But when trying to insert a 'PREPARE
TRANSACTION' statement into a PL/Pgsql function I get an error:
ERROR: XX000: SPI_execute_plan failed executing query "PREPARE
TRANSACTION '2pctest'": SPI_ERROR_TRANSACTION
Is there a way to achieve the needed behaviour with two-phase commmit,
plpgsql and plproxy ?