pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Alvaro Herrera <alvherre@alvh.no-ip.org>
To: Japin Li <japinli@hotmail.com>
Cc: Erik Rijkers <er@xs4all.nl>
Cc: Andrew Dunstan <andrew@dunslane.net>
Cc: Simon Riggs <simon.riggs@enterprisedb.com>
Cc: Tomas Vondra <tomas.vondra@enterprisedb.com>
Cc: Zhihong Yu <zyu@yugabyte.com>
Cc: Daniel Westermann <dwe@dbi-services.com>
Cc: Amit Langote <amitlangote09@gmail.com>
Cc: Justin Pryzby <pryzby@telsasoft.com>
Cc: Pavan Deolasee <pavan.deolasee@gmail.com>
Cc: pgsql-hackers@lists.postgresql.org
Subject: Re: support for MERGE
Date: Thu, 20 Jan 2022 18:02:22 -0300
Message-ID: <202201202102.ivimvlzzk4rv@alvherre.pgsql> (raw)
In-Reply-To: <MEYP282MB16695D606207B2090372E374B6569@MEYP282MB1669.AUSP282.PROD.OUTLOOK.COM>

On 2022-Jan-17, Japin Li wrote:

> So for NOT MATCHED, we are expected not use the target table columns.
> 
> The code comes from execMerge.c says:
> 
>     /*
>      * Make source tuple available to ExecQual and ExecProject. We don't need
>      * the target tuple, since the WHEN quals and the targetlist can't refer to
>      * the target columns.
>      */
>     econtext->ecxt_scantuple = NULL;
>     econtext->ecxt_innertuple = slot;
>     econtext->ecxt_outertuple = NULL;
> 
> It will set econtext->ecxt_scantuple to NULL, which leads the crash.

Right.  So this was broken by the fact that I recently allowed MATCHED
actions to target DO NOTHING; previously, only NOT MATCHED actions could
do so.  So the bug was present, but it wasn't accessible.

> Should we setNamespaceVisibilityForRTE() for CMD_NOTHING?  I try to set it
> and it works as expected.  OTOH, the system attributes from target table
> also cannot be accessible.  I'm not sure the v6 patch how to implement this
> limitation.

I changed this block so that it depends on whether the clause is MATCHED
or NOT MATCHED, rather than the action.  I think it was pretty
nonsensical for it to be keyed on action type, and it made the code
needlessly longer.

Thank you!

-- 
Álvaro Herrera              Valdivia, Chile  —  https://www.EnterpriseDB.com/
"All rings of power are equal,
But some rings of power are more equal than others."
                                 (George Orwell's The Lord of the Rings)





view thread (123+ messages)  latest in thread

Message-ID: <202201202102.ivimvlzzk4rv@alvherre.pgsql>
Permalink:  ../202201202102.ivimvlzzk4rv@alvherre.pgsql/
Also on:    postgresql.org/message-id/202201202102.ivimvlzzk4rv@alvherre.pgsql

 · 

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-hackers@postgresql.org
  Cc: alvherre@alvh.no-ip.org, japinli@hotmail.com, er@xs4all.nl, andrew@dunslane.net, simon.riggs@enterprisedb.com, tomas.vondra@enterprisedb.com, zyu@yugabyte.com, dwe@dbi-services.com, amitlangote09@gmail.com, pryzby@telsasoft.com, pavan.deolasee@gmail.com, pgsql-hackers@lists.postgresql.org
  Subject: Re: support for MERGE
  In-Reply-To: <202201202102.ivimvlzzk4rv@alvherre.pgsql>

* 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