| From: | Michael Paquier <michael(at)paquier(dot)xyz> |
|---|---|
| To: | Ranier Vilela <ranier(dot)vf(at)gmail(dot)com> |
| Cc: | Pg Hackers <pgsql-hackers(at)postgresql(dot)org> |
| Subject: | Re: Refactor function pg_get_multixact_stats (src/backend/utils/adt/multixactfuncs.c) |
| Date: | 2026-07-01 03:18:23 |
| Message-ID: | akSG_6C53MTxNqNO@paquier.xyz |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
On Tue, Jun 30, 2026 at 09:23:20AM -0300, Ranier Vilela wrote:
> Move the GetMultiXactInfo() call and the resulting computations
> into the branch where the values are actually consumed, narrowing
> the scope of the related local variables to that branch. This
> matches the usual pattern for privileged stats functions, which
> skip the underlying work entirely for callers who can't see the
> result, and avoids touching shared MultiXact state when there is no
> caller around to observe it.
That's indeed wasteful, so applied as it is my business.
> While here, size the memset() that NULLs the output row off
> sizeof(nulls) rather than *sizeof(bool) * tupdesc->natts*.
> The two are equivalent today, since nulls is a fixed 4-element array
> matching the function's declared return type, but relying the
> memset() with *natts* is an unnecessary dependency.
> If a column were ever added to the function's SQL definition without a
> matching update to this array, the old code would silently write
> past the end of nulls.
But I left this one out. It's really impossible to miss.
--
Michael
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Haibo Yan | 2026-07-01 03:26:51 | Re: [PATCH v2] Avoid internal error for invalid interval typmods |
| Previous Message | Ajin Cherian | 2026-07-01 02:49:49 | Re: [PATCH] Preserve replication origin OIDs in pg_upgrade |