Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1r5G7h-00Cdet-BZ for pgsql-docs@arkaria.postgresql.org; Tue, 21 Nov 2023 02:04:21 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1r5G7f-00CCiN-Ex for pgsql-docs@arkaria.postgresql.org; Tue, 21 Nov 2023 02:04:19 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1r5G7f-00CCiC-6a for pgsql-docs@lists.postgresql.org; Tue, 21 Nov 2023 02:04:19 +0000 Received: from momjian.us ([72.94.173.45]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1r5G7c-007Whb-HQ for pgsql-docs@lists.postgresql.org; Tue, 21 Nov 2023 02:04:18 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=momjian.us; s=2023062407; h=In-Reply-To:Content-Transfer-Encoding:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-ID:Content-Description; bh=JoUQrZm6q60eoiTb7gA0SC88QP/9bF4GlFOfzl3Wmkc=; b=axJnowMXjMuft/z/8r8/l4nLOh ppZVGwPz+USNZNzNZWUdd0gDsJPGehRHB6JHLsj4qAtbgFo9MEPCuEf1ttxq83CSJFEKBjaZWMv+1 gJjNabRbw1Bc7fmh0A/7pY//LCCqinyknBdPZ5b6Wkidupad92cGtO2XrYh4PzTK+XSd8UJHtwm/S /Y+0i2WUrmLM82KhRnwl//+5RuJpY/8ndr5QHDMFNO8qMsyjIjM3YNDy4d4lktXMCTyIs6pLpOlBl 058hEgxwqRCoinG1Gl5jLyiUe/ff1gR066zQY8RZ5K/Lwp8iRS+4pwXa+sgh4hwF0QVEQrLej7Lni hKKCnoog==; Received: from bruce by momjian.us with local (Exim 4.96) (envelope-from ) id 1r5G7Y-0044BC-2w; Mon, 20 Nov 2023 21:04:12 -0500 Date: Mon, 20 Nov 2023 21:04:12 -0500 From: Bruce Momjian To: "David G. Johnston" Cc: 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 Message-ID: References: <152483686904.19805.3369061025704720797@wrigleys.postgresql.org> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="zsdELUvZawjv90Cj" Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --zsdELUvZawjv90Cj Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit 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 https://momjian.us EDB https://enterprisedb.com Only you can decide what is important to you. --zsdELUvZawjv90Cj Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="alias.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 ( expressioncount | ALL } ] [ OFFSET start [ ROW | ROWS ] ] [ FETCH { FIRST | NEXT } [ count ] { ROW | ROWS } { ONLY | WITH TIES } ] - [ FOR { UPDATE | NO KEY UPDATE | SHARE | KEY SHARE } [ OF table_name [, ...] ] [ NOWAIT | SKIP LOCKED ] [...] ] + [ FOR { UPDATE | NO KEY UPDATE | SHARE | KEY SHARE } [ OF from_reference [, ...] ] [ NOWAIT | SKIP LOCKED ] [...] ] where from_item can be one of: @@ -202,7 +202,11 @@ TABLE [ ONLY ] table_name [ * ] is specified, the SELECT statement locks the selected rows against concurrent updates. (See - below.) + below.) from_reference must be a table + alias or non-hidden + table_name referenced + in the FROM clause. --zsdELUvZawjv90Cj--