Re: Use CompactAttribute more often, when possible

From: David Rowley <dgrowleyml(at)gmail(dot)com>
To: Michael Paquier <michael(at)paquier(dot)xyz>
Cc: PostgreSQL Developers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Use CompactAttribute more often, when possible
Date: 2025-10-20 08:43:25
Message-ID: CAApHDvpD6a2RthbMZ0EN6Pk5y1RS6ottV60vV_kwWmsHE3H-LQ@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Mon, 20 Oct 2025 at 21:15, Michael Paquier <michael(at)paquier(dot)xyz> wrote:
>
> On Mon, Oct 20, 2025 at 05:46:33PM +1300, David Rowley wrote:
> > I don't think the attached is very interesting to look at, but l'll
> > leave it here for a bit just in case anyone wants to look. Otherwise,
> > I plan to just treat it as a follow-up of 5983a4cff.
>
> Still I've looked at it. I like reading code.

Thanks!, and good! :)

> The change in validateDomainCheckConstraint()@typecmds.c looks
> independent to what you are suggesting here. Grouping that is fine,
> just noting that the intent is not the same.

Yeah, maybe shouldn't have included that with this patch. It felt
minor enough to include it. I should likely mention it in the commit
message. Otherwise, happy to do it separately, I just thought it was a
bit too trivial.

> @@ -5146,10 +5146,6 @@ ReorderBufferToastReplace(ReorderBuffer *rb, ReorderBufferTXN *txn,
> dlist_iter it;
> Size data_done = 0;
>
> - /* system columns aren't toasted */
> - if (attr->attnum < 0)
> - continue;
>
> Er, why this removal?

It's a good question. I only remembered to write about that after I
hit send on the email...

We don't put system attributes in TupleDescs so I put that check down
to misguided programming.

TupleDesc's header comment says:

* Note that only user attributes, not system attributes, are mentioned in
* TupleDesc.

plus there are so many places where we assume that
TupleDesc[Compact]Attr(..., attnum - 1) returns the attribute details
for attnum, so if the 0th element of the compact_attrs[] and
subsequent attrs[] array wasn't attnum==1, we'd be in big trouble.

David

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Xuneng Zhou 2025-10-20 08:46:53 Re: Optimize SnapBuildPurgeOlderTxn: use in-place compaction instead of temporary array
Previous Message Michael Paquier 2025-10-20 08:40:28 Re: [PATCH] Add Windows support for backtrace_functions (MSVC only)