postgres.git / summary / log / commit / refs
commit debfb3c8a8c93e7bcc3638523b7ffc0846cc2db8
Author: Etsuro Fujita <efujita@postgresql.org>
Date: Thu Nov 12 02:15:00 2026 +0000
First released in: 19.0
postgres_fdw: Update some comments in functions for statistics import.
* Fix a typo in a comment in match_attrmap(): s/attname/remote_attname/
* Add a comment about using a NullableDatum array in
import_fetched_statistics().
* Tweak the comments for each of the two functions.
Follow-up to commits 28972b6fc and 54cd6fc83.
Author: Etsuro Fujita <etsuro.fujita@gmail.com>
Reviewed-by: Chao Li <lic@highgo.com>
Discussion: https://postgr.es/m/CAPmGK17d%3DUz-_teKwZdJN8T644QQyzEq%3DpUuf9gc%2Bc2Hp3x6%2Bw%40mail.gmail.com
Backpatch-through: 19
contrib/postgres_fdw/postgres_fdw.c | 20 +++++++++++++-------
1 file changed, 13 insertions(+), 7 deletions(-)
diff --git a/contrib/postgres_fdw/postgres_fdw.c b/contrib/postgres_fdw/postgres_fdw.c
index 7621f679a99..2b467923691 100644
--- a/contrib/postgres_fdw/postgres_fdw.c
+++ b/contrib/postgres_fdw/postgres_fdw.c
@@ -6209,10 +6209,10 @@ remattrmap_cmp(const void *v1, const void *v2)
/*
* Match local columns to result set rows.
*
- * As the result set consists of the attribute stats for some/all of distinct
- * mapped remote columns in the RemoteAttributeMapping, every entry in it
- * should have at most one match in the result set; which is also ordered by
- * remote_attname, so we find such pairs by doing a merge join.
+ * As the result set consists of the attribute stats for distinct mapped
+ * remote columns, every entry in the RemoteAttributeMapping should have at
+ * most one match in the result set; which is also ordered by remote_attname,
+ * so we find such pairs by doing a merge join.
*
* Returns true if every entry in it has a match, and false if not.
*/
@@ -6271,8 +6271,8 @@ match_attrmap(PGresult *res,
row += 1;
/*
- * If the attname in the entry is less than that in the next stats
- * row, it means the stats for the entry are missing.
+ * If the remote_attname in the entry is less than that in the next
+ * stats row, it means the stats for the entry are missing.
*/
if (strcmp(remattrmap[mapidx].remote_attname,
PQgetvalue(res, row, ATTSTATS_ATTNAME)) < 0)
@@ -6304,7 +6304,7 @@ match_attrmap(PGresult *res,
}
/*
- * Import fetched statistics into the local statistics tables.
+ * Attempt to import fetched statistics into the local statistics tables.
*/
static bool
import_fetched_statistics(Relation relation,
@@ -6314,6 +6314,12 @@ import_fetched_statistics(Relation relation,
const RemoteAttributeMapping *remattrmap,
int attrcnt)
{
+ /*
+ * ATTSTATS_NUM_FIELDS corresponds to the number of NullableDatum
+ * arguments for import_attribute_statistics(), which is larger than that
+ * for import_relation_statistics(). Therefore, a NullableDatum array of
+ * that length is used to store data for each argument in both functions.
+ */
NullableDatum args[ATTSTATS_NUM_FIELDS];
/* Set the 'version' parameter, which is common to both statistics. */
[parent: 2656f664616d]