pg.ddx.io  pgsql-docs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Bruce Momjian <bruce@momjian.us>
To: David G. Johnston <david.g.johnston@gmail.com>
Cc: lists@humanleg.org.uk
Cc: pgsql-docs@lists.postgresql.org
Subject: Re: SELECT ... FOR UPDATE OF clause documentation implies use of table_names rather than aliases
Date: Mon, 20 Nov 2023 21:04:12 -0500
Message-ID: <ZVwQHCA85qhKPUcG@momjian.us> (raw)
In-Reply-To: <CAKFQuwa9CX11j5AZSp0Hk16wwW7474hhWHsCEGg1-dMsa4Mg+g@mail.gmail.com>
References: <152483686904.19805.3369061025704720797@wrigleys.postgresql.org>
	<ZVflgb-C2xAmdgBC@momjian.us>
	<CAKFQuwa9CX11j5AZSp0Hk16wwW7474hhWHsCEGg1-dMsa4Mg+g@mail.gmail.com>

On Fri, Nov 17, 2023 at 03:44:04PM -0700, David G. Johnston wrote:
> I don't like this particular solution to the stated complaint.  When a FROM
> entry has an alias it must be referenced via that alias anywhere it is
> referenced in the query - and indeed it is an error to not write the alias in
> your example.  It is not an improvement to write [ table_name | alias ] in our
> syntax to try and demonstrate this requirement.  If we do want to not say
> "table_name" I suggest we say instead "from_reference" and then just define
> what that means (i.e., an unaliased table name or an alias in the sibling FROM
> clause attached to this level of the query).  I like this better anyway on the
> grounds that the thing being referenced can be a subquery or a view as well as
> a table.

Okay, how is the attached patch?

-- 
  Bruce Momjian  <bruce@momjian.us>        https://momjian.us
  EDB                                      https://enterprisedb.com

  Only you can decide what is important to you.

Attachments:

  [text/x-diff] alias.diff (1.6K, ../ZVwQHCA85qhKPUcG@momjian.us/2-alias.diff)
  download | inline diff:
diff --git a/doc/src/sgml/ref/select.sgml b/doc/src/sgml/ref/select.sgml
index 227ba1993b..c98ee8f7ee 100644
--- a/doc/src/sgml/ref/select.sgml
+++ b/doc/src/sgml/ref/select.sgml
@@ -45,7 +45,7 @@ SELECT [ ALL | DISTINCT [ ON ( <replaceable class="parameter">expression</replac
     [ LIMIT { <replaceable class="parameter">count</replaceable> | ALL } ]
     [ OFFSET <replaceable class="parameter">start</replaceable> [ ROW | ROWS ] ]
     [ FETCH { FIRST | NEXT } [ <replaceable class="parameter">count</replaceable> ] { ROW | ROWS } { ONLY | WITH TIES } ]
-    [ FOR { UPDATE | NO KEY UPDATE | SHARE | KEY SHARE } [ OF <replaceable class="parameter">table_name</replaceable> [, ...] ] [ NOWAIT | SKIP LOCKED ] [...] ]
+    [ FOR { UPDATE | NO KEY UPDATE | SHARE | KEY SHARE } [ OF <replaceable class="parameter">from_reference</replaceable> [, ...] ] [ NOWAIT | SKIP LOCKED ] [...] ]
 
 <phrase>where <replaceable class="parameter">from_item</replaceable> can be one of:</phrase>
 
@@ -202,7 +202,11 @@ TABLE [ ONLY ] <replaceable class="parameter">table_name</replaceable> [ * ]
       is specified, the
       <command>SELECT</command> statement locks the selected rows
       against concurrent updates.  (See <xref linkend="sql-for-update-share"/>
-      below.)
+      below.)  <replaceable
+      class="parameter">from_reference</replaceable> must be a table
+      <replaceable class="parameter">alias</replaceable> or non-hidden
+      <replaceable class="parameter">table_name</replaceable> referenced
+      in the <literal>FROM</literal> clause.
      </para>
     </listitem>
    </orderedlist>

view thread (8+ messages)  latest in thread

Message-ID: <ZVwQHCA85qhKPUcG@momjian.us>
Permalink:  ../ZVwQHCA85qhKPUcG@momjian.us/
Also on:    postgresql.org/message-id/ZVwQHCA85qhKPUcG@momjian.us

 ·  · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-docs@postgresql.org
  Cc: bruce@momjian.us, david.g.johnston@gmail.com, lists@humanleg.org.uk, pgsql-docs@lists.postgresql.org
  Subject: Re: SELECT ... FOR UPDATE OF clause documentation implies use of table_names rather than aliases
  In-Reply-To: <ZVwQHCA85qhKPUcG@momjian.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox