I am writing a C-language shared-object file which is dynamically linked with
postgres, and uses the various SPI functions for executing queries from
numerous trigger functions.
My question is thus: what is the best method for a dynamically linked object
to share memory with the same object running on other backends? Am I right in
thinking that if I allocate memory in the "upper execution context" from
SPI_palloc(), this is not shared with the other processes?
I thought of a few ways of doing this (please forgive me if these appear
idiotic, as I am fairly new to postgres):
1. Change memory context to TopMemoryContext and palloc everything there.
(However, I believe this still isn't shared between processes?)
2. Use the shmem functions in src/backend/storage/ipc/shmem.c to create a
chunk of shared memory and use this (Although I would like to avoid writing
my own memory manager to carve up the space).
3. Somehow create shared memory using the shmem functions, and set a memory
context to live *inside* this shared memory, which my trigger functions can
then switch to. Then use palloc() and pfree() without worrying..
Please let me know if this problem has been solved before, as I have searched
through the mailing lists and through the source, but am not sure which is
the best way to resolve it. Thanks for your help.
pgsql-hackers by date
|Next:||From: Martijn van Oosterhout||Date: 2006-02-05 14:11:25|
|Subject: Re: Shared memory and memory context question|
|Previous:||From: Magnus Hagander||Date: 2006-02-05 12:14:38|
|Subject: Re: Postgres 8.1.x and MIT Kerberos 5|