Re: Avoid overflowed array index (src/backend/utils/activity/pgstat.c)

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: Avoid overflowed array index (src/backend/utils/activity/pgstat.c)
Date: 2024-09-05 23:21:57
Message-ID: Zto9FWhyrTe9DxuD@paquier.xyz
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Thu, Sep 05, 2024 at 09:25:11AM -0300, Ranier Vilela wrote:
> Please, disregard the first patch, it contains a bug.
> New version attached, v1.

These are wrong, because they are changing code paths where we know
that stats kinds should be set. For custom stats, particularly, this
would silently skip doing something for code paths that would expect
an action to be taken. (I thought originally about using some
elog(ERRORs) in these areas, refrained from it.)

The change in pgstat_write_statsfile() is equally unnecessary: we are
not going to write to the pgstats file an entry that we have not found
previously, as per the knowledge that these would be compiled with the
code for the builtin code, or added at startup for the custom ones.

I'd suggest to study the code a bit more. Perhaps more documentation
is required, not sure about that yet.
--
Michael

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Michael Paquier 2024-09-05 23:29:52 Re: Create syscaches for pg_extension
Previous Message Noah Misch 2024-09-05 22:04:34 Re: race condition in pg_class