Re: foreign join error "variable not found in subplan target list"

From: Richard Guo <guofenglinux(at)gmail(dot)com>
To: Etsuro Fujita <etsuro(dot)fujita(at)gmail(dot)com>
Cc: Alexander Pyhalov <a(dot)pyhalov(at)postgrespro(dot)ru>, PostgreSQL mailing lists <pgsql-bugs(at)lists(dot)postgresql(dot)org>
Subject: Re: foreign join error "variable not found in subplan target list"
Date: 2022-08-30 01:18:54
Message-ID: CAMbWs4_8WjxO1XUN+PsW1ukfSrVfOrCHS5rbJM6dr0qPhBogkg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On Mon, Aug 29, 2022 at 5:45 PM Richard Guo <guofenglinux(at)gmail(dot)com> wrote:

>
> On Mon, Aug 29, 2022 at 2:17 PM Etsuro Fujita <etsuro(dot)fujita(at)gmail(dot)com>
> wrote:
>
>> One thing I noticed while re-reading the patch is that we should use
>> create_projection_path() here, to avoid modifying the epq_path in
>> place, as it is already used for an unsorted join-pushdown path before
>> we get here. So I modified the patch as such. Updated patch
>> attached.
>
>
> The new change looks reasonable to me as there is other ref to this
> epq_path.
>
> I'm looking again on how we adjust the PathTarget, and I think we may
> need to update the cost and width fields if there are any new columns
> added. Maybe we can leverage set_pathtarget_cost_width for that.
>

To be concrete, I mean something like this:

--- a/contrib/postgres_fdw/postgres_fdw.c
+++ b/contrib/postgres_fdw/postgres_fdw.c
@@ -5808,6 +5808,10 @@ add_paths_with_pathkeys_for_rel(PlannerInfo *root,
RelOptInfo *rel,

PVC_RECURSE_PLACEHOLDERS));
}

+ /* Update the cost and width fields if we have added any
new columns. */
+ if (!equal(epq_path->pathtarget->exprs, target->exprs))
+ set_pathtarget_cost_width(root, target);
+
/*
* The passed-in EPQ path is a join path, so it is
projection-capable,
* but we use create_projection_path() here, so as to avoid
modifying

Thanks
Richard

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Tom Lane 2022-08-30 02:04:39 Re: foreign join error "variable not found in subplan target list"
Previous Message Kirk Wolak 2022-08-29 18:24:14 Re: BUG #17598: EXTENSION can no longer create it's own schema! (Create Schema IF NOT EXISTS XXX)