1
0
mirror of https://github.com/postgres/postgres.git synced 2025-06-13 07:41:39 +03:00

From: Massimo Dal Zotto <dz@cs.unitn.it>

> sequence.patch
>
>       adds the missing setval command to sequences. Owner of sequences
>       can now set the last value to any value between min and max
>       without recreating the sequence. This is useful after loading
>       data from external files.
This commit is contained in:
Marc G. Fournier
1998-08-25 21:25:46 +00:00
parent 88b17d9c56
commit 8e9d69d6ac
4 changed files with 60 additions and 5 deletions

View File

@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/parser/parse_func.c,v 1.25 1998/08/19 02:02:20 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/parser/parse_func.c,v 1.26 1998/08/25 21:25:42 scrappy Exp $
*
*-------------------------------------------------------------------------
*/
@ -427,7 +427,8 @@ ParseFuncOrColumn(ParseState *pstate, char *funcname, List *fargs,
* Sequence handling.
*/
if (funcid == F_NEXTVAL ||
funcid == F_CURRVAL)
funcid == F_CURRVAL ||
funcid == F_SETVAL)
{
Const *seq;
char *seqrel;
@ -435,7 +436,7 @@ ParseFuncOrColumn(ParseState *pstate, char *funcname, List *fargs,
int32 aclcheck_result = -1;
extern text *lower(text *string);
Assert(length(fargs) == 1);
Assert(length(fargs) == ((funcid == F_SETVAL) ? 2 : 1));
seq = (Const *) lfirst(fargs);
if (!IsA((Node *) seq, Const))
elog(ERROR, "Only constant sequence names are acceptable for function '%s'", funcname);
@ -445,7 +446,8 @@ ParseFuncOrColumn(ParseState *pstate, char *funcname, List *fargs,
seqrel = textout(seqname);
if ((aclcheck_result = pg_aclcheck(seqrel, GetPgUserName(),
((funcid == F_NEXTVAL) ? ACL_WR : ACL_RD)))
(((funcid == F_NEXTVAL) || (funcid == F_SETVAL)) ?
ACL_WR : ACL_RD)))
!= ACLCHECK_OK)
elog(ERROR, "%s.%s: %s",
seqrel, funcname, aclcheck_error_strings[aclcheck_result]);
@ -454,6 +456,8 @@ ParseFuncOrColumn(ParseState *pstate, char *funcname, List *fargs,
if (funcid == F_NEXTVAL && pstate->p_in_where_clause)
elog(ERROR, "Sequence function nextval is not allowed in WHERE clauses");
if (funcid == F_SETVAL && pstate->p_in_where_clause)
elog(ERROR, "Sequence function setval is not allowed in WHERE clauses");
}
expr = makeNode(Expr);