Re: Sequence Access Method WIP

Petr Jelinek <petr@2ndquadrant.com>

From: Petr Jelinek <petr@2ndquadrant.com>
To: Andres Freund <andres@2ndquadrant.com>
Cc: Heikki Linnakangas <hlinnakangas@vmware.com>, Simon Riggs <simon@2ndQuadrant.com>, PostgreSQL-development <pgsql-hackers@postgresql.org>
Date: 2014-10-13T10:01:10Z
Lists: pgsql-hackers

Attachments

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

Commits

  1. Add missing gss option to msvc config template