Re: Thinko in pgstat_build_snapshot()

Heikki Linnakangas <hlinnaka@iki.fi>

From: Heikki Linnakangas <hlinnaka@iki.fi>
To: Etsuro Fujita <etsuro.fujita@gmail.com>, PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Date: 2025-03-30T11:30:43Z
Lists: pgsql-hackers
On 30/03/2025 13:23, Etsuro Fujita wrote:
> While working on something else I noticed $SUBJECT: we are allocating
> more memory than necessary and copying more data than necessary
> because we specify the wrong PgStat_KindInfo member as the size
> argument for MemoryContextAlloc and memcpy.  This could become
> problematic if snapshotting a very large number of variables stats, so
> I fixed it.  Attached is a patch for that.

Good catch. Patch looks good to me at quick glance.

-- 
Heikki Linnakangas
Neon (https://neon.tech)



Commits

Same data as JSON: GET /api/v1/messages/:b64id/commits the thread's linked commits as JSON, with link sources. API reference →
  1. Fix memory allocation/copy mistakes.