pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Yilin Zhang <jiezhilove@126.com>
To: dinesh salve <cooltodinesh@gmail.com>
Cc: Sami Imseih <samimseih@gmail.com>
Cc: Tom Lane <tgl@sss.pgh.pa.us>
Cc: pgsql-hackers@postgresql.org, "Jeff Davis" <pgsql@j-davis.com>
Subject: Re: explain plans for foreign servers
Date: Fri, 24 Jul 2026 11:05:41 +0800 (CST)
Message-ID: <259e89b5.2626.19f9215f7e2.Coremail.jiezhilove@126.com> (raw)
In-Reply-To: <CAP+B4TANKj+1h1iJc86vj2XFs075ghXNkjzruRAL6G1yZLX3GQ@mail.gmail.com>
References: <CAP+B4TD=iy-C2EnsrJgjpwSc7_4pd3Xh-gFzA0bwsw3q8u860g@mail.gmail.com>
	<CAA5RZ0vXiOiodrNQ-Va4FCAkXMpGA=GZDeKjFBRgRvHGuW7s7Q@mail.gmail.com>
	<07147023882ac6c4424df946fd4b82b8e8c211a5.camel@j-davis.com>
	<341357.1741201933@sss.pgh.pa.us>
	<fc0cd0a77a2a5566f30a630580affb9fc3f43ce7.camel@j-davis.com>
	<CAP+B4TDxE3gbrixL9qR9F+CK_N_N0-HmXSL55QXVZNAorRHSHQ@mail.gmail.com>
	<CAA5RZ0skXF+d7SANSnMi3xMTs9zr6dZadyc5OEtPiMnw-rGizw@mail.gmail.com>
	<CAA5RZ0vFAhGgz-VwE0NwvesHNDN5PWAgWA1B=cECg0=5nt0kjQ@mail.gmail.com>
	<CAA5RZ0spw7Fmd5pGvFdTaG2GqkSm6HeXJABbBeqzUDkuN4uevQ@mail.gmail.com>
	<CAP+B4TDRPOth7EJcmFMNaA-XchbPpfZ1OPk+__0a1ZMhibJjrw@mail.gmail.com>
	<CAA5RZ0taqqxv8m8RuZJkFXQ_ZxtaQNcHnga47LW5dKYqZLt4Rg@mail.gmail.com>
	<CAP+B4TDngSD2SftX3-O_scuPPBcYQOUaRhraH-XhX4WQ1KeDsA@mail.gmail.com>
	<CAA5RZ0t_5rMsjFficztwJD7nuupbS4GDj0suKxfShdRXjm7c0A@mail.gmail.com>
	<CAP+B4TBATGojLy4ySehGRLWYHyt9WW-ggL+3T=GSn006kiuqqQ@mail.gmail.com>
	<CAP+B4TANKj+1h1iJc86vj2XFs075ghXNkjzruRAL6G1yZLX3GQ@mail.gmail.com>

At 2026-07-09 02:12:36, "dinesh salve" <cooltodinesh@gmail.com> wrote:
> As discussed offline, also added a regression test that joins two foreign
> tables living on different foreign servers (loopback and loopback2), which
> exercises REMOTE_PLANS over multiple fdw connections.


Hi,
Few comments for v4-0001.


1.
inline patch 1: src/include/commands/explain_state.h (+1/-0 lines) download inline-1.patch--- a/src/include/commands/explain_state.h +++ b/src/include/commands/explain_state.h @@ -45,6 +45,7 @@ typedef struct ExplainWorkersState typedef struct ExplainState { StringInfo str; /* output buffer */ + /* options */ bool verbose; /* be verbose */ bool analyze; /* print actual times */
Is this blank line in explain_state.h necessary? 2. diff --git a/contrib/postgres_fdw/postgres_fdw.c b/contrib/postgres_fdw/postgres_fdw.c index 0ea72a6..ff8c76e 100644 --- a/contrib/postgres_fdw/postgres_fdw.c +++ b/contrib/postgres_fdw/postgres_fdw.c ...... +static void +postgresExplainStatement(int plan_node_id, + ExplainState *es, + PgFdwExplainState *pgfdw_explain_state, + PGconn *conn, + char *sql) +{ + PGresult *volatile res = NULL; + StringInfoData explain_sql; + int remote_version = PQserverVersion(conn); + + /* + * GENERIC_PLAN required because deparsed SQL may contain $n placeholders; + * only available from PG 16. + */ + if (remote_version < 160000) + ereport(ERROR, + errcode(ERRCODE_FEATURE_NOT_SUPPORTED), + errmsg("EXPLAIN option REMOTE_PLANS requires a remote server version of 16 or later"), + errdetail("The remote server version is %d.", remote_version)); + + PG_TRY(); + { + int numrows, + i; + PgFdwExplainRemotePlans *explain = (PgFdwExplainRemotePlans *) palloc(sizeof(PgFdwExplainRemotePlans)); + ListCell *lc; + + initStringInfo(&explain_sql); + initStringInfo(&explain->explain_plan); The StringInfoData explain_sql; declared here is uninitialized. While the risk is low, it could lead to subtle problems. This pattern also does not align with existing usage of StringInfoData throughout the codebase. I recommend initializing it before entering the PG_TRY block. Best regards, -- Yilin Zhang

view thread (31+ messages)  latest in thread

Message-ID: <259e89b5.2626.19f9215f7e2.Coremail.jiezhilove@126.com>
Permalink:  ../259e89b5.2626.19f9215f7e2.Coremail.jiezhilove@126.com/
Also on:    postgresql.org/message-id/259e89b5.2626.19f9215f7e2.Coremail.jiezhilove@126.com

 ·  · 

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: jiezhilove@126.com, cooltodinesh@gmail.com, samimseih@gmail.com, tgl@sss.pgh.pa.us, pgsql@j-davis.com
  Subject: Re: explain plans for foreign servers
  In-Reply-To: <259e89b5.2626.19f9215f7e2.Coremail.jiezhilove@126.com>
  References: <CAP+B4TD=iy-C2EnsrJgjpwSc7_4pd3Xh-gFzA0bwsw3q8u860g@mail.gmail.com> <07147023882ac6c4424df946fd4b82b8e8c211a5.camel@j-davis.com> <341357.1741201933@sss.pgh.pa.us> <fc0cd0a77a2a5566f30a630580affb9fc3f43ce7.camel@j-davis.com> <CAP+B4TDxE3gbrixL9qR9F+CK_N_N0-HmXSL55QXVZNAorRHSHQ@mail.gmail.com> <CAA5RZ0skXF+d7SANSnMi3xMTs9zr6dZadyc5OEtPiMnw-rGizw@mail.gmail.com> <CAA5RZ0vFAhGgz-VwE0NwvesHNDN5PWAgWA1B=cECg0=5nt0kjQ@mail.gmail.com> <CAA5RZ0spw7Fmd5pGvFdTaG2GqkSm6HeXJABbBeqzUDkuN4uevQ@mail.gmail.com> <CAP+B4TDRPOth7EJcmFMNaA-XchbPpfZ1OPk+__0a1ZMhibJjrw@mail.gmail.com> <CAA5RZ0taqqxv8m8RuZJkFXQ_ZxtaQNcHnga47LW5dKYqZLt4Rg@mail.gmail.com> <CAP+B4TDngSD2SftX3-O_scuPPBcYQOUaRhraH-XhX4WQ1KeDsA@mail.gmail.com> <CAA5RZ0t_5rMsjFficztwJD7nuupbS4GDj0suKxfShdRXjm7c0A@mail.gmail.com> <CAP+B4TBATGojLy4ySehGRLWYHyt9WW-ggL+3T=GSn006kiuqqQ@mail.gmail.com> <CAP+B4TANKj+1h1iJc86vj2XFs075ghXNkjzruRAL6G1yZLX3GQ@mail.gmail.com> <259e89b5.2626.19f9215f7e2.Coremail.jiezhilove@126.com>

* 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