pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Önder Kalacı <onderkalaci@gmail.com>
Cc: pgsql-bugs@lists.postgresql.org
Subject: Re: Merge command is erroring with: PlaceHolderVar found where not expected
Date: Wed, 15 Mar 2023 10:48:21 -0400
Message-ID: <3204629.1678891701@sss.pgh.pa.us> (raw)
In-Reply-To: <CACawEhUuum-gC_2S3sXLTcsk7bUSPSHOD+g1ZpfKaDK-KKPPWA@mail.gmail.com>
References: <CACawEhUuum-gC_2S3sXLTcsk7bUSPSHOD+g1ZpfKaDK-KKPPWA@mail.gmail.com>

=?UTF-8?B?w5ZuZGVyIEthbGFjxLE=?= <onderkalaci@gmail.com> writes:
> CREATE TABLE source (id integer, z int);
> CREATE TABLE target (id integer, z int);
> MERGE INTO public.target sda USING ((SELECT source.id, source.z, 12 AS rnd
> FROM public.source source) sdn FULL JOIN public.source sdn2 ON ((sdn.id
> OPERATOR(pg_catalog.=) sdn2.id))) ON (sda.id OPERATOR(pg_catalog.=) sdn.id)
> WHEN NOT MATCHED THEN INSERT (id, z) VALUES (sdn.id, sdn.rnd);

> *ERROR:  PlaceHolderVar found where not expected*

Thanks for the report!  Somebody was far too optimistic here:

             * Add resjunk entries for any Vars used in each action's
             * targetlist and WHEN condition that belong to relations other
             * than target.  Note that aggregates, window functions and
             * placeholder vars are not possible anywhere in MERGE's WHEN
             * clauses.  (PHVs may be added later, but they don't concern us
             * here.)

I'm not sure offhand whether RECURSE or INCLUDE is the more appropriate
action.

			regards, tom lane





view thread (2+ messages)

Message-ID: <3204629.1678891701@sss.pgh.pa.us>
Permalink:  ../3204629.1678891701@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/3204629.1678891701@sss.pgh.pa.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-bugs@postgresql.org
  Cc: tgl@sss.pgh.pa.us, onderkalaci@gmail.com, pgsql-bugs@lists.postgresql.org
  Subject: Re: Merge command is erroring with: PlaceHolderVar found where not expected
  In-Reply-To: <3204629.1678891701@sss.pgh.pa.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