From: Alexander Pyhalov <a.pyhalov@postgrespro.ru>
To: pgsql-bugs@lists.postgresql.org
Subject: foreign join error "variable not found in subplan target list"
Date: Mon, 08 Aug 2022 18:26:44 +0300
Message-ID: <cfb17bf6dfdf876467bd5ef533852d18@postgrespro.ru> (raw)
Hi.
Using the following patch I'm able to get
"ERROR: variable not found in subplan target list"
on foreign join pushdown for update returning.
It seems that we generate Result node which has 7 vars in targetlist
over Sort plan node, which has only 6 vars in targetlist.
So far not sure what causes this.
--
Best regards,
Alexander Pyhalov,
Postgres Professional
Attachments:
[text/x-diff] costs_tweaks.diff (1.1K, ../cfb17bf6dfdf876467bd5ef533852d18@postgrespro.ru/2-costs_tweaks.diff)
download | inline diff:diff --git a/contrib/postgres_fdw/sql/postgres_fdw.sql b/contrib/postgres_fdw/sql/postgres_fdw.sqlindex 42735ae78a9..5eb387ef14f 100644--- a/contrib/postgres_fdw/sql/postgres_fdw.sql+++ b/contrib/postgres_fdw/sql/postgres_fdw.sql@@ -1355,6 +1355,9 @@ INSERT INTO ft2 (c1,c2,c3)
EXPLAIN (verbose, costs off)
UPDATE ft2 SET c3 = 'bar' WHERE postgres_fdw_abs(c1) > 2000 RETURNING *; -- can't be pushed down
UPDATE ft2 SET c3 = 'bar' WHERE postgres_fdw_abs(c1) > 2000 RETURNING *;
+ALTER SERVER loopback OPTIONS (add fdw_startup_cost '10000.0');+ALTER SERVER loopback OPTIONS (add fdw_tuple_cost '1.0');+SET enable_nestloop TO false;
EXPLAIN (verbose, costs off)
UPDATE ft2 SET c3 = 'baz'
FROM ft4 INNER JOIN ft5 ON (ft4.c1 = ft5.c1)
@@ -1364,6 +1367,9 @@ UPDATE ft2 SET c3 = 'baz'
FROM ft4 INNER JOIN ft5 ON (ft4.c1 = ft5.c1)
WHERE ft2.c1 > 2000 AND ft2.c2 === ft4.c1
RETURNING ft2.*, ft4.*, ft5.*;
+RESET enable_nestloop;+ALTER SERVER loopback OPTIONS (drop fdw_startup_cost);+ALTER SERVER loopback OPTIONS (drop fdw_tuple_cost);
EXPLAIN (verbose, costs off)
DELETE FROM ft2
USING ft4 INNER JOIN ft5 ON (ft4.c1 === ft5.c1)
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: a.pyhalov@postgrespro.ru, pgsql-bugs@lists.postgresql.org
Subject: Re: foreign join error "variable not found in subplan target list"
In-Reply-To: <cfb17bf6dfdf876467bd5ef533852d18@postgrespro.ru>
* 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