pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Peter Eisentraut <peter.eisentraut@2ndquadrant.com>
To: Fabien COELHO <coelho@cri.ensmp.fr>
Cc: Michael Paquier <michael@paquier.xyz>
Cc: Heikki Linnakangas <hlinnaka@iki.fi>
Cc: pgsql-hackers <pgsql-hackers@postgresql.org>
Subject: Re: chained transactions
Date: Wed, 2 Jan 2019 16:07:40 +0100
Message-ID: <6f81f979-3b36-73b9-ac94-49b0baaaeaab@2ndquadrant.com> (raw)
In-Reply-To: <alpine.DEB.2.21.1812260923330.32444@lancre>
References: <28536681-324b-10dc-ade8-ab46f7645a5a@2ndquadrant.com>
	<b989871c-b2d9-42b9-4461-ace590d1a7c0@iki.fi>
	<20181002053854.GA11712@paquier.xyz>
	<ae851ab9-1e53-2200-cbdd-5823160a0367@2ndquadrant.com>
	<alpine.DEB.2.21.1811041203540.7070@lancre>
	<adb990de-c96d-c685-ddc1-5489aaf49316@2ndquadrant.com>
	<alpine.DEB.2.21.1812260923330.32444@lancre>

On 26/12/2018 09:47, Fabien COELHO wrote:
> I'm wary of changing the SPI_commit and SPI_rollback interfaces which are 
> certainly being used outside the source tree and could break countless 
> code, and it seems quite unclean that commit and rollback would do 
> anything else but committing or rollbacking.

These are new as of PG11 and are only used by PL implementations that
support transaction control in procedures, of which there are very few.
We could write separate functions for the "and chain" variants, but I
hope that eventually all PLs will support chaining (because that's
really what you ought to be using in procedures), and so then the
non-chaining interfaces would end up being unused.

> ISTM that it should be kept as is and only managed from the PL/pgsql 
> exec_stmt_* functions, which have to be adapted anyway. That would 
> minimise changes and not break existing code.

But we want other PLs to be able to use this too.

> If SPI_* functions are modified, which I would advise against, I find 
> keeping the next assignment in the chained case doubtful:
> 
>  	_SPI_current->internal_xact = false;

This is correct as is.  The internal_xact flag prevents
CommitTransactionCommand() and AbortCurrentTransaction() from releasing
SPI memory, so it only needs to be set around those calls.  Afterwards
it's unset again so that a top-level transaction end will end up freeing
SPI memory.

Maybe something like internal_xact_end would have been a clearer name.

-- 
Peter Eisentraut              http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services




view thread (28+ messages)  latest in thread

Message-ID: <6f81f979-3b36-73b9-ac94-49b0baaaeaab@2ndquadrant.com>
Permalink:  ../6f81f979-3b36-73b9-ac94-49b0baaaeaab@2ndquadrant.com/
Also on:    postgresql.org/message-id/6f81f979-3b36-73b9-ac94-49b0baaaeaab@2ndquadrant.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-hackers@postgresql.org
  Cc: peter.eisentraut@2ndquadrant.com, coelho@cri.ensmp.fr, michael@paquier.xyz, hlinnaka@iki.fi
  Subject: Re: chained transactions
  In-Reply-To: <6f81f979-3b36-73b9-ac94-49b0baaaeaab@2ndquadrant.com>
  References: <28536681-324b-10dc-ade8-ab46f7645a5a@2ndquadrant.com> <b989871c-b2d9-42b9-4461-ace590d1a7c0@iki.fi> <20181002053854.GA11712@paquier.xyz> <ae851ab9-1e53-2200-cbdd-5823160a0367@2ndquadrant.com> <alpine.DEB.2.21.1811041203540.7070@lancre> <adb990de-c96d-c685-ddc1-5489aaf49316@2ndquadrant.com> <alpine.DEB.2.21.1812260923330.32444@lancre> <6f81f979-3b36-73b9-ac94-49b0baaaeaab@2ndquadrant.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox