Re: Suggestion: Issue warning when calling SET TRANSACTION outside transaction block - Mailing list pgsql-hackers

From Bruce Momjian
Subject Re: Suggestion: Issue warning when calling SET TRANSACTION outside transaction block
Date
Msg-id 20131119180916.GO28149@momjian.us
Whole thread Raw
In response to Re: Suggestion: Issue warning when calling SET TRANSACTION outside transaction block  (Andres Freund <andres@2ndquadrant.com>)
Responses Re: Suggestion: Issue warning when calling SET TRANSACTION outside transaction block
List pgsql-hackers
On Tue, Nov 19, 2013 at 07:08:05PM +0100, Andres Freund wrote:
> On 2013-11-19 13:05:01 -0500, Bruce Momjian wrote:
> >     SAVEPOINT
> 
> >     test=> ROLLBACK TO SAVEPOINT asdf;
> >     ERROR:  ROLLBACK TO SAVEPOINT can only be used in transaction blocks
> > 
> > Notice that they do _not_ check their arguments;  they just throw
> > errors.  With this patch they issue warnings and evaluate their
> > arguments:
> 
> >     test=> ROLLBACK TO SAVEPOINT asdf;
> >     WARNING:  ROLLBACK TO SAVEPOINT can only be used in transaction blocks
> >     ROLLBACK
> >     
> > However, SAVEPOINT/ROLLBACK throw weird errors when they are evaluated
> > outside a multi-statement transaction, so their arguments are not
> > evaluated.  This might be why they were originally marked as errors.
> 
> Why change the historical behaviour for savepoints?

Because as Tom stated, we already do warnings for other useless
transaction commands like BEGIN WORK inside a transaction block:
test=> begin work;BEGINtest=> begin work;
-->    WARNING:  there is already a transaction in progressBEGINtest=> commit;COMMITtest=>

--  Bruce Momjian  <bruce@momjian.us>        http://momjian.us EnterpriseDB
http://enterprisedb.com
 + Everyone has their own god. +



pgsql-hackers by date:

Previous
From: Robert Haas
Date:
Subject: Re: additional json functionality
Next
From: Andrew Dunstan
Date:
Subject: Re: additional json functionality