Re: Add pg_get_injection_points() for information of injection points

From: Ranier Vilela <ranier(dot)vf(at)gmail(dot)com>
To: Michael Paquier <michael(at)paquier(dot)xyz>
Cc: Postgres hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Add pg_get_injection_points() for information of injection points
Date: 2025-04-14 14:21:38
Message-ID: CAEudQApN3X1z1S5LtAaOS1qG3nYhDPqnarg4MQUOUORGLHh-NQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Em seg., 14 de abr. de 2025 às 09:46, Ranier Vilela <ranier(dot)vf(at)gmail(dot)com>
escreveu:

> Hi Michael.
>
> Em dom., 13 de abr. de 2025 às 21:36, Michael Paquier <michael(at)paquier(dot)xyz>
> escreveu:
>
>> Hi all,
>>
>> One thing that's been lacking in injection points is the possibility
>> to look at the state of the injection points in shared memory through
>> some SQL. This was on my tablets for some time, but I have not taken
>> the time to do the actual legwork.
>>
>> The attached patch adds a SRF that returns a set of tuples made of the
>> name, library and function for all the injection points attached to
>> the system. This implementation relies on a new function added in
>> injection_point.c, called InjectionPointList(), that retrieves a
>> palloc()'d array of the injection points, hiding from the callers the
>> internals of what this stuff does with the shmem array lookup.
>>
>> This is useful for monitoring or in tests, to make sure for example
>> that nothing is left around at the end of a script. I have a
>> different proposal planned for this area of the code, where this
>> function would be good to have, but I am sending an independent patch
>> as this stuff is useful on its own.
>>
>> The patch includes a couple of tests and some documentation.
>>
> I think that it would be more productive to use the "int idx", to store
> *num_points,
> avoiding counting inside the loop, no?
>
> Function InjectionPointList:
> + uint32 max_inuse;
> + int idx;
> + for (idx = 0; idx < max_inuse; idx++)- (*num_points)++;
> + *num_points = idx;
> + return result;
>
Nevermind, this is wrong, sorry for the noise.

best regards,
Ranier Vilela

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Maksim Milyutin 2025-04-14 14:25:53 Re: COALESCE with single argument looks like identity function
Previous Message Andres Freund 2025-04-14 14:13:27 Re: pgsql: Add function to get memory context stats for processes