Re: SET CONSTRAINTS ALL IMMEDIATE affects SET TRANSACTION READ ONLY

From: Peter Eisentraut <peter(dot)eisentraut(at)2ndquadrant(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, chris+postgresql(at)qwirx(dot)com
Cc: pgsql-docs(at)postgresql(dot)org
Subject: Re: SET CONSTRAINTS ALL IMMEDIATE affects SET TRANSACTION READ ONLY
Date: 2016-10-11 00:47:33
Message-ID: d5262e05-5d96-6090-d665-482f036e1717@2ndquadrant.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-docs

On 9/9/16 12:39 PM, Tom Lane wrote:
> chris+postgresql(at)qwirx(dot)com writes:
>> We found that normally, if you execute SET TRANSACTION READ ONLY, it
>> prevents COMMIT from happening if any data has been changed in the
>> transaction (and we have been relying on this for safety).
>
> This seems like a truly bizarre expectation.
>
> I wouldn't really imagine that it's sensible to set READ ONLY
> mid-transaction at all, but if it means anything to do that, surely
> it ought to mean that no updates can happen *after* you set it.

I think there is a bit of code missing in check_transaction_read_only().
We prevent changing from read-only to read-write after the first query
but not vice versa. That seems like an oversight.

--
Peter Eisentraut http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services

In response to

Responses

Browse pgsql-docs by date

  From Date Subject
Next Message Tom Lane 2016-10-11 00:59:11 Re: SET CONSTRAINTS ALL IMMEDIATE affects SET TRANSACTION READ ONLY
Previous Message Tatsuo Ishii 2016-10-09 21:43:21 parallel.sgml