Re: [HACKERS] [PATCH] Lockable views - Mailing list pgsql-hackers

From Robert Haas
Subject Re: [HACKERS] [PATCH] Lockable views
Date
Msg-id CA+TgmoZqDXb+ZBnBR9e8Pc=WkVAZ0yVqKyB_Mg14fySyOau7Eg@mail.gmail.com
Whole thread Raw
In response to Re: [HACKERS] [PATCH] Lockable views  (Tatsuo Ishii <ishii@sraoss.co.jp>)
Responses Re: [HACKERS] [PATCH] Lockable views  (Tatsuo Ishii <ishii@sraoss.co.jp>)
List pgsql-hackers
On Mon, Feb 5, 2018 at 8:18 PM, Tatsuo Ishii <ishii@sraoss.co.jp> wrote:
> We have: CREATE VIEW v1 AS SELECT * FROM t1 WHERE i = (SELECT i FROM t2);
>
> 1. Session A tries to lock v1 (I suppose it tries to acquire lock in
> the order of t1, then t2). A acquires lock on t1 but yet on t2.
>
> 2. Another session B acquires lock on t2.
>
> 3. A continues to try to acquire lock on t2 (blocked).
>
> 4. B tries to acquire lock on t1. Deadlock occurs.

True.  But the same exact analysis also applies to this definition,
which contains no subquery:

CREATE VIEW v1 AS SELECT t1.* FROM t1, t2 WHERE t1.i = t2.i;

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


pgsql-hackers by date:

Previous
From: Amit Langote
Date:
Subject: Re: update tuple routing and triggers
Next
From: Craig Ringer
Date:
Subject: Re: Better Upgrades