Re: Session variables and C functions - Mailing list pgsql-general

From Ivan Voras
Subject Re: Session variables and C functions
Date
Msg-id CAF-QHFUEWeZnJ9kHsqpCxHzNeNAy9eR=u18tcSe+U72k-kx2SA@mail.gmail.com
Whole thread Raw
In response to Re: Session variables and C functions  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: Session variables and C functions  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-general
On 17 November 2011 19:02, Tom Lane <tgl@sss.pgh.pa.us> wrote:
> Ivan Voras <ivoras@freebsd.org> writes:
>> Ideally, the C module would create its own "custom variable class,"
>> named e.g. "module", then define some setting, e.g. "module.setting".
>> The users would then execute an SQL command such as "SET SESSION
>> module.setting='something'", and the module would need to pick this up
>> in the C function.
>
> Plenty of examples of that in contrib/ ...

Ok, I found DefineCustom*() and _PG_init() but there's a small
problem: the functions I'm writing are for a user defined typed and
apparently _PG_init() is not called until some operation with the type
is done (e.g. anything with the input/output functions).

This means that DefineCustom*() is not called and PG doesn't know
about the variable until it's too late - I need the session variable
to be settable by the user before input/output - relying on the
"default value" is not enough.

Is there any way to make _PG_init() called earlier, e.g. as soon as
the session is established or at database connection time, something
like that?

pgsql-general by date:

Previous
From: Raymond O'Donnell
Date:
Subject: Re: Authentication configuration for local connections on Windows
Next
From: Tom Lane
Date:
Subject: Re: Session variables and C functions