what about _PG_fini

Started by Cédric Villemainover 16 years ago3 messageshackers
Jump to latest
#1Cédric Villemain
cedric.villemain.debian@gmail.com

Hello dear hackers,

I wonder what is the future of "_PG_fini", documentation say at [1]http://www.postgresql.org/docs/8.4/static/xfunc-c.html#XFUNC-C-DYNLOAD:
"Note that _PG_fini will only be called during an unload of the file,
not during process termination. (Presently, unloads are disabled and
will never occur, but this may change in the future.)"

Since 8.2 it is the same and no entry in the TODO list for that, also
I didn't find mails about that in the pgsql-hackers ML archive.

So:
1. do we want a _PG_fini which is call on server stop ?
2. what's actually the best way to execute some code when server stop,
if one have ideas ... ?

Regards,
Cédric Villemain

[1]: http://www.postgresql.org/docs/8.4/static/xfunc-c.html#XFUNC-C-DYNLOAD

#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: Cédric Villemain (#1)
Re: what about _PG_fini

=?ISO-8859-1?Q?C=E9dric_Villemain?= <cedric.villemain.debian@gmail.com> writes:

I wonder what is the future of "_PG_fini", documentation say at [1]:
"Note that _PG_fini will only be called during an unload of the file,
not during process termination. (Presently, unloads are disabled and
will never occur, but this may change in the future.)"

What we'd need to work out before (re)enabling _PG_fini is some
consistent rules for allowing multiple modules to get into *and out of*
the same hook pointers. The current coding methods are very
load-order-dependent, and that would have to be fixed somehow.

1. do we want a _PG_fini which is call on server stop ?
2. what's actually the best way to execute some code when server stop,
if one have ideas ... ?

In any case, _PG_fini would have approximately nothing to do with "code
to be executed on server stop". It would happen at session end,
typically.

Personally I'd suggest putting whatever you have in mind into your
service start/stop scripts.

regards, tom lane

#3Cédric Villemain
cedric.villemain.debian@gmail.com
In reply to: Tom Lane (#2)
Re: what about _PG_fini

2009/12/23 Tom Lane <tgl@sss.pgh.pa.us>:

=?ISO-8859-1?Q?C=E9dric_Villemain?= <cedric.villemain.debian@gmail.com> writes:

I wonder what is the future of "_PG_fini", documentation say at [1]:
"Note that _PG_fini will only be called during an unload of the file,
not during process termination. (Presently, unloads are disabled and
will never occur, but this may change in the future.)"

What we'd need to work out before (re)enabling _PG_fini is some
consistent rules for allowing multiple modules to get into *and out of*
the same hook pointers.  The current coding methods are very
load-order-dependent, and that would have to be fixed somehow.

Ok, thank you for clarification.

1. do we want a _PG_fini which is call on server stop ?
2. what's actually the best way to execute some code when server stop,
if one have ideas ... ?

In any case, _PG_fini would have approximately nothing to do with "code
to be executed on server stop".  It would happen at session end,
typically.

Personally I'd suggest putting whatever you have in mind into your
service start/stop scripts.

Yes, I thought it was probably the simplest way to do it.

for information I have some functions to make a snapshot of the blocks
which are in buffer cache (it is a max of 32KB per segment) and to
reload them when server start. Option to execute them without
'external' code could have been fine.

Show quoted text

                       regards, tom lane