]> granicus.if.org Git - postgresql/commit
Add CREATE SEQUENCE AS <data type> clause
authorPeter Eisentraut <peter_e@gmx.net>
Fri, 10 Feb 2017 20:12:32 +0000 (15:12 -0500)
committerPeter Eisentraut <peter_e@gmx.net>
Fri, 10 Feb 2017 20:34:35 +0000 (15:34 -0500)
commit2ea5b06c7a7056dca0af1610aadebe608fbcca08
tree368b0cb5ac34c4450238da2c6161f20852fe242f
parent9401883a7a598f1f1664c74835821f697932666f
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>
18 files changed:
doc/src/sgml/catalogs.sgml
doc/src/sgml/information_schema.sgml
doc/src/sgml/ref/alter_sequence.sgml
doc/src/sgml/ref/create_sequence.sgml
src/backend/catalog/information_schema.sql
src/backend/catalog/system_views.sql
src/backend/commands/sequence.c
src/backend/parser/gram.y
src/backend/parser/parse_utilcmd.c
src/bin/pg_dump/pg_dump.c
src/bin/pg_dump/t/002_pg_dump.pl
src/include/catalog/catversion.h
src/include/catalog/pg_proc.h
src/include/catalog/pg_sequence.h
src/test/modules/test_pg_dump/t/001_base.pl
src/test/regress/expected/rules.out
src/test/regress/expected/sequence.out
src/test/regress/sql/sequence.sql