pg.ddx.io pgsql-bugs@postgresql.org mailing list archivehelp / color / mirror / Atom feed
Merge command is erroring with: PlaceHolderVar found where not expected 2+ messages / 2 participants [nested] [flat]
Commits from this thread: 2023-03-15 e3ac85014e 3908d6ae11 Support PlaceHolderVars in MERGE actions.
* Merge command is erroring with: PlaceHolderVar found where not expected @ 2023-03-15 12:24 Önder Kalacı <onderkalaci@gmail.com> 0 siblings, 1 reply; 2+ messages in thread From: Önder Kalacı @ 2023-03-15 12:24 UTC (permalink / raw) To: pgsql-bugs@lists.postgresql.org Hi hackers, While playing with the Merge command, I get an unexpected error. I've searched the mailing list, but couldn't find any reference to this, so decided to send an e-mail. 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* Here is the backtrace: ``` thread #1, queue = 'com.apple.main-thread', stop reason = breakpoint 2.1 * frame #0: 0x000000010d60f0df postgres`errstart(elevel=21, domain=0x0000000000000000) at elog.c:453:6 [opt] frame #1: 0x000000010d6d7e7e postgres`pull_var_clause_walker.cold.7 at var.c:703:4 [opt] frame #2: 0x000000010d415dae postgres`pull_var_clause_walker(node=<unavailable>, context=0x00007ff7b2dcb7d0) at var.c:703:4 [opt] frame #3: 0x000000010d3782a5 postgres`expression_tree_walker_impl(node=0x00007ff18503a7c0, walker=<unavailable>, context=<unavailable>) at nodeFuncs.c:2206:9 [opt] frame #4: 0x000000010d415dfe postgres`pull_var_clause_walker(node=<unavailable>, context=<unavailable>) at var.c:705:9 [opt] [artificial] frame #5: 0x000000010d415cfc postgres`pull_var_clause(node=<unavailable>, flags=0) at var.c:622:2 [opt] frame #6: 0x000000010d3fac81 postgres`preprocess_targetlist(root=0x00007ff185037a28) at preptlist.c:165:11 [opt] frame #7: 0x000000010d3e6941 postgres`grouping_planner(root=<unavailable>, tuple_fraction=<unavailable>) at planner.c:1419:3 [opt] frame #8: 0x000000010d3e5678 postgres`subquery_planner(glob=<unavailable>, parse=<unavailable>, parent_root=<unavailable>, hasRecursion=<unavailable>, tuple_fraction=0) at planner.c:1065:2 [opt] frame #9: 0x000000010d3e4277 postgres`standard_planner(parse=0x00007ff185011668, query_string=<unavailable>, cursorOptions=2048, boundParams=0x0000000000000000) at planner.c:411:9 [opt] ``` Thanks, Onder KALACI ^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: Merge command is erroring with: PlaceHolderVar found where not expected @ 2023-03-15 14:48 Tom Lane <tgl@sss.pgh.pa.us> parent: Önder Kalacı <onderkalaci@gmail.com> 0 siblings, 0 replies; 2+ messages in thread From: Tom Lane @ 2023-03-15 14:48 UTC (permalink / raw) To: Önder Kalacı <onderkalaci@gmail.com>; +Cc: pgsql-bugs@lists.postgresql.org =?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 ^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2023-03-15 14:48 UTC | newest] Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed) -- links below jump to the message on this page -- 2023-03-15 12:24 Merge command is erroring with: PlaceHolderVar found where not expected Önder Kalacı <onderkalaci@gmail.com> 2023-03-15 14:48 ` Tom Lane <tgl@sss.pgh.pa.us>
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