Re: Merge command is erroring with: PlaceHolderVar found where not expected - Mailing list pgsql-bugs

From Tom Lane
Subject Re: Merge command is erroring with: PlaceHolderVar found where not expected
Date
Msg-id 3204629.1678891701@sss.pgh.pa.us
Whole thread Raw
In response to Merge command is erroring with: PlaceHolderVar found where not expected  (Önder Kalacı <onderkalaci@gmail.com>)
List pgsql-bugs
=?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



pgsql-bugs by date:

Previous
From: Önder Kalacı
Date:
Subject: Merge command is erroring with: PlaceHolderVar found where not expected
Next
From: Sébastien
Date:
Subject: Re: BUG #17840: Failing to execute auto_explain for logging leads to transaction rollback.