? doc/src/sgml/ref/alter_sequence.sgml
? src/test/regress/expected/sequence.out
? src/test/regress/sql/.sequence.sql.swp
? src/test/regress/sql/sequence.sql
Index: doc/src/sgml/reference.sgml
===================================================================
RCS file: /projects/cvsroot/pgsql-server/doc/src/sgml/reference.sgml,v
retrieving revision 1.41
diff -c -r1.41 reference.sgml
*** doc/src/sgml/reference.sgml 2002/12/06 05:00:10 1.41
--- doc/src/sgml/reference.sgml 2003/03/03 03:40:16
***************
*** 49,54 ****
--- 49,55 ----
&alterDatabase;
&alterDomain;
&alterGroup;
+ &alterSequence;
&alterTable;
&alterTrigger;
&alterUser;
Index: doc/src/sgml/ref/allfiles.sgml
===================================================================
RCS file: /projects/cvsroot/pgsql-server/doc/src/sgml/ref/allfiles.sgml,v
retrieving revision 1.52
diff -c -r1.52 allfiles.sgml
*** doc/src/sgml/ref/allfiles.sgml 2002/12/06 04:40:36 1.52
--- doc/src/sgml/ref/allfiles.sgml 2003/03/03 03:40:38
***************
*** 40,45 ****
--- 40,46 ----
+
Index: doc/src/sgml/ref/create_sequence.sgml
===================================================================
RCS file: /projects/cvsroot/pgsql-server/doc/src/sgml/ref/create_sequence.sgml,v
retrieving revision 1.30
diff -c -r1.30 create_sequence.sgml
*** doc/src/sgml/ref/create_sequence.sgml 2003/01/19 00:13:29 1.30
--- doc/src/sgml/ref/create_sequence.sgml 2003/03/03 03:40:38
***************
*** 22,28 ****
CREATE [ TEMPORARY | TEMP ] SEQUENCE seqname [ INCREMENT [ BY ] increment ]
! [ MINVALUE minvalue ] [ MAXVALUE maxvalue ]
[ START [ WITH ] start ] [ CACHE cache ] [ [ NO ] CYCLE ]
--- 22,28 ----
CREATE [ TEMPORARY | TEMP ] SEQUENCE seqname [ INCREMENT [ BY ] increment ]
! [ MINVALUE minvalue | NO MINVALUE ] [ MAXVALUE maxvalue | NO MAXVALUE ]
[ START [ WITH ] start ] [ CACHE cache ] [ [ NO ] CYCLE ]
***************
*** 63,69 ****
The
!
clause is optional. A positive value will make an
ascending sequence, a negative one a descending sequence.
The default value is one (1).
--- 63,69 ----
The
!
clause is optional. A positive value will make an
ascending sequence, a negative one a descending sequence.
The default value is one (1).
***************
*** 73,84 ****
minvalue
The optional clause
determines the minimum value
! a sequence can generate. The defaults are 1 and -2^63-1 for
ascending and descending sequences, respectively.
--- 73,86 ----
minvalue
+ NO MINVALUE
The optional clause
determines the minimum value
! a sequence can generate. If this clause is not supplied or
! is specified, then defaults will be used. The defaults are 1 and -2^63-1 for
ascending and descending sequences, respectively.
***************
*** 86,98 ****
maxvalue
The optional clause
determines the maximum
! value for the sequence. The defaults are 2^63-1 and -1 for
! ascending and descending sequences, respectively.
--- 88,102 ----
maxvalue
+ NO MAXVALUE
The optional clause
determines the maximum
! value for the sequence. If this clause is not supplied or
! is specified, then default values will be used.
! The defaults are 2^63-1 and -1 for ascending and descending sequences, respectively.
***************
*** 101,107 ****
start
! The optional enables the sequence to begin anywhere.
The default starting value is
--- 105,111 ----
start
! The optional enables the sequence to begin anywhere.
The default starting value is
Index: src/backend/commands/sequence.c
===================================================================
RCS file: /projects/cvsroot/pgsql-server/src/backend/commands/sequence.c,v
retrieving revision 1.91
diff -c -r1.91 sequence.c
*** src/backend/commands/sequence.c 2003/02/13 05:25:24 1.91
--- src/backend/commands/sequence.c 2003/03/03 03:40:49
***************
*** 84,90 ****
SeqTable *p_elm, Relation *p_rel);
static Form_pg_sequence read_info(const char *caller, SeqTable elm,
Relation rel, Buffer *buf);
! static void init_params(CreateSeqStmt *seq, Form_pg_sequence new);
static void do_setval(RangeVar *sequence, int64 next, bool iscalled);
/*
--- 84,90 ----
SeqTable *p_elm, Relation *p_rel);
static Form_pg_sequence read_info(const char *caller, SeqTable elm,
Relation rel, Buffer *buf);
! static void init_params(char *caller, List *options, Form_pg_sequence new);
static void do_setval(RangeVar *sequence, int64 next, bool iscalled);
/*
***************
*** 108,115 ****
int i;
NameData name;
/* Check and set values */
! init_params(seq, &new);
/*
* Create relation (and fill *null & *value)
--- 108,123 ----
int i;
NameData name;
+ /* Values are NULL (or false) by default */
+ new.last_value = NULL;
+ new.increment_by = NULL;
+ new.max_value = NULL;
+ new.min_value = NULL;
+ new.cache_value = NULL;
+ new.is_cycled = false;
+
/* Check and set values */
! init_params("DefineSequence", seq->options, &new);
/*
* Create relation (and fill *null & *value)
***************
*** 302,308 ****
--- 310,400 ----
heap_close(rel, NoLock);
}
+ /*
+ * AlterSequence
+ *
+ * Modify the defition of a sequence relation
+ */
+ void
+ AlterSequence(AlterSeqStmt *stmt)
+ {
+ SeqTable elm;
+ Relation seqrel;
+ Buffer buf;
+ Page page;
+ Form_pg_sequence seq;
+ FormData_pg_sequence new;
+
+ /* open and AccessShareLock sequence */
+ init_sequence("setval", stmt->sequence, &elm, &seqrel);
+
+ /* Allow DROP to sequence owner only*/
+ if (!pg_class_ownercheck(elm->relid, GetUserId()))
+ aclcheck_error(ACLCHECK_NOT_OWNER, stmt->sequence->relname);
+
+ /* lock page' buffer and read tuple into new sequence structure */
+ seq = read_info("nextval", elm, seqrel, &buf);
+ page = BufferGetPage(buf);
+
+ new.increment_by = seq->increment_by;
+ new.max_value = seq->max_value;
+ new.min_value = seq->min_value;
+ new.cache_value = seq->cache_value;
+ new.is_cycled = seq->is_cycled;
+ new.last_value = seq->last_value;
+
+ /* Check and set values */
+ init_params("AlterSequence", stmt->options, &new);
+
+ seq->increment_by = new.increment_by;
+ seq->max_value = new.max_value;
+ seq->min_value = new.min_value;
+ seq->cache_value = new.cache_value;
+ seq->is_cycled = new.is_cycled;
+ if (seq->last_value != new.last_value)
+ {
+ seq->last_value = new.last_value;
+ seq->is_called = false;
+ seq->log_cnt = 1;
+ }
+
+ START_CRIT_SECTION();
+
+ /* XLOG stuff */
+ if (!seqrel->rd_istemp)
+ {
+ xl_seq_rec xlrec;
+ XLogRecPtr recptr;
+ XLogRecData rdata[2];
+ xlrec.node = seqrel->rd_node;
+ rdata[0].buffer = InvalidBuffer;
+ rdata[0].data = (char *) &xlrec;
+ rdata[0].len = sizeof(xl_seq_rec);
+ rdata[0].next = &(rdata[1]);
+
+ rdata[1].buffer = InvalidBuffer;
+ rdata[1].data = (char *) page + ((PageHeader) page)->pd_upper;
+ rdata[1].len = ((PageHeader) page)->pd_special -
+ ((PageHeader) page)->pd_upper;
+ rdata[1].next = NULL;
+
+ recptr = XLogInsert(RM_SEQ_ID, XLOG_SEQ_LOG | XLOG_NO_TRAN, rdata);
+
+ PageSetLSN(page, recptr);
+ PageSetSUI(page, ThisStartUpID);
+ }
+
+ END_CRIT_SECTION();
+
+ LockBuffer(buf, BUFFER_LOCK_UNLOCK);
+
+ WriteBuffer(buf);
+
+ relation_close(seqrel, NoLock);
+ }
+
+
Datum
nextval(PG_FUNCTION_ARGS)
{
***************
*** 774,780 ****
static void
! init_params(CreateSeqStmt *seq, Form_pg_sequence new)
{
DefElem *last_value = NULL;
DefElem *increment_by = NULL;
--- 866,872 ----
static void
! init_params(char *caller, List *options, Form_pg_sequence new)
{
DefElem *last_value = NULL;
DefElem *increment_by = NULL;
***************
*** 784,859 ****
bool is_cycled_set = false;
List *option;
! new->is_cycled = false;
! foreach(option, seq->options)
{
DefElem *defel = (DefElem *) lfirst(option);
if (strcmp(defel->defname, "increment") == 0)
{
if (increment_by)
! elog(ERROR, "DefineSequence: INCREMENT BY defined twice");
increment_by = defel;
}
! else if (strcmp(defel->defname, "start") == 0)
{
if (last_value)
! elog(ERROR, "DefineSequence: LAST VALUE defined twice");
last_value = defel;
}
else if (strcmp(defel->defname, "maxvalue") == 0)
{
if (max_value)
! elog(ERROR, "DefineSequence: MAX VALUE defined twice");
max_value = defel;
}
else if (strcmp(defel->defname, "minvalue") == 0)
{
if (min_value)
! elog(ERROR, "DefineSequence: MIN VALUE defined twice");
min_value = defel;
}
else if (strcmp(defel->defname, "cache") == 0)
{
if (cache_value)
! elog(ERROR, "DefineSequence: CACHE defined twice");
cache_value = defel;
}
else if (strcmp(defel->defname, "cycle") == 0)
{
if (is_cycled_set)
! elog(ERROR, "DefineSequence: CYCLE defined twice");
is_cycled_set = true;
new->is_cycled = (defel->arg != NULL);
}
else
! elog(ERROR, "DefineSequence: option \"%s\" not recognized",
defel->defname);
}
! if (increment_by == (DefElem *) NULL) /* INCREMENT BY */
new->increment_by = 1;
! else if ((new->increment_by = defGetInt64(increment_by)) == 0)
! elog(ERROR, "DefineSequence: can't INCREMENT by 0");
! if (max_value == (DefElem *) NULL || !max_value->arg) /* MAXVALUE */
{
if (new->increment_by > 0)
! new->max_value = SEQ_MAXVALUE; /* ascending seq */
else
! new->max_value = -1; /* descending seq */
}
! else
new->max_value = defGetInt64(max_value);
! if (min_value == (DefElem *) NULL || !min_value->arg) /* MINVALUE */
{
if (new->increment_by > 0)
! new->min_value = 1; /* ascending seq */
else
! new->min_value = SEQ_MINVALUE; /* descending seq */
}
! else
new->min_value = defGetInt64(min_value);
if (new->min_value >= new->max_value)
--- 876,967 ----
bool is_cycled_set = false;
List *option;
! foreach(option, options)
{
DefElem *defel = (DefElem *) lfirst(option);
if (strcmp(defel->defname, "increment") == 0)
{
if (increment_by)
! elog(ERROR, "%s: INCREMENT BY defined twice", caller);
!
increment_by = defel;
+
}
! /*
! * start is for a new sequence
! * restart is for alter
! */
! else if ((new->last_value == NULL && strcmp(defel->defname, "start") == 0)
! || (new->last_value != NULL && strcmp(defel->defname, "restart") == 0))
{
if (last_value)
! elog(ERROR, "%s: LAST VALUE defined twice", caller);
last_value = defel;
}
else if (strcmp(defel->defname, "maxvalue") == 0)
{
if (max_value)
! elog(ERROR, "%s: MAX VALUE defined twice", caller);
max_value = defel;
}
else if (strcmp(defel->defname, "minvalue") == 0)
{
if (min_value)
! elog(ERROR, "%s: MIN VALUE defined twice", caller);
min_value = defel;
}
else if (strcmp(defel->defname, "cache") == 0)
{
if (cache_value)
! elog(ERROR, "%s: CACHE defined twice", caller);
cache_value = defel;
}
else if (strcmp(defel->defname, "cycle") == 0)
{
if (is_cycled_set)
! elog(ERROR, "%s: CYCLE defined twice", caller);
is_cycled_set = true;
new->is_cycled = (defel->arg != NULL);
}
else
! elog(ERROR, "%s: option \"%s\" not recognized", caller,
defel->defname);
}
! /* INCREMENT BY */
! if (new->increment_by == NULL && increment_by == (DefElem *) NULL)
new->increment_by = 1;
! else if (increment_by != (DefElem *) NULL)
! {
! if (defGetInt64(increment_by) == 0)
! elog(ERROR, "%s: can't INCREMENT by 0", caller);
!
! new->increment_by = defGetInt64(increment_by);
! }
! /* MAXVALUE */
! if ((new->max_value == NULL && max_value == (DefElem *) NULL)
! || (max_value != (DefElem *) NULL && !max_value->arg))
{
if (new->increment_by > 0)
! new->max_value = SEQ_MAXVALUE; /* ascending seq */
else
! new->max_value = -1; /* descending seq */
}
! else if (max_value != (DefElem *) NULL)
new->max_value = defGetInt64(max_value);
! /* MINVALUE */
! if ((new->min_value == NULL && min_value == (DefElem *) NULL)
! || (min_value != (DefElem *) NULL && !min_value->arg))
{
if (new->increment_by > 0)
! new->min_value = 1; /* ascending seq */
else
! new->min_value = SEQ_MINVALUE; /* descending seq */
}
! else if (min_value != (DefElem *) NULL)
new->min_value = defGetInt64(min_value);
if (new->min_value >= new->max_value)
***************
*** 863,880 ****
snprintf(bufm, 100, INT64_FORMAT, new->min_value);
snprintf(bufx, 100, INT64_FORMAT, new->max_value);
! elog(ERROR, "DefineSequence: MINVALUE (%s) must be less than MAXVALUE (%s)",
! bufm, bufx);
}
! if (last_value == (DefElem *) NULL) /* START WITH */
{
if (new->increment_by > 0)
new->last_value = new->min_value; /* ascending seq */
else
new->last_value = new->max_value; /* descending seq */
}
! else
new->last_value = defGetInt64(last_value);
if (new->last_value < new->min_value)
--- 971,989 ----
snprintf(bufm, 100, INT64_FORMAT, new->min_value);
snprintf(bufx, 100, INT64_FORMAT, new->max_value);
! elog(ERROR, "%s: MINVALUE (%s) must be less than MAXVALUE (%s)",
! caller, bufm, bufx);
}
! /* START WITH */
! if (new->last_value == NULL && last_value == (DefElem *) NULL)
{
if (new->increment_by > 0)
new->last_value = new->min_value; /* ascending seq */
else
new->last_value = new->max_value; /* descending seq */
}
! else if (last_value != (DefElem *) NULL)
new->last_value = defGetInt64(last_value);
if (new->last_value < new->min_value)
***************
*** 884,891 ****
snprintf(bufs, 100, INT64_FORMAT, new->last_value);
snprintf(bufm, 100, INT64_FORMAT, new->min_value);
! elog(ERROR, "DefineSequence: START value (%s) can't be less than MINVALUE (%s)",
! bufs, bufm);
}
if (new->last_value > new->max_value)
{
--- 993,1000 ----
snprintf(bufs, 100, INT64_FORMAT, new->last_value);
snprintf(bufm, 100, INT64_FORMAT, new->min_value);
! elog(ERROR, "%s: START value (%s) can't be less than MINVALUE (%s)",
! caller, bufs, bufm);
}
if (new->last_value > new->max_value)
{
***************
*** 894,914 ****
snprintf(bufs, 100, INT64_FORMAT, new->last_value);
snprintf(bufm, 100, INT64_FORMAT, new->max_value);
! elog(ERROR, "DefineSequence: START value (%s) can't be greater than MAXVALUE (%s)",
! bufs, bufm);
}
! if (cache_value == (DefElem *) NULL) /* CACHE */
new->cache_value = 1;
else if ((new->cache_value = defGetInt64(cache_value)) <= 0)
{
char buf[100];
snprintf(buf, 100, INT64_FORMAT, new->cache_value);
! elog(ERROR, "DefineSequence: CACHE (%s) can't be <= 0",
! buf);
}
-
}
--- 1003,1023 ----
snprintf(bufs, 100, INT64_FORMAT, new->last_value);
snprintf(bufm, 100, INT64_FORMAT, new->max_value);
! elog(ERROR, "%s: START value (%s) can't be greater than MAXVALUE (%s)",
! caller, bufs, bufm);
}
! /* CACHE */
! if (cache_value == (DefElem *) NULL)
new->cache_value = 1;
else if ((new->cache_value = defGetInt64(cache_value)) <= 0)
{
char buf[100];
snprintf(buf, 100, INT64_FORMAT, new->cache_value);
! elog(ERROR, "%s: CACHE (%s) can't be <= 0",
! caller, buf);
}
}
Index: src/backend/nodes/copyfuncs.c
===================================================================
RCS file: /projects/cvsroot/pgsql-server/src/backend/nodes/copyfuncs.c,v
retrieving revision 1.244
diff -c -r1.244 copyfuncs.c
*** src/backend/nodes/copyfuncs.c 2003/02/16 02:30:37 1.244
--- src/backend/nodes/copyfuncs.c 2003/03/03 03:41:25
***************
*** 2053,2058 ****
--- 2053,2069 ----
return newnode;
}
+ static AlterSeqStmt *
+ _copyAlterSeqStmt(AlterSeqStmt *from)
+ {
+ AlterSeqStmt *newnode = makeNode(AlterSeqStmt);
+
+ COPY_NODE_FIELD(sequence);
+ COPY_NODE_FIELD(options);
+
+ return newnode;
+ }
+
static VariableSetStmt *
_copyVariableSetStmt(VariableSetStmt *from)
{
***************
*** 2726,2731 ****
--- 2737,2745 ----
break;
case T_CreateSeqStmt:
retval = _copyCreateSeqStmt(from);
+ break;
+ case T_AlterSeqStmt:
+ retval = _copyAlterSeqStmt(from);
break;
case T_VariableSetStmt:
retval = _copyVariableSetStmt(from);
Index: src/backend/nodes/equalfuncs.c
===================================================================
RCS file: /projects/cvsroot/pgsql-server/src/backend/nodes/equalfuncs.c,v
retrieving revision 1.187
diff -c -r1.187 equalfuncs.c
*** src/backend/nodes/equalfuncs.c 2003/02/16 02:30:37 1.187
--- src/backend/nodes/equalfuncs.c 2003/03/03 03:41:40
***************
*** 1059,1064 ****
--- 1059,1073 ----
}
static bool
+ _equalAlterSeqStmt(AlterSeqStmt *a, AlterSeqStmt *b)
+ {
+ COMPARE_NODE_FIELD(sequence);
+ COMPARE_NODE_FIELD(options);
+
+ return true;
+ }
+
+ static bool
_equalVariableSetStmt(VariableSetStmt *a, VariableSetStmt *b)
{
COMPARE_STRING_FIELD(name);
***************
*** 1852,1857 ****
--- 1861,1869 ----
break;
case T_CreateSeqStmt:
retval = _equalCreateSeqStmt(a, b);
+ break;
+ case T_AlterSeqStmt:
+ retval = _equalAlterSeqStmt(a, b);
break;
case T_VariableSetStmt:
retval = _equalVariableSetStmt(a, b);
Index: src/backend/parser/gram.y
===================================================================
RCS file: /projects/cvsroot/pgsql-server/src/backend/parser/gram.y,v
retrieving revision 2.404
diff -c -r2.404 gram.y
*** src/backend/parser/gram.y 2003/02/16 02:30:38 2.404
--- src/backend/parser/gram.y 2003/03/03 03:43:26
***************
*** 129,135 ****
%type stmt schema_stmt
AlterDatabaseSetStmt AlterDomainStmt AlterGroupStmt
! AlterTableStmt AlterUserStmt AlterUserSetStmt
AnalyzeStmt ClosePortalStmt ClusterStmt CommentStmt
ConstraintsSetStmt CopyStmt CreateAsStmt CreateCastStmt
CreateDomainStmt CreateGroupStmt CreateOpClassStmt CreatePLangStmt
--- 129,135 ----
%type stmt schema_stmt
AlterDatabaseSetStmt AlterDomainStmt AlterGroupStmt
! AlterSeqStmt AlterTableStmt AlterUserStmt AlterUserSetStmt
AnalyzeStmt ClosePortalStmt ClusterStmt CommentStmt
ConstraintsSetStmt CopyStmt CreateAsStmt CreateCastStmt
CreateDomainStmt CreateGroupStmt CreateOpClassStmt CreatePLangStmt
***************
*** 379,385 ****
PROCEDURE
READ REAL RECHECK REFERENCES REINDEX RELATIVE RENAME REPLACE
! RESET RESTRICT RETURNS REVOKE RIGHT ROLLBACK ROW ROWS
RULE
SCHEMA SCROLL SECOND_P SECURITY SELECT SEQUENCE
--- 379,385 ----
PROCEDURE
READ REAL RECHECK REFERENCES REINDEX RELATIVE RENAME REPLACE
! RESET RESTART RESTRICT RETURNS REVOKE RIGHT ROLLBACK ROW ROWS
RULE
SCHEMA SCROLL SECOND_P SECURITY SELECT SEQUENCE
***************
*** 480,485 ****
--- 480,486 ----
AlterDatabaseSetStmt
| AlterDomainStmt
| AlterGroupStmt
+ | AlterSeqStmt
| AlterTableStmt
| AlterUserStmt
| AlterUserSetStmt
***************
*** 1867,1872 ****
--- 1868,1874 ----
*
* QUERY :
* CREATE SEQUENCE seqname
+ * ALTER SEQUENCE seqname
*
*****************************************************************************/
***************
*** 1881,1886 ****
--- 1883,1898 ----
}
;
+ AlterSeqStmt:
+ ALTER SEQUENCE qualified_name OptSeqList
+ {
+ AlterSeqStmt *n = makeNode(AlterSeqStmt);
+ n->sequence = $3;
+ n->options = $4;
+ $$ = (Node *)n;
+ }
+ ;
+
OptSeqList: OptSeqList OptSeqElem { $$ = lappend($1, $2); }
| /*EMPTY*/ { $$ = NIL; }
;
***************
*** 1921,1926 ****
--- 1933,1942 ----
{
$$ = makeDefElem("start", (Node *)$3);
}
+ | RESTART opt_with NumericOnly
+ {
+ $$ = makeDefElem("restart", (Node *)$3);
+ }
;
opt_by: BY {}
***************
*** 7169,7174 ****
--- 7185,7191 ----
| RENAME
| REPLACE
| RESET
+ | RESTART
| RESTRICT
| RETURNS
| REVOKE
Index: src/backend/parser/keywords.c
===================================================================
RCS file: /projects/cvsroot/pgsql-server/src/backend/parser/keywords.c,v
retrieving revision 1.134
diff -c -r1.134 keywords.c
*** src/backend/parser/keywords.c 2003/02/10 04:44:46 1.134
--- src/backend/parser/keywords.c 2003/03/03 03:43:27
***************
*** 246,251 ****
--- 246,252 ----
{"rename", RENAME},
{"replace", REPLACE},
{"reset", RESET},
+ {"restart", RESTART},
{"restrict", RESTRICT},
{"returns", RETURNS},
{"revoke", REVOKE},
Index: src/backend/tcop/postgres.c
===================================================================
RCS file: /projects/cvsroot/pgsql-server/src/backend/tcop/postgres.c,v
retrieving revision 1.315
diff -c -r1.315 postgres.c
*** src/backend/tcop/postgres.c 2003/02/10 04:44:46 1.315
--- src/backend/tcop/postgres.c 2003/03/03 03:44:03
***************
*** 2369,2374 ****
--- 2369,2378 ----
tag = "CREATE SEQUENCE";
break;
+ case T_AlterSeqStmt:
+ tag = "ALTER SEQUENCE";
+ break;
+
case T_RemoveAggrStmt:
tag = "DROP AGGREGATE";
break;
Index: src/backend/tcop/utility.c
===================================================================
RCS file: /projects/cvsroot/pgsql-server/src/backend/tcop/utility.c,v
retrieving revision 1.193
diff -c -r1.193 utility.c
*** src/backend/tcop/utility.c 2003/02/19 03:59:02 1.193
--- src/backend/tcop/utility.c 2003/03/03 03:44:12
***************
*** 183,188 ****
--- 183,189 ----
case T_AlterDatabaseSetStmt:
case T_AlterDomainStmt:
case T_AlterGroupStmt:
+ case T_AlterSeqStmt:
case T_AlterTableStmt:
case T_RenameStmt:
case T_AlterUserStmt:
***************
*** 749,754 ****
--- 750,759 ----
case T_CreateSeqStmt:
DefineSequence((CreateSeqStmt *) parsetree);
+ break;
+
+ case T_AlterSeqStmt:
+ AlterSequence((AlterSeqStmt *) parsetree);
break;
case T_RemoveAggrStmt:
Index: src/include/commands/sequence.h
===================================================================
RCS file: /projects/cvsroot/pgsql-server/src/include/commands/sequence.h,v
retrieving revision 1.21
diff -c -r1.21 sequence.h
*** src/include/commands/sequence.h 2002/06/20 20:29:49 1.21
--- src/include/commands/sequence.h 2003/03/03 03:44:38
***************
*** 84,89 ****
--- 84,90 ----
extern Datum setval_and_iscalled(PG_FUNCTION_ARGS);
extern void DefineSequence(CreateSeqStmt *stmt);
+ extern void AlterSequence(AlterSeqStmt *stmt);
extern void seq_redo(XLogRecPtr lsn, XLogRecord *rptr);
extern void seq_undo(XLogRecPtr lsn, XLogRecord *rptr);
Index: src/include/nodes/nodes.h
===================================================================
RCS file: /projects/cvsroot/pgsql-server/src/include/nodes/nodes.h,v
retrieving revision 1.137
diff -c -r1.137 nodes.h
*** src/include/nodes/nodes.h 2003/02/16 02:30:39 1.137
--- src/include/nodes/nodes.h 2003/03/03 03:44:45
***************
*** 220,225 ****
--- 220,226 ----
T_VacuumStmt,
T_ExplainStmt,
T_CreateSeqStmt,
+ T_AlterSeqStmt,
T_VariableSetStmt,
T_VariableShowStmt,
T_VariableResetStmt,
Index: src/include/nodes/parsenodes.h
===================================================================
RCS file: /projects/cvsroot/pgsql-server/src/include/nodes/parsenodes.h,v
retrieving revision 1.231
diff -c -r1.231 parsenodes.h
*** src/include/nodes/parsenodes.h 2003/02/16 02:30:39 1.231
--- src/include/nodes/parsenodes.h 2003/03/03 03:45:02
***************
*** 1058,1064 ****
} DropGroupStmt;
/* ----------------------
! * Create SEQUENCE Statement
* ----------------------
*/
--- 1058,1064 ----
} DropGroupStmt;
/* ----------------------
! * {Create|Alter} SEQUENCE Statement
* ----------------------
*/
***************
*** 1068,1073 ****
--- 1068,1080 ----
RangeVar *sequence; /* the sequence to create */
List *options;
} CreateSeqStmt;
+
+ typedef struct AlterSeqStmt
+ {
+ NodeTag type;
+ RangeVar *sequence; /* the sequence to alter */
+ List *options;
+ } AlterSeqStmt;
/* ----------------------
* Create {Aggregate|Operator|Type} Statement
Index: src/test/regress/parallel_schedule
===================================================================
RCS file: /projects/cvsroot/pgsql-server/src/test/regress/parallel_schedule,v
retrieving revision 1.19
diff -c -r1.19 parallel_schedule
*** src/test/regress/parallel_schedule 2002/10/22 20:20:10 1.19
--- src/test/regress/parallel_schedule 2003/03/03 03:45:27
***************
*** 74,77 ****
# The sixth group of parallel test
# ----------
# "plpgsql" cannot run concurrently with "rules"
! test: limit plpgsql copy2 temp domain rangefuncs prepare without_oid conversion truncate alter_table
--- 74,77 ----
# The sixth group of parallel test
# ----------
# "plpgsql" cannot run concurrently with "rules"
! test: limit plpgsql copy2 temp domain rangefuncs prepare without_oid conversion truncate alter_table sequence
Index: src/test/regress/serial_schedule
===================================================================
RCS file: /projects/cvsroot/pgsql-server/src/test/regress/serial_schedule,v
retrieving revision 1.18
diff -c -r1.18 serial_schedule
*** src/test/regress/serial_schedule 2002/09/02 05:55:43 1.18
--- src/test/regress/serial_schedule 2003/03/03 03:45:27
***************
*** 90,92 ****
--- 90,93 ----
test: conversion
test: truncate
test: alter_table
+ test: sequence
Index: src/test/regress/expected/alter_table.out
===================================================================
RCS file: /projects/cvsroot/pgsql-server/src/test/regress/expected/alter_table.out,v
retrieving revision 1.56
diff -c -r1.56 alter_table.out
*** src/test/regress/expected/alter_table.out 2003/02/13 05:20:03 1.56
--- src/test/regress/expected/alter_table.out 2003/03/03 03:45:48
***************
*** 286,301 ****
(5 rows)
DROP VIEW tmp_view_new;
- -- renaming sequences
- CREATE SEQUENCE foo_seq;
- ALTER TABLE foo_seq RENAME TO foo_seq_new;
- SELECT * FROM foo_seq_new;
- sequence_name | last_value | increment_by | max_value | min_value | cache_value | log_cnt | is_cycled | is_called
- ---------------+------------+--------------+---------------------+-----------+-------------+---------+-----------+-----------
- foo_seq | 1 | 1 | 9223372036854775807 | 1 | 1 | 1 | f | f
- (1 row)
-
- DROP SEQUENCE foo_seq_new;
-- toast-like relation name
alter table stud_emp rename to pg_toast_stud_emp;
alter table pg_toast_stud_emp rename to stud_emp;
--- 286,291 ----
Index: src/test/regress/expected/create_misc.out
===================================================================
RCS file: /projects/cvsroot/pgsql-server/src/test/regress/expected/create_misc.out,v
retrieving revision 1.18
diff -c -r1.18 create_misc.out
*** src/test/regress/expected/create_misc.out 2002/08/19 19:33:36 1.18
--- src/test/regress/expected/create_misc.out 2003/03/03 03:45:51
***************
*** 132,162 ****
VALUES (1, 3.567, '(3.0,1.0),(4.0,2.0)'::polygon);
INSERT INTO iportaltest (i, d, p)
VALUES (2, 89.05, '(4.0,2.0),(3.0,1.0)'::polygon);
- ---
- --- test creation of SERIAL column
- ---
- CREATE TABLE serialTest (f1 text, f2 serial);
- NOTICE: CREATE TABLE will create implicit sequence 'serialtest_f2_seq' for SERIAL column 'serialtest.f2'
- INSERT INTO serialTest VALUES ('foo');
- INSERT INTO serialTest VALUES ('bar');
- INSERT INTO serialTest VALUES ('force', 100);
- INSERT INTO serialTest VALUES ('wrong', NULL);
- ERROR: ExecInsert: Fail to add null value in not null attribute f2
- SELECT * FROM serialTest;
- f1 | f2
- -------+-----
- foo | 1
- bar | 2
- force | 100
- (3 rows)
-
- CREATE SEQUENCE sequence_test;
- BEGIN;
- SELECT nextval('sequence_test');
- nextval
- ---------
- 1
- (1 row)
-
- DROP SEQUENCE sequence_test;
- END;
--- 132,134 ----
Index: src/test/regress/sql/alter_table.sql
===================================================================
RCS file: /projects/cvsroot/pgsql-server/src/test/regress/sql/alter_table.sql,v
retrieving revision 1.37
diff -c -r1.37 alter_table.sql
*** src/test/regress/sql/alter_table.sql 2003/02/13 05:20:05 1.37
--- src/test/regress/sql/alter_table.sql 2003/03/03 03:45:57
***************
*** 173,183 ****
-- 5 values, sorted
SELECT unique1 FROM tenk1 WHERE unique1 < 5;
DROP VIEW tmp_view_new;
- -- renaming sequences
- CREATE SEQUENCE foo_seq;
- ALTER TABLE foo_seq RENAME TO foo_seq_new;
- SELECT * FROM foo_seq_new;
- DROP SEQUENCE foo_seq_new;
-- toast-like relation name
alter table stud_emp rename to pg_toast_stud_emp;
alter table pg_toast_stud_emp rename to stud_emp;
--- 173,178 ----
Index: src/test/regress/sql/create_misc.sql
===================================================================
RCS file: /projects/cvsroot/pgsql-server/src/test/regress/sql/create_misc.sql,v
retrieving revision 1.12
diff -c -r1.12 create_misc.sql
*** src/test/regress/sql/create_misc.sql 2002/06/26 21:58:56 1.12
--- src/test/regress/sql/create_misc.sql 2003/03/03 03:45:57
***************
*** 203,226 ****
INSERT INTO iportaltest (i, d, p)
VALUES (2, 89.05, '(4.0,2.0),(3.0,1.0)'::polygon);
-
-
- ---
- --- test creation of SERIAL column
- ---
-
- CREATE TABLE serialTest (f1 text, f2 serial);
-
- INSERT INTO serialTest VALUES ('foo');
- INSERT INTO serialTest VALUES ('bar');
- INSERT INTO serialTest VALUES ('force', 100);
- INSERT INTO serialTest VALUES ('wrong', NULL);
-
- SELECT * FROM serialTest;
-
- CREATE SEQUENCE sequence_test;
-
- BEGIN;
- SELECT nextval('sequence_test');
- DROP SEQUENCE sequence_test;
- END;
--- 203,205 ----