Major man page update from Tom Lane. c
This commit is contained in:
parent
f99dcd6d15
commit
3600fd320f
@ -7,7 +7,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/nodes/outfuncs.c,v 1.38 1998/07/13 21:27:58 momjian Exp $
|
* $Header: /cvsroot/pgsql/src/backend/nodes/outfuncs.c,v 1.39 1998/07/14 01:45:24 momjian Exp $
|
||||||
*
|
*
|
||||||
* NOTES
|
* NOTES
|
||||||
* Every (plan) node in POSTGRES has an associated "out" routine which
|
* Every (plan) node in POSTGRES has an associated "out" routine which
|
||||||
@ -660,10 +660,7 @@ _outResdom(StringInfo str, Resdom *node)
|
|||||||
sprintf(buf, " :restypmod %d ", node->restypmod);
|
sprintf(buf, " :restypmod %d ", node->restypmod);
|
||||||
appendStringInfo(str, buf);
|
appendStringInfo(str, buf);
|
||||||
appendStringInfo(str, " :resname ");
|
appendStringInfo(str, " :resname ");
|
||||||
if (*node->resname)
|
|
||||||
sprintf(buf,"\"%s\"", node->resname); /* fix for SELECT col AS "my name" */
|
sprintf(buf,"\"%s\"", node->resname); /* fix for SELECT col AS "my name" */
|
||||||
else
|
|
||||||
buf[0] = '\0';
|
|
||||||
appendStringInfo(str, buf);
|
appendStringInfo(str, buf);
|
||||||
sprintf(buf, " :reskey %d ", node->reskey);
|
sprintf(buf, " :reskey %d ", node->reskey);
|
||||||
appendStringInfo(str, buf);
|
appendStringInfo(str, buf);
|
||||||
@ -1506,7 +1503,6 @@ _outDatum(StringInfo str, Datum value, Oid type)
|
|||||||
appendStringInfo(str, buf);
|
appendStringInfo(str, buf);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/nodes/readfuncs.c,v 1.30 1998/06/15 19:28:33 momjian Exp $
|
* $Header: /cvsroot/pgsql/src/backend/nodes/readfuncs.c,v 1.31 1998/07/14 01:45:24 momjian Exp $
|
||||||
*
|
*
|
||||||
* NOTES
|
* NOTES
|
||||||
* Most of the read functions for plan nodes are tested. (In fact, they
|
* Most of the read functions for plan nodes are tested. (In fact, they
|
||||||
@ -716,7 +716,7 @@ _readResdom()
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
local_node->resname = (char *) palloc(length + 1);
|
local_node->resname = (char *) palloc(length + 1);
|
||||||
StrNCpy(local_node->resname, token, length + 1);
|
StrNCpy(local_node->resname, token+1, length + 1 - 2);/* strip quotes */
|
||||||
}
|
}
|
||||||
|
|
||||||
token = lsptok(NULL, &length); /* eat :reskey */
|
token = lsptok(NULL, &length); /* eat :reskey */
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
.\" This is -*-nroff-*-
|
.\" This is -*-nroff-*-
|
||||||
.\" XXX standard disclaimer belongs here....
|
.\" XXX standard disclaimer belongs here....
|
||||||
.\" $Header: /cvsroot/pgsql/src/man/Attic/create_sequence.l,v 1.4 1998/06/23 17:52:32 momjian Exp $
|
.\" $Header: /cvsroot/pgsql/src/man/Attic/create_sequence.l,v 1.5 1998/07/14 01:45:25 momjian Exp $
|
||||||
.TH "CREATE SEQUENCE" SQL 04/01/97 PostgreSQL PostgreSQL
|
.TH "CREATE SEQUENCE" SQL 07/13/98 PostgreSQL PostgreSQL
|
||||||
.SH NAME
|
.SH NAME
|
||||||
create sequence - create a new sequence number generator
|
create sequence - create a new sequence number generator
|
||||||
.SH SYNOPSIS
|
.SH SYNOPSIS
|
||||||
@ -17,7 +17,7 @@ create sequence - create a new sequence number generator
|
|||||||
.SH DESCRIPTION
|
.SH DESCRIPTION
|
||||||
.BR "Create sequence"
|
.BR "Create sequence"
|
||||||
will enter a new sequence number generator into the current data base.
|
will enter a new sequence number generator into the current data base.
|
||||||
Actually, new single block
|
Actually, a new single-record
|
||||||
.BR table
|
.BR table
|
||||||
with name
|
with name
|
||||||
.IR seqname
|
.IR seqname
|
||||||
@ -26,23 +26,23 @@ The generator will be
|
|||||||
\*(lqowned\*(rq by the user issuing the command.
|
\*(lqowned\*(rq by the user issuing the command.
|
||||||
.PP
|
.PP
|
||||||
The
|
The
|
||||||
.BR "increment"
|
.BR increment
|
||||||
is optional clause. Positive value will make ascending sequence,
|
clause is optional. A positive value will make an ascending sequence,
|
||||||
negative - descending. Default value is 1.
|
negative - descending. Default value is 1.
|
||||||
.PP
|
.PP
|
||||||
The optional integer
|
The optional integer
|
||||||
.BR minvalue
|
.BR minvalue
|
||||||
determines the minimum value a sequence can be. Defaults are
|
determines the minimum value the sequence can generate. Defaults are
|
||||||
1/-2147483647 for ascending/descending sequences.
|
1/-2147483647 for ascending/descending sequences.
|
||||||
.PP
|
.PP
|
||||||
Use optional integer
|
The optional integer
|
||||||
.BR maxvalue
|
.BR maxvalue
|
||||||
to determine the maximum value for sequence. Defaults are
|
determines the maximum value the sequence can generate. Defaults are
|
||||||
2147483647/-1 for ascending/descending sequences.
|
2147483647/-1 for ascending/descending sequences.
|
||||||
.PP
|
.PP
|
||||||
The optinal
|
The optional
|
||||||
.BR "start"
|
.BR start
|
||||||
value enables sequence to begin anywhere. Default is
|
value sets the first value to be generated. Default is
|
||||||
.BR minvalue
|
.BR minvalue
|
||||||
for ascending sequences and
|
for ascending sequences and
|
||||||
.BR maxvalue
|
.BR maxvalue
|
||||||
@ -52,14 +52,12 @@ The
|
|||||||
.BR cache
|
.BR cache
|
||||||
option enables sequence numbers to be preallocated and
|
option enables sequence numbers to be preallocated and
|
||||||
stored in memory for faster access. The minimum value is 1
|
stored in memory for faster access. The minimum value is 1
|
||||||
(i.e. - no cache) and it is default.
|
(one value will be allocated at a time, i.e., no cache)
|
||||||
.BR NOTE:
|
and that is the default. See below for details.
|
||||||
each backend uses own cache to store allocated numbers.
|
|
||||||
Cached but not used in current session numbers will be lost.
|
|
||||||
.PP
|
.PP
|
||||||
The optional
|
The optional
|
||||||
.BR cycle
|
.BR cycle
|
||||||
keyword may be used to enable sequence to continue when the
|
keyword may be used to enable the sequence to continue after the
|
||||||
.BR maxvalue/minvalue
|
.BR maxvalue/minvalue
|
||||||
has been reached by ascending/descending sequence.
|
has been reached by ascending/descending sequence.
|
||||||
If the limit is reached, the next number generated will be
|
If the limit is reached, the next number generated will be
|
||||||
@ -67,27 +65,56 @@ whatever the
|
|||||||
.BR minvalue/maxvalue
|
.BR minvalue/maxvalue
|
||||||
is.
|
is.
|
||||||
.PP
|
.PP
|
||||||
After sequence created, You may use function
|
After a sequence object has been created, you may use the function
|
||||||
.BR nextval
|
.BR nextval
|
||||||
with sequence name as argument to get new number from sequence
|
with the sequence name as argument to generate a new number from the
|
||||||
specified.
|
specified sequence.
|
||||||
Function
|
.PP
|
||||||
|
The function
|
||||||
.BR currval
|
.BR currval
|
||||||
('sequence_name')
|
('sequence_name')
|
||||||
may be used to determine number returned by last call to
|
may be used to re-fetch the number returned by the last call to
|
||||||
.BR nextval
|
.BR nextval
|
||||||
for specified sequence in current session.
|
for the specified sequence in the current session.
|
||||||
|
.BR NOTE:
|
||||||
|
currval will return an error if nextval has never been called for the
|
||||||
|
given sequence in the current backend session. Also beware that it
|
||||||
|
does not give the last number ever allocated, only the last one allocated
|
||||||
|
by this backend.
|
||||||
.PP
|
.PP
|
||||||
|
Use a query like
|
||||||
.nf
|
.nf
|
||||||
Use query like
|
SELECT * FROM <sequence_name>;
|
||||||
|
|
||||||
select * from <sequence_name>;
|
|
||||||
|
|
||||||
to get parameters of a sequence.
|
|
||||||
.fi
|
.fi
|
||||||
|
to get the parameters of a sequence. Aside from fetching the original
|
||||||
|
parameters, you can use
|
||||||
|
.nf
|
||||||
|
SELECT last_value FROM <sequence_name>;
|
||||||
|
.fi
|
||||||
|
to obtain the last value allocated by any backend.
|
||||||
.PP
|
.PP
|
||||||
Low-level locking is used to enable multiple simultaneous calls
|
Low-level locking is used to ensure that multiple backends can safely use
|
||||||
to a generator.
|
a sequence object concurrently.
|
||||||
|
.PP
|
||||||
|
.BR NOTE:
|
||||||
|
Unexpected results may be obtained if a cache setting greater than one
|
||||||
|
is used for a sequence object that will be used concurrently by multiple
|
||||||
|
backends. Each backend will allocate "cache" successive sequence values
|
||||||
|
during one access to the sequence object and increase the sequence
|
||||||
|
object's last_value accordingly. Then, the next cache-1 uses of nextval
|
||||||
|
within that backend simply return the preallocated values without touching
|
||||||
|
the shared object. So, numbers allocated but not used in the current session
|
||||||
|
will be lost. Furthermore, although multiple backends are guaranteed to
|
||||||
|
allocate distinct sequence values, the values may be generated out of
|
||||||
|
sequence when all the backends are considered. (For example, with a cache
|
||||||
|
setting of 10, backend A might reserve values 1..10 and return nextval=1, then
|
||||||
|
backend B might reserve values 11..20 and return nextval=11 before backend
|
||||||
|
A has generated nextval=2.) Thus, with a cache setting of one it is safe
|
||||||
|
to assume that nextval values are generated sequentially; with a cache
|
||||||
|
setting greater than one you should only assume that the nextval values
|
||||||
|
are all distinct, not that they are generated purely sequentially.
|
||||||
|
Also, last_value will reflect the latest value reserved by any backend,
|
||||||
|
whether or not it has yet been returned by nextval.
|
||||||
.PP
|
.PP
|
||||||
.SH EXAMPLES
|
.SH EXAMPLES
|
||||||
.nf
|
.nf
|
||||||
|
Loading…
x
Reference in New Issue
Block a user