Skip site navigation (1) Skip section navigation (2)

Sequence Access Method WIP

From: Simon Riggs <simon(at)2ndQuadrant(dot)com>
To: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Sequence Access Method WIP
Date: 2013-01-16 02:40:32
Message-ID: CA+U5nMLV3ccdzbqCvcedd-HfrE4dUmoFmTBPL_uJ9YjsQbR7iQ@mail.gmail.com (view raw or flat)
Thread:
Lists: 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: seqam.v5.patch
Description: application/octet-stream (40.6 KB)

Responses

pgsql-hackers by date

Next:From: Simon RiggsDate: 2013-01-16 02:42:58
Subject: log_lock_waits to identify transaction's relation
Previous:From: Claudio FreireDate: 2013-01-16 02:36:55
Subject: Re: Parallel query execution

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group