Sequence Access Method WIP - Mailing list pgsql-hackers

From Simon Riggs
Subject Sequence Access Method WIP
Date
Msg-id CA+U5nMLV3ccdzbqCvcedd-HfrE4dUmoFmTBPL_uJ9YjsQbR7iQ@mail.gmail.com
Whole thread Raw
Responses Re: Sequence Access Method WIP
List pgsql-hackers
SeqAm allows you to specify a plugin that alters the behaviour for
sequence allocation and resetting, aimed specifically at clustering
systems.

New command options on end of statement allow syntax
  CREATE SEQUENCE foo_seq
      USING globalseq WITH (custom_option=setting);
which allows you to specify an alternate Sequence Access Method for a
sequence object,
or you can specify a default_sequence_mgr as a USERSET parameter
  SET default_sequence_mgr = globalseq;

Existing sequences can be modified to use a different SeqAM, by calling
  ALTER SEQUENCE foo_seq USING globalseq;

SeqAM is similar to IndexAM: There is a separate catalog table for
SeqAMs, but no specific API to create them. Initdb creates one
sequence am, called "local", which is the initial default. If
default_sequence_mgr is set to '' or 'local' then we use the local
seqam. The local seqam's functions are included in core.

Status is still "Work In Progress". Having said that most of the grunt
work is done and if we agree the shape of this is right, its
relatively easy going code.

postgres=# select oid, * from pg_seqam;
-[ RECORD 1 ]+--------------------
oid          | 3839
seqamname    | local
seqamalloc   | seqam_local_alloc
seqamsetval  | seqam_local_setval
seqamoptions | seqam_local_options

postgres=# select relname, relam from pg_class where relname = 'foo2';
 relname | relam
---------+-------
 foo2    |  3839

postgres=# create sequence foo5 using global;
ERROR:  access method "global" does not exist

Footprint
 backend/access/Makefile            |    2
 backend/access/common/reloptions.c |   26 +++
 backend/access/sequence/Makefile   |   17 ++
 backend/access/sequence/seqam.c    |  278 +++++++++++++++++++++++++++++++++++++
 backend/catalog/Makefile           |    2
 backend/commands/sequence.c        |  132 +++++++++++++++--
 backend/commands/tablecmds.c       |    3
 backend/nodes/copyfuncs.c          |    4
 backend/nodes/equalfuncs.c         |    4
 backend/parser/gram.y              |   84 ++++++++++-
 backend/parser/parse_utilcmd.c     |    4
 backend/utils/cache/catcache.c     |    6
 backend/utils/cache/syscache.c     |   23 +++
 backend/utils/misc/guc.c           |   12 +
 include/access/reloptions.h        |    6
 include/access/seqam.h             |   27 +++
 include/catalog/indexing.h         |    5
 include/catalog/pg_proc.h          |    6
 include/catalog/pg_seqam.h         |   70 +++++++++
 include/nodes/parsenodes.h         |    8 -
 include/utils/guc.h                |    1
 include/utils/rel.h                |   22 +-
 include/utils/syscache.h           |    2
 23 files changed, 706 insertions(+), 38 deletions(-)

Tasks to complete
* contrib module for example/testing
* Docs

--
 Simon Riggs                   http://www.2ndQuadrant.com/
 PostgreSQL Development, 24x7 Support, Training & Services

Attachment

pgsql-hackers by date:

Previous
From: Claudio Freire
Date:
Subject: Re: Parallel query execution
Next
From: Simon Riggs
Date:
Subject: log_lock_waits to identify transaction's relation