public inbox for [email protected]  
help / color / mirror / Atom feed
From: David G. Johnston <[email protected]>
To: Pg Docs <[email protected]>
Subject: Re: Update wording of INSERT ON CONFLICT "rows proposed for insertion"
Date: Mon, 11 Apr 2022 20:21:49 -0700
Message-ID: <CAKFQuwYN20c0+7kKvm3PBgibu77BzxDvk9RvoXBb1=j1mDODPw@mail.gmail.com> (raw)
In-Reply-To: <CAKFQuwZKQoOEHQgTREb7swqryWjHVckcrpOrHUKQqEHznsZfGA@mail.gmail.com>
References: <CAKFQuwZKQoOEHQgTREb7swqryWjHVckcrpOrHUKQqEHznsZfGA@mail.gmail.com>

On Tue, Mar 8, 2022 at 5:14 PM David G. Johnston <[email protected]>
wrote:

>
> I suggest a minor rewording of:
>
> https://www.postgresql.org/docs/devel/sql-insert.html
>
>
Concretely as attached.  I did a bit more than minor work - I decided that
actually calling it a table in the docs didn't really fit how it behaves in
practice and so reworded the "table" into just "name".  Please see the
commit message for more exposition.

David J.


Attachments:

  [application/octet-stream] v0001-on-conflict-excluded-is-name-not-table.patch (3.3K, 3-v0001-on-conflict-excluded-is-name-not-table.patch)
  download | inline diff:
commit 3ae125aafb5bad062952be1e9f97cb2288350f5b
Author: David G. Johnston <[email protected]>
Date:   Tue Apr 12 02:51:18 2022 +0000

    doc: For INSERT ON CONFLICT excluded is a only a name, not a table.
    
    As one cannot place excluded in a FROM clause (subquery) in the
    ON CONFLICT clause referring to it as a table, with plural rows
    nonetheless, leads the reader to infer more about what the
    behavior here is than is correct. We already just say use the
    table's name for the existing row so just match that pattern
    of using the name excluded for the proposed row.
    
    The alias description doesn't have the same issue regarding the
    use of the word table and rows, as the use there is more conceptual,
    but the wording about "otherwise taken as" is wrong: rather two
    labels of excluded end up in scope and you get an ambigious name error.
    
    The error messages still consider excluded to be a table reference
    and this patch does not try to change that.  That implementation
    detail need not force the user-facing documentation for the feature
    to use the term table when it doesn't really apply.

diff --git a/doc/src/sgml/ref/insert.sgml b/doc/src/sgml/ref/insert.sgml
index a9af9959c0..0fad1d3640 100644
--- a/doc/src/sgml/ref/insert.sgml
+++ b/doc/src/sgml/ref/insert.sgml
@@ -175,9 +175,8 @@ INSERT INTO <replaceable class="parameter">table_name</replaceable> [ AS <replac
         class="parameter">table_name</replaceable>.  When an alias is
         provided, it completely hides the actual name of the table.
         This is particularly useful when <literal>ON CONFLICT DO UPDATE</literal>
-        targets a table named <varname>excluded</varname>, since that will otherwise
-        be taken as the name of the special table representing rows proposed
-        for insertion.
+        targets a table named <varname>excluded</varname>, since that will
+        conflict with the special name representing the row proposed for insertion.
        </para>
       </listitem>
      </varlistentry>
@@ -396,8 +395,8 @@ INSERT INTO <replaceable class="parameter">table_name</replaceable> [ AS <replac
         conflict.  The <literal>SET</literal> and
         <literal>WHERE</literal> clauses in <literal>ON CONFLICT DO
         UPDATE</literal> have access to the existing row using the
-        table's name (or an alias), and to rows proposed for insertion
-        using the special <varname>excluded</varname> table.
+        table's name (or an alias), and to the proposed row
+        using the name <varname>excluded</varname>.
         <literal>SELECT</literal> privilege is required on any column in the
         target table where corresponding <varname>excluded</varname>
         columns are read.
@@ -699,8 +698,8 @@ INSERT INTO employees_log SELECT *, current_timestamp FROM upd;
   <para>
    Insert or update new distributors as appropriate.  Assumes a unique
    index has been defined that constrains values appearing in the
-   <literal>did</literal> column.  Note that the special
-   <varname>excluded</varname> table is used to reference values originally
+   <literal>did</literal> column.  Note that the name
+   <varname>excluded</varname> is used to reference values originally
    proposed for insertion:
 <programlisting>
 INSERT INTO distributors (did, dname)


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: [email protected]
  Cc: [email protected], [email protected]
  Subject: Re: Update wording of INSERT ON CONFLICT "rows proposed for insertion"
  In-Reply-To: <CAKFQuwYN20c0+7kKvm3PBgibu77BzxDvk9RvoXBb1=j1mDODPw@mail.gmail.com>

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

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