From: Alexander Pyhalov <a.pyhalov@postgrespro.ru>
To: Fujii Masao <masao.fujii@gmail.com>
Cc: PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Subject: Re: postgres_fdw: Fix crash when estimating joins with functions
Date: Wed, 09 Sep 2026 18:09:42 +0300
Message-ID: <ae12f92b71879b41e82a2eb952ded6ed@postgrespro.ru> (raw)
In-Reply-To: <CAHGQGwGE9xPzCke0C0r4omTkh-hU08aBd2j9oSA0FYmJLCf9jA@mail.gmail.com>
References: <CAHGQGwGE9xPzCke0C0r4omTkh-hU08aBd2j9oSA0FYmJLCf9jA@mail.gmail.com>
Fujii Masao писал(а) 2026-09-09 17:02:
> Hi,
>
> On master, I found that the following causes a segmentation fault:
>
> CREATE EXTENSION postgres_fdw;
> CREATE SERVER loopback FOREIGN DATA WRAPPER postgres_fdw;
> CREATE USER MAPPING FOR PUBLIC SERVER loopback;
> CREATE TABLE t (i int);
> CREATE FOREIGN TABLE ft (i int) SERVER loopback
> OPTIONS (table_name 't', use_remote_estimate 'true');
> EXPLAIN SELECT * FROM generate_series(1, 3) g JOIN ft ON ft.i = g;
>
> This crash seems to occur because init_func_stub_fpinfo() forgets to
> copy
> the user mapping to the function-side stub, leaving it NULL. The NULL
> mapping is then passed to GetConnection() when requesting a remote
> estimate, causing the segmentation fault.
>
> This seems to have been introduced by commit 0ee83dd4a99.
>
> The attached patch fixes this by also copying the user mapping from the
> foreign side.
>
> Regards,
Hi. Thanks. Looks good to me.
--
Best regards,
Alexander Pyhalov,
Postgres Professional
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 from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-hackers@postgresql.org
Cc: a.pyhalov@postgrespro.ru, masao.fujii@gmail.com
Subject: Re: postgres_fdw: Fix crash when estimating joins with functions
In-Reply-To: <ae12f92b71879b41e82a2eb952ded6ed@postgrespro.ru>
References: <CAHGQGwGE9xPzCke0C0r4omTkh-hU08aBd2j9oSA0FYmJLCf9jA@mail.gmail.com> <ae12f92b71879b41e82a2eb952ded6ed@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