Re: Autonomous Transaction is back - Mailing list pgsql-hackers

From Robert Haas
Subject Re: Autonomous Transaction is back
Date
Msg-id CA+TgmoZc-Z7wtL6Zvs+1Q+PVF+PKwwQkcazm2pVtbRPFNitQFw@mail.gmail.com
Whole thread Raw
In response to Re: Autonomous Transaction is back  (Noah Misch <noah@leadboat.com>)
Responses Re: Autonomous Transaction is back  (Noah Misch <noah@leadboat.com>)
List pgsql-hackers
On Sat, Aug 22, 2015 at 2:23 AM, Noah Misch <noah@leadboat.com> wrote:
>> > Can you get away with only looking at tuples though?  For example,
>> > what about advisory locks?  Table locks?
>>
>> Well, that's an interesting question.  Can we get away with regarding
>> those things as non-conflicting, as between the parent and child
>> transactions?
>
> For system lock types, no.  While one could define advisory locks to work
> differently, we should assume that today's advisory lockers have expectations
> like those of system lockers.  An autonomous transaction should not bypass any
> lock that a transaction of another backend could not bypass.

Why?

Suppose you do this:

BEGIN;
DECLARE CURSOR foo FOR SELECT * FROM foo;
BEGIN AUTONOMOUS TRANSACTION;
ALTER TABLE foo ALTER bar TYPE int;

This has got to fail for safety reasons, but CheckTableNotInUse() is
on it.  Suppose you do this:

BEGIN;
LOCK foo;
BEGIN AUTONOMOUS TRANSACTION;
INSERT INTO foo VALUES ('spelunk');

How will making this fail improve anything?

-- 
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company



pgsql-hackers by date:

Previous
From: Alvaro Herrera
Date:
Subject: Re: pg_ctl/pg_rewind tests vs. slow AIX buildfarm members
Next
From: Robert Haas
Date:
Subject: Re: strange test in psql:startup.c