Thread: SPI shared memory ?
Guys, Is there any exposed PG-specific API to utilize shared memory while working with SPI ? Thanks! Best regards, Alex Vinogradovs
On Fri, 2007-09-21 at 12:50 -0700, Alex Vinogradovs wrote: > Guys, > > > Is there any exposed PG-specific API to utilize shared memory while > working with SPI ? Thanks! > What are you trying to do? The available SPI functions don't include any shared memory access, do you actually want access to postgresql's shared structures, or do you just want your own area? Regards, Jeff Davis
Yes, I'd like to get some memory of my own, so that it can be shared between functions executing in different connections. Is there an existent API, or should I just straight use Unix IPC ? Thanks! Alex. On Fri, 2007-09-21 at 16:33 -0700, Jeff Davis wrote: > On Fri, 2007-09-21 at 12:50 -0700, Alex Vinogradovs wrote: > > Guys, > > > > > > Is there any exposed PG-specific API to utilize shared memory while > > working with SPI ? Thanks! > > > > What are you trying to do? > > The available SPI functions don't include any shared memory access, do > you actually want access to postgresql's shared structures, or do you > just want your own area? > > Regards, > Jeff Davis >
Alex Vinogradovs <AVinogradovs@Clearpathnet.com> writes: > Yes, I'd like to get some memory of my own, so that it can > be shared between functions executing in different connections. > Is there an existent API, or should I just straight use Unix IPC ? As of (I think) 8.2, there's RequestAddinShmemSpace and RequestAddinLWLocks. However, the fly in the ointment is that you can only usefully call these from a loadable module that is preloaded at postmaster start; otherwise it is too late to affect the sizing of shared memory. There's enough slop in the shared memory allocation that you can probably grab a few dozen or hundred bytes without a pre-allocation. One possibility is to do that and use it to store a reference to a separate shared memory segment. regards, tom lane