Re: functions + shared libraries

From: Doug McNaught <doug(at)mcnaught(dot)org>
To: Eric B(dot)Ridge <ebr(at)tcdi(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: functions + shared libraries
Date: 2002-12-09 13:42:46
Message-ID: m3d6ob71gp.fsf@varsoon.wireboard.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Eric B.Ridge <ebr(at)tcdi(dot)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

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Shridhar Daithankar 2002-12-09 13:55:56 Re: functions + shared libraries
Previous Message Martijn van Oosterhout 2002-12-09 10:51:34 Re: UPDATE syntax problem