Shared sequence-like objects in PostgreSQL

Поиск
Список
Период
Сортировка
От Vlad Arkhipov
Тема Shared sequence-like objects in PostgreSQL
Дата
Msg-id 4E799006.4030308@dc.baikal.ru
обсуждение исходный текст
Ответы Re: Shared sequence-like objects in PostgreSQL
Список pgsql-hackers
Hello all,

I'm writing a C-language function that is similar to nextval() but 
should return the next member of the recurrent sequence:
T(n+1) = f(T(n), T(n-1), ..., T(n-k)), where f is some function and k is 
a constant.
The state of this object should be persistent between database restarts 
and should be easily recovered if the database crashes.

So the first problem I encountered was where to store the current state 
of this object (n and values T(n), T(n-1), ... T(n-k)). I believe that 
TopMemoryContext is not shared between processes, therefore I must use 
shmem functions from backend/storage/ipc/shmem.c to create a structure 
in shared memory.

The next issue is how to synchronize backends' reads/writes to this 
chunk of shared memory. I suppose there must be something to handle with 
semaphores in the Postgres code.

Then I periodically need to persist the state of this object to the 
database, for example for every 100 generated values, as well as on the 
postmaster's shutdown. What is the best method for doing that?

Please let me know if this problem has been solved before. Thanks for 
you help.


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

Предыдущее
От: Peter Geoghegan
Дата:
Сообщение: Re: Inlining comparators as a performance optimisation
Следующее
От: Magnus Hagander
Дата:
Сообщение: Re: Online base backup from the hot-standby