Re: Sequence Access Method WIP
От | Petr Jelinek |
---|---|
Тема | Re: Sequence Access Method WIP |
Дата | |
Msg-id | 543BA2E6.3070308@2ndquadrant.com обсуждение исходный текст |
Ответ на | Re: Sequence Access Method WIP (Andres Freund <andres@2ndquadrant.com>) |
Ответы |
Re: Sequence Access Method WIP
|
Список | pgsql-hackers |
Hi, I rewrote the patch with different API along the lines of what was discussed. The API now consists of following functions: sequence_alloc - allocating range of new values The function receives the sequence relation, current value, number of requested values amdata and relevant sequence options like min/max and returns new amdata, new current value, number of values allocated and also if it needs wal write (that should be returned if amdata has changed plus other reasons the AM might have to force the wal update). sequence_setval - notification that setval is happening This function gets sequence relation, previous value and new value plus the amdata and returns amdata (I can imagine some complex sequence AMs will want to throw error that setval can't be done on them). sequence_request_update/sequence_update - used for background processing Basically AM can call the sequence_request_update and backend will then call the sequence_update method of an AM with current amdata and will write the updated amdata to disk sequence_seqparams - function to process/validate the standard sequence options like start position, min/max, increment by etc by the AM, it's called in addition to the standard processing sequence_reloptions - this is the only thing that remained unchanged from previous patch, it's meant to pass custom options to the AM Only the alloc and reloptions methods are required (and implemented by the local AM). The caching, xlog writing, updating the page, etc is handled by backend, the AM does not see the tuple at all. I decided to not pass even the struct around and just pass the relevant options because I think if we want to abstract the storage properly then the AM should not care about how the pg_sequence looks like at all, even if it means that the sequence_alloc parameter list is bit long. For the amdata handling (which is the AM's private data variable) the API assumes that (Datum) 0 is NULL, this seems to work well for reloptions so should work here also and it simplifies things a little compared to passing pointers to pointers around and making sure everything is allocated, etc. Sadly the fact that amdata is not fixed size and can be NULL made the page updates of the sequence relation quite more complex that it used to be. There are probably some optimizations possible there but I think the patch is good enough for the review now, so I am adding it to October commitfest. -- Petr Jelinek http://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Training & Services
Вложения
В списке pgsql-hackers по дате отправления: