=?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