1
1
<!--
2
- $Header: /cvsroot/pgsql/doc/src/sgml/ref/create_sequence.sgml,v 1.14 2000/10/05 19:48:17 momjian Exp $
2
+ $Header: /cvsroot/pgsql/doc/src/sgml/ref/create_sequence.sgml,v 1.15 2000/12/08 20:06:58 tgl Exp $
3
3
Postgres documentation
4
4
-->
5
5
@@ -77,9 +77,9 @@ CREATE SEQUENCE <replaceable class="parameter">seqname</replaceable> [ INCREMENT
77
77
<term><replaceable class="parameter">maxvalue</replaceable></term>
78
78
<listitem>
79
79
<para>
80
- Use the optional clause <option>MAXVALUE
81
- <replaceable class="parameter">maxvalue</replaceable></option> to
82
- determine the maximum
80
+ The optional clause <option>MAXVALUE
81
+ <replaceable class="parameter">maxvalue</replaceable></option>
82
+ determines the maximum
83
83
value for the sequence. The defaults are 2147483647 and -1 for
84
84
ascending and descending sequences, respectively.
85
85
</para>
@@ -120,15 +120,15 @@ CREATE SEQUENCE <replaceable class="parameter">seqname</replaceable> [ INCREMENT
120
120
<listitem>
121
121
<para>
122
122
The optional CYCLE keyword may be used to enable the sequence
123
- to continue when the
123
+ to wrap around when the
124
124
<replaceable class="parameter">maxvalue</replaceable> or
125
125
<replaceable class="parameter">minvalue</replaceable> has been
126
126
reached by
127
127
an ascending or descending sequence respectively. If the limit is
128
- reached, the next number generated will be whatever the
128
+ reached, the next number generated will be the
129
129
<replaceable class="parameter">minvalue</replaceable> or
130
- <replaceable class="parameter">maxvalue</replaceable> is ,
131
- as appropriate .
130
+ <replaceable class="parameter">maxvalue</replaceable>,
131
+ respectively .
132
132
</para>
133
133
</listitem>
134
134
</varlistentry>
@@ -192,7 +192,7 @@ ERROR: DefineSequence: MINVALUE (<replaceable class="parameter">min</replaceabl
192
192
</computeroutput></term>
193
193
<listitem>
194
194
<para>
195
- If the minimum and maximum values are inconsistant .
195
+ If the minimum and maximum values are inconsistent .
196
196
</para>
197
197
</listitem>
198
198
</varlistentry>
@@ -213,24 +213,24 @@ ERROR: DefineSequence: MINVALUE (<replaceable class="parameter">min</replaceabl
213
213
into the current data base. This involves creating and initializing a
214
214
new single-row
215
215
table with the name <replaceable class="parameter">seqname</replaceable>.
216
- The generator will be " owned" by the user issuing the command.
216
+ The generator will be owned by the user issuing the command.
217
217
</para>
218
218
219
219
<para>
220
220
After a sequence is created, you may use the function
221
- <function>nextval(<replaceable class="parameter">seqname</replaceable>)</function>
221
+ <function>nextval(' <replaceable class="parameter">seqname</replaceable>' )</function>
222
222
to get a new number from the sequence.
223
223
The function
224
224
<function>currval('<replaceable class="parameter">seqname</replaceable>')</function>
225
225
may be used to determine the number returned by the last call to
226
- <function>nextval(<replaceable class="parameter">seqname</replaceable>)</function>
226
+ <function>nextval(' <replaceable class="parameter">seqname</replaceable>' )</function>
227
227
for the specified sequence in the current session.
228
228
The function
229
229
<function>setval('<replaceable class="parameter">seqname</replaceable>',
230
230
<replaceable class="parameter">newvalue</replaceable>)</function>
231
231
may be used to set the current value of the specified sequence.
232
232
The next call to
233
- <function>nextval(<replaceable class="parameter">seqname</replaceable>)</function>
233
+ <function>nextval(' <replaceable class="parameter">seqname</replaceable>' )</function>
234
234
will return the given value plus the sequence increment.
235
235
</para>
236
236
@@ -241,7 +241,7 @@ ERROR: DefineSequence: MINVALUE (<replaceable class="parameter">min</replaceabl
241
241
SELECT * FROM <replaceable>seqname</replaceable>;
242
242
</programlisting>
243
243
244
- to get the parameters of a sequence.
244
+ to examine the parameters of a sequence.
245
245
246
246
As an alternative to fetching the
247
247
parameters from the original definition as above, you can use
@@ -254,8 +254,13 @@ SELECT last_value FROM <replaceable>seqname</replaceable>;
254
254
</para>
255
255
256
256
<para>
257
- Low-level locking is used to enable multiple simultaneous
258
- calls to a generator.
257
+ To avoid blocking of concurrent transactions
258
+ that obtain numbers from the same sequence, a nextval operation
259
+ is never rolled back; that is, once a value has been fetched it is
260
+ considered used, even if the transaction that did the nextval later
261
+ aborts. This means that aborted transactions may leave unused "holes"
262
+ in the sequence of assigned values. setval operations are never
263
+ rolled back, either.
259
264
</para>
260
265
261
266
<caution>
@@ -279,6 +284,9 @@ SELECT last_value FROM <replaceable>seqname</replaceable>;
279
284
are all distinct, not that they are generated purely sequentially.
280
285
Also, last_value will reflect the latest value reserved by any backend,
281
286
whether or not it has yet been returned by nextval.
287
+ Another consideration is that a setval executed on such a sequence
288
+ will not be noticed by other backends until they have used up any
289
+ preallocated values they have cached.
282
290
</para>
283
291
</caution>
284
292
@@ -293,7 +301,7 @@ SELECT last_value FROM <replaceable>seqname</replaceable>;
293
301
Use <command>DROP SEQUENCE</command> to remove a sequence.
294
302
</para>
295
303
<para>
296
- Each backend uses its own cache to store allocated numbers.
304
+ Each backend uses its own cache to store preallocated numbers.
297
305
Numbers that are cached but not used in the current session will be
298
306
lost, resulting in "holes" in the sequence.
299
307
</para>
0 commit comments