Re: functions + shared libraries

Поиск
Список
Период
Сортировка
От Doug McNaught
Тема Re: functions + shared libraries
Дата
Msg-id m3d6ob71gp.fsf@varsoon.wireboard.com
обсуждение исходный текст
Ответ на functions + shared libraries  (Eric B.Ridge <ebr@tcdi.com>)
Ответы Re: functions + shared libraries  ("Shridhar Daithankar" <shridhar_daithankar@persistent.co.in>)
Список pgsql-general
Eric B.Ridge <ebr@tcdi.com> writes:

> Is it possible, via a shared library that contains functions used by
> postgres, to detect when the library is first loaded and when it is
> unloaded?

You could have a 'static' variable in the library, that all its
functions check first thing, and set to 1 after checking.  That would
be a little clumsy, but would work.

As for unloading, I don't think you can detect it other than running a
function on process exit with an atexit() handler.

> Also, each postgres process loads its own copy of a library that
> contains functions.  Is it possible to make a single library instance
> shared across all postgres processes?  I suspect the answer is no b/c
> I assume the postmaster exec()'s postgres, rather than forking, but it
> doesn't hurt to ask.

Shared libraries are not shared memory.  Each process has its own copy
of the library data area; though the text (library code) is usually
shared, it's read-only.  If you want chared memory then use the SysV
or POSIX shm API.

-Doug

В списке pgsql-general по дате отправления:

Предыдущее
От: Martijn van Oosterhout
Дата:
Сообщение: Re: UPDATE syntax problem
Следующее
От: "Shridhar Daithankar"
Дата:
Сообщение: Re: functions + shared libraries