Re: SELECT ... FOR UPDATE OF clause documentation implies use of table_names rather than aliases

From: Bruce Momjian <bruce(at)momjian(dot)us>
To: lists(at)humanleg(dot)org(dot)uk, pgsql-docs(at)lists(dot)postgresql(dot)org
Subject: Re: SELECT ... FOR UPDATE OF clause documentation implies use of table_names rather than aliases
Date: 2023-11-17 22:13:21
Message-ID: ZVflgb-C2xAmdgBC@momjian.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-docs

On Fri, Apr 27, 2018 at 01:47:49PM +0000, PG Doc comments form wrote:
> The following documentation comment has been logged on the website:
>
> Page: https://www.postgresql.org/docs/9.5/static/sql-select.html
> Description:
>
> In the SELECT statement page the argument type of the (FOR SHARE/UPDATE) OF
> clause is listed to be a table_name. This is not *quite* accurate - it
> should reference the *alias* assigned to the table if one was given. The
> distinction is subtly important, as without this information the
> documentation implies that the choice of rows to lock can only be done
> per-table (i.e. that in a query mentioning the same table twice, *any*
> tuples being pulled from that table would be given the same treatment).
>
> But in fact postgres supports specifying the locking behaviour per-alias,
> which is a really powerful ability. And actually, trying to specify it by
> actual "table name" where an alias has been assigned won't work either.

I can confirm this report from 2018:

CREATE TABLE test ( x INT );

SELECT * FROM test AS t1 JOIN test AS t2 ON (TRUE) FOR UPDATE OF t1;
x | x
---+---


SELECT * FROM test AS t1 JOIN test AS t2 ON (TRUE) FOR UPDATE OF t2;
x | x
---+---

The attached patch documents this.

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

Only you can decide what is important to you.

Attachment Content-Type Size
alias.diff text/x-diff 1.0 KB

In response to

Responses

Browse pgsql-docs by date

  From Date Subject
Next Message David G. Johnston 2023-11-17 22:44:04 Re: SELECT ... FOR UPDATE OF clause documentation implies use of table_names rather than aliases
Previous Message Bruce Momjian 2023-11-17 21:48:23 Re: Missing documentation for FETCH FIRST in chapter 7.6