Re: [HACKERS] livetime of a variable defined in a c-procedure (fwd) - Mailing list pgsql-hackers

From Tom Lane
Subject Re: [HACKERS] livetime of a variable defined in a c-procedure (fwd)
Date
Msg-id 3827.928607583@sss.pgh.pa.us
Whole thread Raw
In response to livetime of a variable defined in a c-procedure (fwd)  ("Victoria W." <wicki@terror.de>)
List pgsql-hackers
"Victoria W." <wicki@terror.de> writes:
> CREATE FUNCTION add_rechnr(int4) RETURNS int4
>               AS '/usr/local/pgsql/lib/modules/funcs.so' LANGUAGE 'c';

> whenever I add a value to rechnr, the correct result is returned. but if I
> copy a new file "funcs.so" into the direcotry while the backend is
> running and a connection is established, I'll get this error:

> pqReadData() -- backend closed the channel unexpectedly.

Overwriting a shared library that's in active use is a no-no on many
flavors of Unix.  (The one I use won't even let you do it --- you get
a "text file busy" error if you try to delete or modify an open SL.)

I don't think there is an "unload shared library" function in Postgres
(it'd be hard or impossible to implement on some Unixes, anyway).  So
the only way to stop referencing a shared library once it's been opened
is to terminate the backend process.

In short, if you've designed a solution that requires you to constantly
modify the shared library, you'd better look for another solution ---
or accept a lot of backend restarts.
        regards, tom lane


pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: [HACKERS] Priorities for 6.6
Next
From: The Hermit Hacker
Date:
Subject: Re: [PATCHES] Re: contrib code for 6.5