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: dwayne.towell@gmail.com
Cc: pgsql-docs@lists.postgresql.org
Subject: Re: MERGE examples not clear
Date: Fri, 1 Nov 2024 16:21:09 -0400
Message-ID: <ZyU4NaROlZbNUc-q@momjian.us> (raw)
In-Reply-To: <ZRS98kJEt9AZAtpM@momjian.us>
References: <167699245721.1902146.6479762301617101634@wrigleys.postgresql.org>
	<CAKFQuwZrP1_hRLT8JXdfX4Bi20-Y3oGPsaKeRVe9bNzngFP+JQ@mail.gmail.com>
	<ZRS98kJEt9AZAtpM@momjian.us>

On Wed, Sep 27, 2023 at 07:42:42PM -0400, Bruce Momjian wrote:
> On Tue, Feb 21, 2023 at 08:56:50AM -0700, David G. Johnston wrote:
> > On Tue, Feb 21, 2023 at 8:35 AM PG Doc comments form <noreply@postgresql.org>
> > wrote:
> > 
> >     The following documentation comment has been logged on the website:
> > 
> >     Page: https://www.postgresql.org/docs/15/sql-merge.html
> >     Description:
> > 
> >     On this page: https://www.postgresql.org/docs/15/sql-merge.html
> >     the first and second examples seems to be contrasted (by "this would be
> >     exactly equivalent to the following statement"), however the difference
> >     does
> >     not seem to related to the stated reason ("the MATCHED result does not
> >     change"). It seems like the difference should involve the order of WHEN
> >     clauses?
> >     Of course, it might be that I don't understand the point, in which case
> >     maybe the point could be stated more clearly?
> > 
> > 
> > Yeah, that is a pretty poor pair of examples.  Given that a given customer can
> > reasonably be assumed to have more than one recent transaction the MERGE has a
> > good chance of failing.
> > 
> > The only difference between the two is the second one uses an explicit subquery
> > as the source while the first simply names a table.  If the subquery had a
> > GROUP BY customer_id that would be a good change explaining that the second
> > query is different because it is resilient in the face of duplicate customer
> > recent transactions.
> > 
> > While here...source_alias (...completely hides...the fact that a query was
> > issued).  What?  Probably it should read (not verified) that it is actually
> > required when the source is a query (maybe tweaking the syntax to match).
> 
> The attached patch removes the second example, which doesn't seem to add
> much.

Patch from September 2023 applied.

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

  When a patient asks the doctor, "Am I going to die?", he means 
  "Am I going to die soon?"





view thread (4+ messages)

Message-ID: <ZyU4NaROlZbNUc-q@momjian.us>
Permalink:  ../ZyU4NaROlZbNUc-q@momjian.us/
Also on:    postgresql.org/message-id/ZyU4NaROlZbNUc-q@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, dwayne.towell@gmail.com, pgsql-docs@lists.postgresql.org
  Subject: Re: MERGE examples not clear
  In-Reply-To: <ZyU4NaROlZbNUc-q@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