pg.ddx.io pgsql-hackers@postgresql.org mailing list archive
help / color / mirror / Atom feed From: Marina Polyakova <m.polyakova@postgrespro.ru>
To: Karina Litskevich <litskevichkarina@gmail.com>
Cc: Alexander Pyhalov <a.pyhalov@postgrespro.ru>
Cc: Anthonin Bonnefoy <anthonin.bonnefoy@datadoghq.com>
Cc: Alexander Korotkov <aekorotkov@gmail.com>
Cc: solaimurugan vellaipandiyan <drsolaimurugan.v@gmail.com>
Cc: Álvaro Herrera <alvherre@kurilemu.de>
Cc: g.kashkin@postgrespro.ru, Ashutosh Bapat <ashutosh.bapat.oss@gmail.com>
Cc: PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Subject: Re: Function scan FDW pushdown
Date: Sat, 29 Aug 2026 22:21:53 +0300
Message-ID: <f966e42da14169138b01cdd564b0bf9e@postgrespro.ru> (raw )
In-Reply-To: <CACiT8iamoL-=792e6JK2uCVvwDhfCg7DXHhvqN0P33jhGg2-8A@mail.gmail.com >
References: <202508051955.sao7ucalcce7@alvherre.pgsql >
<e3af56f9b2f1bd9fdf12aff6ca25b18d@postgrespro.ru >
<c42480257bc3350c20749f6c0362826c@postgrespro.ru >
<CAHEL7KQU_=iKQU3dGMV+6vOBWkh=i5g7speEU=VVziRu=3v1Tw@mail.gmail.com >
<b91abe323f12f4210a53feb1ead3ac0d@postgrespro.ru >
<CAPpHfdvz=ahOKEnu4OZ_z3JjQQVddgsNti4FX8SmAKCxmh80BQ@mail.gmail.com >
<7e2abeb3ea9bc7ca024f4e457dce33f5@postgrespro.ru >
<CAPpHfduVg4-6U=oDyBLGV53nU6bVfF+3yqVo9s09TpRSjgMDWw@mail.gmail.com >
<b02d45f5484fedb7e32acbed44abb8f6@postgrespro.ru >
<CAPpHfdvkPk0dLFbF-2DG7hV5zKNPcdyV4Xzj99chYiqAFtvh_Q@mail.gmail.com >
<e0765907e8073c105c76134b5eb6b39b@postgrespro.ru >
<CAPpHfduLKwM=Jj-0q+vWiwNOLYfhJQFs+c-YPF8=voPD1M_trQ@mail.gmail.com >
<214e7cb76a9f142a08246660a649ca0b@postgrespro.ru >
<CAPpHfdtxrvDkGsdxEnaGB4f2apHnHHS0BPySYgZ39gFoBt1F=g@mail.gmail.com >
<2dcab8ff39f8c6f88ecfa3cfb54d8180@postgrespro.ru >
<CAPpHfdvhMtkY-MJ5M3_JjN5wPA7_ZoYw_vmdm97ZEvQ33rCT0g@mail.gmail.com >
<2828ce456ded46a41cd225a1cc393526@postgrespro.ru >
<CAPpHfdv99rqDdZOmo6onNaFkvW_ETj0yVW90yRpNxVtM1iFgWg@mail.gmail.com >
<c6de48bf1f09e2c1a22b5f680d4d9099@postgrespro.ru >
<CAPpHfdubqtP-hMGO7rstR2iUCdq=jOWwy=9p0cdJZHi0BMpJoQ@mail.gmail.com >
<CAO6_XqrGH2NRe0oFx_00nLXra1UZezd3jbS9pgoRhZtgzHD9gg@mail.gmail.com >
<f29ef461267372c23e06ad9ad687f395@postgrespro.ru >
<CACiT8iamoL-=792e6JK2uCVvwDhfCg7DXHhvqN0P33jhGg2-8A@mail.gmail.com >
Hello!
I got this warning with gcc-13 ([1], [2]) and CFLAGS=-Og (both -O0 and
-O1 work fine). Both gcc-12 [3] and gcc-14 [4] work fine with
CFLAGS=-Og. IMO this compiler warning is strange because the attached
patch with a simple code reordering fixes it.
[1] https://github.com/gcc-mirror/gcc/releases/tag/releases%2Fgcc-13.3.0
[2] https://github.com/gcc-mirror/gcc/releases/tag/releases%2Fgcc-13.4.0
[3] Ubuntu 12.3.0-1ubuntu1~22.04.3 12.3.0
[4] https://github.com/gcc-mirror/gcc/releases/tag/releases%2Fgcc-14.4.0
On 2026-08-28 16:18, Karina Litskevich wrote:
> Hi!
>
> Here is another compilation warning that seems to be caused by this
> patch.
>
> postgres_fdw.c: In function ‘foreign_join_ok’:
> postgres_fdw.c:7135:46: error: ‘fpinfo_i’ may be used
> uninitialized [-Werror=maybe-uninitialized]
> 7135 | if (fpinfo_o->local_conds || fpinfo_i->local_conds)
> | ~~~~~~~~^~~~~~~~~~~~~
> postgres_fdw.c:7044:28: note: ‘fpinfo_i’ was declared here
> 7044 | PgFdwRelationInfo *fpinfo_i;
> | ^~~~~~~~
>
> Best regards,
> Karina Litskevich
> Postgres Professional: http://postgrespro.com/
--
Marina Polyakova
Postgres Professional: http://www.postgrespro.com
The Russian Postgres Company
Attachments:
diff_fix_warning.patch (text/x-diff, 2.9K) download
diff --git a/contrib/postgres_fdw/postgres_fdw.c b/contrib/postgres_fdw/postgres_fdw.c
index 9269418a074c3bce26af742d8fbb3550b65e130e..fb61e6e7978c4c9ad683a8d36c4cca08eafcba7d 100644
--- a/contrib/postgres_fdw/postgres_fdw.c
+++ b/contrib/postgres_fdw/postgres_fdw.c
@@ -7044,8 +7044,6 @@ foreign_join_ok(PlannerInfo *root, RelOptInfo *joinrel, JoinType jointype,
PgFdwRelationInfo *fpinfo_i;
ListCell *lc;
List *joinclauses;
- bool outer_is_function = false;
- bool inner_is_function = false;
/*
* We support pushing down INNER, LEFT, RIGHT, FULL OUTER and SEMI joins.
@@ -7075,34 +7073,6 @@ foreign_join_ok(PlannerInfo *root, RelOptInfo *joinrel, JoinType jointype,
(fpinfo_o = (PgFdwRelationInfo *) outerrel->fdw_private) &&
fpinfo_o->pushdown_safe &&
function_rte_pushdown_ok(root, innerrel, outerrel))
- {
- inner_is_function = true;
- }
- else if (jointype == JOIN_INNER && outerrel->rtekind == RTE_FUNCTION &&
- (fpinfo_i = (PgFdwRelationInfo *) innerrel->fdw_private) &&
- fpinfo_i->pushdown_safe &&
- function_rte_pushdown_ok(root, outerrel, innerrel))
- {
- outer_is_function = true;
- }
- else
- {
- fpinfo_o = (PgFdwRelationInfo *) outerrel->fdw_private;
- fpinfo_i = (PgFdwRelationInfo *) innerrel->fdw_private;
- if (!fpinfo_o || !fpinfo_o->pushdown_safe ||
- !fpinfo_i || !fpinfo_i->pushdown_safe)
- return false;
- }
-
- /*
- * If one side is a function RTE, allocate a stub fpinfo so the rest of
- * this function and the cost estimator can treat it uniformly. We hand
- * the stub to the joinrel's deparser via the same path the foreign side
- * uses, but we never permanently attach it to the function rel's
- * fdw_private (different joinrels may pair the same function RTE with
- * different foreign servers).
- */
- if (inner_is_function)
{
fpinfo_i = init_func_stub_fpinfo(fpinfo_o, innerrel);
@@ -7117,7 +7087,10 @@ foreign_join_ok(PlannerInfo *root, RelOptInfo *joinrel, JoinType jointype,
&fpinfo_i->remote_conds, &fpinfo_i->local_conds);
fpinfo->inner_func_fpinfo = fpinfo_i;
}
- else if (outer_is_function)
+ else if (jointype == JOIN_INNER && outerrel->rtekind == RTE_FUNCTION &&
+ (fpinfo_i = (PgFdwRelationInfo *) innerrel->fdw_private) &&
+ fpinfo_i->pushdown_safe &&
+ function_rte_pushdown_ok(root, outerrel, innerrel))
{
fpinfo_o = init_func_stub_fpinfo(fpinfo_i, outerrel);
@@ -7126,6 +7099,14 @@ foreign_join_ok(PlannerInfo *root, RelOptInfo *joinrel, JoinType jointype,
&fpinfo_o->remote_conds, &fpinfo_o->local_conds);
fpinfo->outer_func_fpinfo = fpinfo_o;
}
+ else
+ {
+ fpinfo_o = (PgFdwRelationInfo *) outerrel->fdw_private;
+ fpinfo_i = (PgFdwRelationInfo *) innerrel->fdw_private;
+ if (!fpinfo_o || !fpinfo_o->pushdown_safe ||
+ !fpinfo_i || !fpinfo_i->pushdown_safe)
+ return false;
+ }
/*
* If joining relations have local conditions, those conditions are
view thread (36+ messages) latest in thread
Message-ID: <f966e42da14169138b01cdd564b0bf9e@postgrespro.ru>
Permalink: ../f966e42da14169138b01cdd564b0bf9e@postgrespro.ru/
Also on: postgresql.org/message-id/f966e42da14169138b01cdd564b0bf9e@postgrespro.ru
copy link · copy postgr.es · copy git am
reply 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: m.polyakova@postgrespro.ru, litskevichkarina@gmail.com, a.pyhalov@postgrespro.ru, anthonin.bonnefoy@datadoghq.com, aekorotkov@gmail.com, drsolaimurugan.v@gmail.com, alvherre@kurilemu.de, ashutosh.bapat.oss@gmail.com
Subject: Re: Function scan FDW pushdown
In-Reply-To: <f966e42da14169138b01cdd564b0bf9e@postgrespro.ru>
References: <202508051955.sao7ucalcce7@alvherre.pgsql> <CAPpHfdvkPk0dLFbF-2DG7hV5zKNPcdyV4Xzj99chYiqAFtvh_Q@mail.gmail.com> <e0765907e8073c105c76134b5eb6b39b@postgrespro.ru> <CAPpHfduLKwM=Jj-0q+vWiwNOLYfhJQFs+c-YPF8=voPD1M_trQ@mail.gmail.com> <214e7cb76a9f142a08246660a649ca0b@postgrespro.ru> <CAPpHfdtxrvDkGsdxEnaGB4f2apHnHHS0BPySYgZ39gFoBt1F=g@mail.gmail.com> <2dcab8ff39f8c6f88ecfa3cfb54d8180@postgrespro.ru> <CAPpHfdvhMtkY-MJ5M3_JjN5wPA7_ZoYw_vmdm97ZEvQ33rCT0g@mail.gmail.com> <2828ce456ded46a41cd225a1cc393526@postgrespro.ru> <CAPpHfdv99rqDdZOmo6onNaFkvW_ETj0yVW90yRpNxVtM1iFgWg@mail.gmail.com> <c6de48bf1f09e2c1a22b5f680d4d9099@postgrespro.ru> <CAPpHfdubqtP-hMGO7rstR2iUCdq=jOWwy=9p0cdJZHi0BMpJoQ@mail.gmail.com> <CAO6_XqrGH2NRe0oFx_00nLXra1UZezd3jbS9pgoRhZtgzHD9gg@mail.gmail.com> <f29ef461267372c23e06ad9ad687f395@postgrespro.ru> <CACiT8iamoL-=792e6JK2uCVvwDhfCg7DXHhvqN0P33jhGg2-8A@mail.gmail.com> <f966e42da14169138b01cdd564b0bf9e@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