From: Robert Haas Date: Mon, 6 Aug 2012 19:18:00 +0000 (-0400) Subject: Warn more vigorously about the non-transactional behavior of sequences. X-Git-Tag: REL9_1_5~11 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=16a69120eb4d2728bc7b988aee9fedf86d15be53;p=postgresql Warn more vigorously about the non-transactional behavior of sequences. Craig Ringer, edited fairly heavily by me --- diff --git a/doc/src/sgml/datatype.sgml b/doc/src/sgml/datatype.sgml index 9dfecbbbc3..b62ee05a4c 100644 --- a/doc/src/sgml/datatype.sgml +++ b/doc/src/sgml/datatype.sgml @@ -802,6 +802,20 @@ ALTER SEQUENCE tablename_ + + + Because smallserial, serial and + bigserial are implemented usings sequences, there may + be "holes" or gaps in the sequence of values which appears in the + column, even if no rows are ever deleted. This is a value allocated + from the sequence is still "used up" even if a row containing that + value is never successfully inserted into the table column. This + may happen, for example, if the inserting transaction rolls back. + See nextval() in + for details. + + + Prior to PostgreSQL 7.3, serial diff --git a/doc/src/sgml/func.sgml b/doc/src/sgml/func.sgml index 4eb91311e6..fcad177b7d 100644 --- a/doc/src/sgml/func.sgml +++ b/doc/src/sgml/func.sgml @@ -9741,6 +9741,27 @@ nextval('foo'::text) foo is looked up at execute nextval concurrently, each will safely receive a distinct sequence value. + + + If a sequence object has been created with default parameters, + successive nextval calls will return successive + values beginning with 1. Other behaviors can be obtained by using + special parameters in the command; + see its command reference page for more information. + + + + + To avoid blocking concurrent transactions that obtain numbers from the + same sequence, a nextval operation is never + rolled back; that is, once a value has been fetched it is considered + used, even if the transaction that did the + nextval later aborts. This means that aborted + transactions might leave unused holes in the sequence + of assigned values. + + + @@ -9804,31 +9825,18 @@ SELECT setval('foo', 42, false); Next nextval wi The result returned by setval is just the value of its second argument. + + + Because sequences are non-transactional, changes made by + setval are not undone if the transaction rolls + back. + + - - If a sequence object has been created with default parameters, - successive nextval calls will return successive values - beginning with 1. Other behaviors can be obtained by using - special parameters in the command; - see its command reference page for more information. - - - - - To avoid blocking concurrent transactions that obtain numbers from the - same sequence, a nextval operation is never rolled back; - that is, once a value has been fetched it is considered used, even if the - transaction that did the nextval later aborts. This means - that aborted transactions might leave unused holes in the - sequence of assigned values. setval operations are never - rolled back, either. - - -