aboutsummaryrefslogtreecommitdiff
path: root/contrib/postgres_fdw/postgres_fdw.h
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2019-12-02 16:31:03 -0500
committerTom Lane <tgl@sss.pgh.pa.us>2019-12-02 16:31:03 -0500
commit4526951d564a7eed512b4a0ac3b5893e0a115690 (patch)
treefdf1c5cea4c021ffa178de3baf4aa4fd3a785b0b /contrib/postgres_fdw/postgres_fdw.h
parent1d468b9ad81b9139b4a0b16b416c3597925af4b0 (diff)
downloadpostgresql-4526951d564a7eed512b4a0ac3b5893e0a115690.tar.gz
postgresql-4526951d564a7eed512b4a0ac3b5893e0a115690.zip
Make postgres_fdw's "Relations" output agree with the rest of EXPLAIN.
The relation aliases shown in the "Relations" line for a foreign scan didn't always agree with those used in the rest of EXPLAIN's output. The regression test result changes appearing here provide examples. It's really impossible for postgres_fdw to duplicate EXPLAIN's alias assignment logic during postgresGetForeignRelSize(), because of the de-duplication that EXPLAIN does on a global basis --- and anyway, trying to duplicate that would be unmaintainable. Instead, just put numeric rangetable indexes into the string, and convert those to table names/aliases in postgresExplainForeignScan, which does have access to the results of ruleutils.c's alias assignment logic. Aside from being more reliable, this shifts some work from planning to EXPLAIN, which is a good tradeoff for performance. (I also changed from using StringInfo to using psprintf, which makes the code slightly simpler and reduces its memory consumption.) A kluge required by this solution is that we have to reverse-engineer the rtoffset applied by setrefs.c. If that logic ever fails (presumably because the member tables of a join got offset by different amounts), we'll need some more cooperation with setrefs.c to keep things straight. But for now, there's no need for that. Arguably this is a back-patchable bug fix, but since this is a mostly cosmetic issue and there have been no field complaints, I'll refrain for now. Discussion: https://postgr.es/m/12424.1575168015@sss.pgh.pa.us
Diffstat (limited to 'contrib/postgres_fdw/postgres_fdw.h')
-rw-r--r--contrib/postgres_fdw/postgres_fdw.h11
1 files changed, 7 insertions, 4 deletions
diff --git a/contrib/postgres_fdw/postgres_fdw.h b/contrib/postgres_fdw/postgres_fdw.h
index bdefe0c40e2..ea052872c3e 100644
--- a/contrib/postgres_fdw/postgres_fdw.h
+++ b/contrib/postgres_fdw/postgres_fdw.h
@@ -87,11 +87,14 @@ typedef struct PgFdwRelationInfo
int fetch_size; /* fetch size for this remote table */
/*
- * Name of the relation while EXPLAINing ForeignScan. It is used for join
- * relations but is set for all relations. For join relation, the name
- * indicates which foreign tables are being joined and the join type used.
+ * Name of the relation, for use while EXPLAINing ForeignScan. It is used
+ * for join and upper relations but is set for all relations. For a base
+ * relation, this is really just the RT index as a string; we convert that
+ * while producing EXPLAIN output. For join and upper relations, the name
+ * indicates which base foreign tables are included and the join type or
+ * aggregation type used.
*/
- StringInfo relation_name;
+ char *relation_name;
/* Join information */
RelOptInfo *outerrel;