Re: chained transactions - Mailing list pgsql-hackers

From Andres Freund
Subject Re: chained transactions
Date
Msg-id 20190216052222.djehwrd3dtdauk6u@alap3.anarazel.de
Whole thread Raw
In response to Re: chained transactions  (Peter Eisentraut <peter.eisentraut@2ndquadrant.com>)
Responses Re: chained transactions
List 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


pgsql-hackers by date:

Previous
From: Andres Freund
Date:
Subject: Re: SQL/JSON: functions
Next
From: Andres Freund
Date:
Subject: Re: Conflict handling for COPY FROM