Re: chained transactions

From: Andres Freund <andres(at)anarazel(dot)de>
To: Peter Eisentraut <peter(dot)eisentraut(at)2ndquadrant(dot)com>
Cc: Fabien COELHO <coelho(at)cri(dot)ensmp(dot)fr>, Michael Paquier <michael(at)paquier(dot)xyz>, Heikki Linnakangas <hlinnaka(at)iki(dot)fi>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: chained transactions
Date: 2019-02-16 05:22:22
Message-ID: 20190216052222.djehwrd3dtdauk6u@alap3.anarazel.de
Views: Raw Message | Whole Thread | Download mbox
Thread:
Lists: pgsql-hackers

Hi,

On 2019-01-02 16:02:21 +0100, Peter Eisentraut wrote:
> +++ b/src/backend/access/transam/xact.c
> @@ -189,6 +189,7 @@ typedef struct TransactionStateData
> bool startedInRecovery; /* did we start in recovery? */
> bool didLogXid; /* has xid been included in WAL record? */
> int parallelModeLevel; /* Enter/ExitParallelMode counter */
> + bool chain; /* start a new block after this one */
> struct TransactionStateData *parent; /* back link to parent */
> } TransactionStateData;
>
> @@ -2760,6 +2761,36 @@ StartTransactionCommand(void)
> MemoryContextSwitchTo(CurTransactionContext);
> }
>
> +
> +/*
> + * Simple system for saving and restoring transaction characteristics
> + * (isolation level, read only, deferrable). We need this for transaction
> + * chaining, so that we can set the characteristics of the new transaction to
> + * be the same as the previous one. (We need something like this because the
> + * GUC system resets the characteristics at transaction end, so for example
> + * just skipping the reset in StartTransaction() won't work.)
> + */
> +static int save_XactIsoLevel;
> +static bool save_XactReadOnly;
> +static bool save_XactDeferrable;

We normally don't define variables in the middle of a file? Also, why
do these need to be global vars rather than defined where we do
chaining? I'm imagining a SavedTransactionState struct declared on the
stack that's then passed to Save/Restore?

Not crucial, but I do wonder if we can come up with a prettier approach
for this.

Greetings,

Andres Freund

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Andres Freund 2019-02-16 05:24:57 Re: Conflict handling for COPY FROM
Previous Message Andres Freund 2019-02-16 05:12:39 Re: SQL/JSON: functions