SPI and transactions - Mailing list pgsql-hackers

From Konstantin Knizhnik
Subject SPI and transactions
Date
Msg-id 564C507F.4050903@postgrespro.ru
Whole thread Raw
Responses Re: SPI and transactions  (Robert Haas <robertmhaas@gmail.com>)
Re: SPI and transactions  (Craig Ringer <craig@2ndquadrant.com>)
List pgsql-hackers
Hello,

SPI was originally developed for execution SQL statements from C user 
defined functions in context of existed transaction.
This is why it is not possible to execute any transaction manipulation 
statement (BEGIN, COMMIT, PREPARE,...) using 
SPI_execute:SPI_ERROR_TRANSACTION is returned.

But now SPI is used not only inside UDFs. It is also used in background 
workers. For example in receiver_raw, written by Michael Paquier (I lot 
of thanks Michael, understand logical replication without them will be 
much more difficult).
Right now transactions have to be started by background worker using  
StartTransactionCommand().
So receiver_raw is not able to preserve master's transaction semantic 
(certainly it can be implemented).

I wonder whether SPI can be extended now to support transaction 
manipulation functions when been called outside transaction context? Or 
there are some principle problem with it?

Thanks in advance,
Konstantin






pgsql-hackers by date:

Previous
From: "Maeldron T."
Date:
Subject: PostgreSQL super HA (High Availability) conception for 9.5+
Next
From: Dean Rasheed
Date:
Subject: Re: Bug in numeric multiplication