Re: Suggestion: Issue warning when calling SET TRANSACTION outside transaction block

From: Bruce Momjian <bruce(at)momjian(dot)us>
To: Andres Freund <andres(at)2ndquadrant(dot)com>
Cc: Robert Haas <robertmhaas(at)gmail(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>, Morten Hustveit <morten(at)eventures(dot)vc>, "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Suggestion: Issue warning when calling SET TRANSACTION outside transaction block
Date: 2013-11-19 18:09:16
Message-ID: 20131119180916.GO28149@momjian.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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;
BEGIN
test=> begin work;
--> WARNING: there is already a transaction in progress
BEGIN
test=> commit;
COMMIT
test=>

--
Bruce Momjian <bruce(at)momjian(dot)us> http://momjian.us
EnterpriseDB http://enterprisedb.com

+ Everyone has their own god. +

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Andrew Dunstan 2013-11-19 18:09:18 Re: additional json functionality
Previous Message Robert Haas 2013-11-19 18:09:15 Re: additional json functionality