| From: | jian he <jian(dot)universality(at)gmail(dot)com> |
|---|---|
| To: | PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org> |
| Subject: | Re: refactor ExecInitPartitionInfo |
| Date: | 2026-02-21 15:07:52 |
| Message-ID: | CACJufxGcUztOYcCj85o15YT68qPY3qpwUtdndqDgOs_Sps6Cow@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
On Fri, Nov 28, 2025 at 7:00 PM jian he <jian(dot)universality(at)gmail(dot)com> wrote:
>
> hi.
>
> I noticed the following code pattern repeated several times in
> ExecInitPartitionInfo.
> ```
> if (part_attmap == NULL)
> build_attrmap_by_name(RelationGetDescr(partrel),
> RelationGetDescr(firstResultRel),
> false);
> ```
>
> we can consolidated into one, like:
>
> + if (node != NULL &&
> + (list_length(node->withCheckOptionLists) > 0 ||
> + list_length(node->returningLists) > 0 ||
> + node->onConflictAction != ONCONFLICT_NONE ||
> + node->operation == CMD_MERGE))
> + {
> + part_attmap =
> + build_attrmap_by_name(RelationGetDescr(partrel),
> + RelationGetDescr(firstResultRel),
> + false);
> + }
> +
>
> + if (node != NULL &&
> + (list_length(node->withCheckOptionLists) > 0 ||
> + list_length(node->returningLists) > 0 ||
> + node->onConflictAction != ONCONFLICT_NONE ||
> + node->operation == CMD_MERGE))
V1 is way too complicated.
IMHO, we can just do
if (node != NULL)
part_attmap = build_attrmap_by_name(RelationGetDescr(partrel),
RelationGetDescr(firstResultRel),
false);
We have now consolidated five uses of build_attrmap_by_name into one.
| Attachment | Content-Type | Size |
|---|---|---|
| v2-0001-refactor-ExecInitPartitionInfo.patch | text/x-patch | 3.3 KB |
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Laurenz Albe | 2026-02-21 15:13:59 | Re: BUG #19393: pg_upgrade fails with duplicate key violation when CHECK constraint named *_not_null exists |
| Previous Message | David G. Johnston | 2026-02-21 15:01:08 | Partial Mode in Aggregate Functions |