From: | Vlad Arkhipov <arhipov(at)dc(dot)baikal(dot)ru> |
---|---|
To: | pgsql-hackers(at)postgresql(dot)org |
Subject: | Shared sequence-like objects in PostgreSQL |
Date: | 2011-09-21 07:19:34 |
Message-ID: | 4E799006.4030308@dc.baikal.ru |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | 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.
From | Date | Subject | |
---|---|---|---|
Next Message | Michael Paquier | 2011-09-21 07:20:06 | Re: WIP: Join push-down for foreign tables |
Previous Message | Heikki Linnakangas | 2011-09-21 07:08:42 | Re: Inlining comparators as a performance optimisation |