From: Justin Pryzby <pryzby@telsasoft.com>
To: David G. Johnston <david.g.johnston@gmail.com>
Cc: Alvaro Herrera <alvherre@alvh.no-ip.org>
Cc: Matthias van de Meent <boekewurm+postgres@gmail.com>
Cc: pgsql-hackers@postgresql.org
Subject: Re: MERGE and parsing with prepared statements
Date: Mon, 18 Jul 2022 08:20:00 -0500
Message-ID: <20220718132000.GB18011@telsasoft.com> (raw)
In-Reply-To: <20220715204341.GO18011@telsasoft.com>
References: <20220715175854.GM18011@telsasoft.com>
<20220715184019.rour3mk33ngc76y6@alvherre.pgsql>
<CAKFQuwbtQk52zWLYsXvO2+ZGTPu+MPvWgaCS7jQKuGhrwn0-rA@mail.gmail.com>
<20220715194013.GN18011@telsasoft.com>
<CAKFQuwb4X_WMoV_k=ybPWYybz+=T1JhPqkOY=xdoJNzMHEiBwg@mail.gmail.com>
<20220715204341.GO18011@telsasoft.com>
On Fri, Jul 15, 2022 at 03:43:41PM -0500, Justin Pryzby wrote:
> Should that sentence be removed from MERGE ?
Also, I think these examples should be more similar.
doc/src/sgml/ref/merge.sgml
> <programlisting>
> MERGE INTO CustomerAccount CA
> USING RecentTransactions T
> ON T.CustomerId = CA.CustomerId
> WHEN MATCHED THEN
> UPDATE SET Balance = Balance + TransactionValue
> WHEN NOT MATCHED THEN
> INSERT (CustomerId, Balance)
> VALUES (T.CustomerId, T.TransactionValue);
> </programlisting>
> </para>
>
> <para>
> Notice that this would be exactly equivalent to the following
> statement because the <literal>MATCHED</literal> result does not change
> during execution.
>
> <programlisting>
> MERGE INTO CustomerAccount CA
> USING (Select CustomerId, TransactionValue From RecentTransactions) AS T
> ON CA.CustomerId = T.CustomerId
> WHEN NOT MATCHED THEN
> INSERT (CustomerId, Balance)
> VALUES (T.CustomerId, T.TransactionValue)
> WHEN MATCHED THEN
> UPDATE SET Balance = Balance + TransactionValue;
> </programlisting>
> </para>
The "ON" lines can be the same.
The "MATCHED" can be in the same order.
--
Justin
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 from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-hackers@postgresql.org
Cc: pryzby@telsasoft.com, david.g.johnston@gmail.com, alvherre@alvh.no-ip.org, boekewurm+postgres@gmail.com
Subject: Re: MERGE and parsing with prepared statements
In-Reply-To: <20220718132000.GB18011@telsasoft.com>
References: <20220715175854.GM18011@telsasoft.com> <20220715184019.rour3mk33ngc76y6@alvherre.pgsql> <CAKFQuwbtQk52zWLYsXvO2+ZGTPu+MPvWgaCS7jQKuGhrwn0-rA@mail.gmail.com> <20220715194013.GN18011@telsasoft.com> <CAKFQuwb4X_WMoV_k=ybPWYybz+=T1JhPqkOY=xdoJNzMHEiBwg@mail.gmail.com> <20220715204341.GO18011@telsasoft.com> <20220718132000.GB18011@telsasoft.com>
* 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