Update comments in functions for statistics import in postgres_fdw.c

Started by Etsuro Fujita15 days ago7 messageshackers
Jump to latest
#1Etsuro Fujita
etsuro.fujita@gmail.com

Hi,

I did s/attname/remote_attname/ to a comment in match_attrmap(), for
clarity, and added a comment to import_fetched_statistics(). I also
tweaked the comments for each of the two functions.

Best regards,
Etsuro Fujita

Attachments:

t258352_1
update-comments-in-stat-import-functions.patchapplication/octet-stream; name=update-comments-in-stat-import-functions.patchDownload+13-7
#2Chao Li
li.evan.chao@gmail.com
In reply to: Etsuro Fujita (#1)
Re: Update comments in functions for statistics import in postgres_fdw.c

On Nov 9, 2026, at 17:35, Etsuro Fujita <etsuro.fujita@gmail.com> wrote:

Hi,

I did s/attname/remote_attname/ to a comment in match_attrmap(), for
clarity, and added a comment to import_fetched_statistics(). I also
tweaked the comments for each of the two functions.

Best regards,
Etsuro Fujita
<update-comments-in-stat-import-functions.patch>

```
+	/*
+	 * ATTSTATS_NUM_FIELDS corresponds to the number of statistical value
+	 * parameters 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 parameter in both functions.
+	 */
 	NullableDatum args[ATTSTATS_NUM_FIELDS];
```

I think this comment is slightly inaccurate. ATTSTATS_NUM_FIELDS is 14, including ATTSTATS_ATTNAME as 0. So the number of statistical value parameters is 13. import_attribute_statistics() needs 14 NullableDatatum including a “version” argument plus 13 statistical value parameters.

How about:
```
ATTSTATS_NUM_FIELDS equals the number of NullableDatum arguments
required by import_relation_statistics(). Use the same array for import_relation_statistics(),
which requires fewer arguments.
```

Best regards,
--
Chao Li (Evan)
HighGo Software Co., Ltd.
https://www.highgo.com/

#3Etsuro Fujita
etsuro.fujita@gmail.com
In reply to: Chao Li (#2)
Re: Update comments in functions for statistics import in postgres_fdw.c

On Tue, Nov 10, 2026 at 3:23 PM Chao Li <li.evan.chao@gmail.com> wrote:

```
+       /*
+        * ATTSTATS_NUM_FIELDS corresponds to the number of statistical value
+        * parameters 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 parameter in both functions.
+        */
NullableDatum args[ATTSTATS_NUM_FIELDS];
```

I think this comment is slightly inaccurate. ATTSTATS_NUM_FIELDS is 14, including ATTSTATS_ATTNAME as 0. So the number of statistical value parameters is 13. import_attribute_statistics() needs 14 NullableDatatum including a “version” argument plus 13 statistical value parameters.

As I understand it, you are saying we need to separate the version
parameter from statistical value parameters, but the comment for
import_attribute_statistics says:

* Import attribute statistics from NullableDatum inputs for all statistical
* values.
*
* For now, the 'version' argument is ignored. In the future it can be used
* to interpret older statistics properly.

So IMU I think we are using the term "statistical value parameters" to
include the version parameter. With that in mind, what I proposed is
not that bad...

Thanks for reviewing!

Best regards,
Etsuro Fujita

#4Etsuro Fujita
etsuro.fujita@gmail.com
In reply to: Etsuro Fujita (#3)
Re: Update comments in functions for statistics import in postgres_fdw.c

On Tue, Nov 10, 2026 at 6:50 PM Etsuro Fujita <etsuro.fujita@gmail.com> wrote:

As I understand it, you are saying we need to separate the version
parameter from statistical value parameters, but the comment for
import_attribute_statistics says:

* Import attribute statistics from NullableDatum inputs for all statistical
* values.
*
* For now, the 'version' argument is ignored. In the future it can be used
* to interpret older statistics properly.

So IMU I think we are using the term "statistical value parameters" to
include the version parameter. With that in mind, what I proposed is
not that bad...

I mean the term "statistical values" includes a version value. Sorry.

Best regards,
Etsuro Fujita

#5Chao Li
li.evan.chao@gmail.com
In reply to: Etsuro Fujita (#4)
Re: Update comments in functions for statistics import in postgres_fdw.c

On Nov 10, 2026, at 18:04, Etsuro Fujita <etsuro.fujita@gmail.com> wrote:

On Tue, Nov 10, 2026 at 6:50 PM Etsuro Fujita <etsuro.fujita@gmail.com> wrote:

As I understand it, you are saying we need to separate the version
parameter from statistical value parameters, but the comment for
import_attribute_statistics says:

* Import attribute statistics from NullableDatum inputs for all statistical
* values.
*
* For now, the 'version' argument is ignored. In the future it can be used
* to interpret older statistics properly.

So IMU I think we are using the term "statistical value parameters" to
include the version parameter. With that in mind, what I proposed is
not that bad...

I mean the term "statistical values" includes a version value. Sorry.

Best regards,
Etsuro Fujita

I was considering the version parameter as metadata for the statistical values, which could be used to distinguish between different sets of statistical values. But I see your point now. Treating the version parameter as a statistical value parameter also makes sense to me. No objection from my side.

Best regards,
--
Chao Li (Evan)
HighGo Software Co., Ltd.
https://www.highgo.com/

#6Etsuro Fujita
etsuro.fujita@gmail.com
In reply to: Chao Li (#5)
Re: Update comments in functions for statistics import in postgres_fdw.c

On Wed, Nov 11, 2026 at 9:39 AM Chao Li <li.evan.chao@gmail.com> wrote:

On Nov 10, 2026, at 18:04, Etsuro Fujita <etsuro.fujita@gmail.com> wrote:
On Tue, Nov 10, 2026 at 6:50 PM Etsuro Fujita <etsuro.fujita@gmail.com> wrote:

As I understand it, you are saying we need to separate the version
parameter from statistical value parameters, but the comment for
import_attribute_statistics says:

* Import attribute statistics from NullableDatum inputs for all statistical
* values.
*
* For now, the 'version' argument is ignored. In the future it can be used
* to interpret older statistics properly.

I mean the term "statistical values" includes a version value. Sorry.

I was considering the version parameter as metadata for the statistical values, which could be used to distinguish between different sets of statistical values. But I see your point now. Treating the version parameter as a statistical value parameter also makes sense to me. No objection from my side.

On reflection I changed my mind. As pointed out by you, what I
proposed isn't very clear. So I modified the patch based on your idea
(ie, s/statistical value parameters/NullableDatum arguments/), then
pushed/back-patched it.

Thanks again!

Best regards,
Etsuro Fujita

#7Chao Li
li.evan.chao@gmail.com
In reply to: Etsuro Fujita (#6)
Re: Update comments in functions for statistics import in postgres_fdw.c

On Nov 12, 2026, at 10:29, Etsuro Fujita <etsuro.fujita@gmail.com> wrote:

On Wed, Nov 11, 2026 at 9:39 AM Chao Li <li.evan.chao@gmail.com> wrote:

On Nov 10, 2026, at 18:04, Etsuro Fujita <etsuro.fujita@gmail.com> wrote:
On Tue, Nov 10, 2026 at 6:50 PM Etsuro Fujita <etsuro.fujita@gmail.com> wrote:

As I understand it, you are saying we need to separate the version
parameter from statistical value parameters, but the comment for
import_attribute_statistics says:

* Import attribute statistics from NullableDatum inputs for all statistical
* values.
*
* For now, the 'version' argument is ignored. In the future it can be used
* to interpret older statistics properly.

I mean the term "statistical values" includes a version value. Sorry.

I was considering the version parameter as metadata for the statistical values, which could be used to distinguish between different sets of statistical values. But I see your point now. Treating the version parameter as a statistical value parameter also makes sense to me. No objection from my side.

On reflection I changed my mind. As pointed out by you, what I
proposed isn't very clear. So I modified the patch based on your idea
(ie, s/statistical value parameters/NullableDatum arguments/), then
pushed/back-patched it.

Thanks again!

Best regards,
Etsuro Fujita

Cool!

Best regards,
--
Chao Li (Evan)
HighGo Software Co., Ltd.
https://www.highgo.com/