Skip site navigation (1) Skip section navigation (2)

Suggestion: Issue warning when calling SET TRANSACTION outside transaction block

From: Morten Hustveit <morten(at)eventures(dot)vc>
To: pgsql-hackers(at)postgresql(dot)org
Subject: Suggestion: Issue warning when calling SET TRANSACTION outside transaction block
Date: 2013-01-30 01:22:41
Message-ID: CAJajUVQgMC4VQpVY=upnwyearwNqLpBWcWrmeX6vjuf5O2rr=w@mail.gmail.com (view raw or flat)
Thread:
Lists: pgsql-hackers
Hi!

Calling "SET TRANSACTION ISOLATION LEVEL ..." outside a transaction
block has no effect.  This is unlike "LOCK ..." and "DECLARE foo
CURSOR FOR ...", which both raise an error.  This is also unlike
MySQL, where such a statement will affect the next transaction
performed.  There's some risk of data corruption, as a user might
assume he's working on a snapshot, while in fact he's not.

I suggest issuing a warning, notice or error message when "SET
TRANSACTION ..." is called outside a transaction block, possibly
directing the user to the "SET SESSION CHARACTERISTICS AS TRANSACTION
..." syntax.

I'm not familiar with the PostgreSQL source code, but it seems this
would have to be added to check_XactIsoLevel() or by calling
RequireTransactionChain() at some appropriate location.


Responses

pgsql-hackers by date

Next:From: Noah MischDate: 2013-01-30 01:34:24
Subject: Re: COPY FREEZE has no warning
Previous:From: Tom LaneDate: 2013-01-30 00:40:28
Subject: Re: Hm, table constraints aren't so unique as all that

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group