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
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