Re: pg_settings.unit and DefineCustomXXXVariable

2025-01-09 Thread Luca Ferrari
On Wed, Jan 8, 2025 at 4:18 PM Tom Lane  wrote:
>
> Matthias van de Meent  writes:

> > DefineCustomXXXVariable has a 'flags' argument, into which GUC_UNIT_*
> > can be or-ed.

Thanks Matthias and Tom for the explaination.
Since I'm needing to define "seconds", GUC_UNIT_S is what I was looking for.


Luca




question about executor hooks

2025-01-14 Thread Luca Ferrari
In the file backend/executor/execMain.c there are the following hook types:

/* Hooks for plugins to get control in ExecutorStart/Run/Finish/End */
ExecutorStart_hook_type ExecutorStart_hook = NULL;
ExecutorRun_hook_type ExecutorRun_hook = NULL;
ExecutorFinish_hook_type ExecutorFinish_hook = NULL;
ExecutorEnd_hook_type ExecutorEnd_hook = NULL;


It is not clear to me what every hook, or better, event is associated
to. I suspect they are:
- start => prepare resources (e.g., allocate memory and stuff)
- run
- finish => execution terminated
- end => free resources

Am I wrong?

Moreover, installing an hook is cluster-wide, right? Is there a way to
limit an hook only for connections related to a single database
(without taking into account FDW and friends)?

Thanks,
Luca




help in allocating shared module within a module

2024-12-23 Thread Luca Ferrari
Hi all,
hope this is the right place to ask for, otherwise please point me in
the right resource.
I'm trying to develop a module that needs shared memory between
background workers.

The _PG_init calls a function to reserve the shared memory, which in
turn calls RequestAddinShmemSpace, which seems to fail. In fact, I
never got the debug line after the call to RequestAddinShmemSpaec and
_PG_init does not conitnue.

Here is my code skeleton:

void
_PG_init(void)
{

if ( ! process_shared_preload_libraries_in_progress )
return;



// set up the GUCs
_define_gucs();


// set up the shared memory
_create_shared_memory();

...
}


void
_create_shared_memory()
{
  Size estimated_size = 10136:

  elog( DEBUG2, "shared allocation %lu", estimated_size );

  RequestAddinShmemSpace( estimated_size );

  elog(DEBUG2, "never reached!" );
...
}

What am I missing here?

Thanks,
Luca




pg_settings.unit and DefineCustomXXXVariable

2025-01-08 Thread Luca Ferrari
Hi all,
I need to define a few GUCs, and for that purpose I'm using
DefineCustomXXXVariable functions that provide hooks for assignment,
show and check. However it is not clear to me if it is possible to
populate the unit column in pg_settings for the custom defined
variables, and if so, how.
Any suggestion is appreciated.

Thanks,
Luca