pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Peter Eisentraut <peter_e@gmx.net>
To: pgsql-committers@postgresql.org
Subject: pgsql: Add CREATE SEQUENCE AS <data type> clause
Date: Fri, 10 Feb 2017 20:38:57 +0000
Message-ID: <E1ccHy5-0005KU-3R@gemulon.postgresql.org> (raw)
List-Unsubscribe:  <mailto:majordomo@postgresql.org?body=unsub%20pgsql-committers>

Add CREATE SEQUENCE AS <data type> clause

This stores a data type, required to be an integer type, with the
sequence.  The sequences min and max values default to the range
supported by the type, and they cannot be set to values exceeding that
range.  The internal implementation of the sequence is not affected.

Change the serial types to create sequences of the appropriate type.
This makes sure that the min and max values of the sequence for a serial
column match the range of values supported by the table column.  So the
sequence can no longer overflow the table column.

This also makes monitoring for sequence exhaustion/wraparound easier,
which currently requires various contortions to cross-reference the
sequences with the table columns they are used with.

This commit also effectively reverts the pg_sequence column reordering
in f3b421da5f4addc95812b9db05a24972b8fd9739, because the new seqtypid
column allows us to fill the hole in the struct and create a more
natural overall column ordering.

Reviewed-by: Steve Singer <steve@ssinger.info>
Reviewed-by: Michael Paquier <michael.paquier@gmail.com>

Branch
------
master

Details
-------
http://git.postgresql.org/pg/commitdiff/2ea5b06c7a7056dca0af1610aadebe608fbcca08

Modified Files
--------------
doc/src/sgml/catalogs.sgml                  |  20 +++++-
doc/src/sgml/information_schema.sgml        |   4 +-
doc/src/sgml/ref/alter_sequence.sgml        |  30 ++++++--
doc/src/sgml/ref/create_sequence.sgml       |  36 ++++++----
src/backend/catalog/information_schema.sql  |   4 +-
src/backend/catalog/system_views.sql        |   1 +
src/backend/commands/sequence.c             |  89 +++++++++++++++++++++---
src/backend/parser/gram.y                   |   6 +-
src/backend/parser/parse_utilcmd.c          |   2 +-
src/bin/pg_dump/pg_dump.c                   | 103 +++++++++++++++-------------
src/bin/pg_dump/t/002_pg_dump.pl            |   2 +
src/include/catalog/catversion.h            |   2 +-
src/include/catalog/pg_proc.h               |   2 +-
src/include/catalog/pg_sequence.h           |   8 ++-
src/test/modules/test_pg_dump/t/001_base.pl |   1 +
src/test/regress/expected/rules.out         |   1 +
src/test/regress/expected/sequence.out      |  49 +++++++++----
src/test/regress/sql/sequence.sql           |  13 ++++
18 files changed, 274 insertions(+), 99 deletions(-)


-- 
Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-committers


Message-ID: <E1ccHy5-0005KU-3R@gemulon.postgresql.org>
Permalink:  ../E1ccHy5-0005KU-3R@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1ccHy5-0005KU-3R@gemulon.postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-committers@postgresql.org
  Cc: peter_e@gmx.net
  Subject: Re: pgsql: Add CREATE SEQUENCE AS <data type> clause
  In-Reply-To: <E1ccHy5-0005KU-3R@gemulon.postgresql.org>
  References: <E1ccHy5-0005KU-3R@gemulon.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox