88 *
99 *
1010 * IDENTIFICATION
11- * $Header: /cvsroot/pgsql/src/backend/commands/sequence.c,v 1.90 2002/11/11 22:19:21 tgl Exp $
11+ * $Header: /cvsroot/pgsql/src/backend/commands/sequence.c,v 1.91 2003/02/13 05:25:24 momjian Exp $
1212 *
1313 *-------------------------------------------------------------------------
1414 */
@@ -781,6 +781,7 @@ init_params(CreateSeqStmt *seq, Form_pg_sequence new)
781781DefElem * max_value = NULL ;
782782DefElem * min_value = NULL ;
783783DefElem * cache_value = NULL ;
784+ bool is_cycled_set = false;
784785List * option ;
785786
786787new -> is_cycled = false;
@@ -789,17 +790,42 @@ init_params(CreateSeqStmt *seq, Form_pg_sequence new)
789790DefElem * defel = (DefElem * )lfirst (option );
790791
791792if (strcmp (defel -> defname ,"increment" )== 0 )
793+ {
794+ if (increment_by )
795+ elog (ERROR ,"DefineSequence: INCREMENT BY defined twice" );
792796increment_by = defel ;
797+ }
793798else if (strcmp (defel -> defname ,"start" )== 0 )
799+ {
800+ if (last_value )
801+ elog (ERROR ,"DefineSequence: LAST VALUE defined twice" );
794802last_value = defel ;
803+ }
795804else if (strcmp (defel -> defname ,"maxvalue" )== 0 )
805+ {
806+ if (max_value )
807+ elog (ERROR ,"DefineSequence: MAX VALUE defined twice" );
796808max_value = defel ;
809+ }
797810else if (strcmp (defel -> defname ,"minvalue" )== 0 )
811+ {
812+ if (min_value )
813+ elog (ERROR ,"DefineSequence: MIN VALUE defined twice" );
798814min_value = defel ;
815+ }
799816else if (strcmp (defel -> defname ,"cache" )== 0 )
817+ {
818+ if (cache_value )
819+ elog (ERROR ,"DefineSequence: CACHE defined twice" );
800820cache_value = defel ;
821+ }
801822else if (strcmp (defel -> defname ,"cycle" )== 0 )
823+ {
824+ if (is_cycled_set )
825+ elog (ERROR ,"DefineSequence: CYCLE defined twice" );
826+ is_cycled_set = true;
802827new -> is_cycled = (defel -> arg != NULL );
828+ }
803829else
804830elog (ERROR ,"DefineSequence: option \"%s\" not recognized" ,
805831defel -> defname );
@@ -810,7 +836,7 @@ init_params(CreateSeqStmt *seq, Form_pg_sequence new)
810836else if ((new -> increment_by = defGetInt64 (increment_by ))== 0 )
811837elog (ERROR ,"DefineSequence: can't INCREMENT by 0" );
812838
813- if (max_value == (DefElem * )NULL )/* MAXVALUE */
839+ if (max_value == (DefElem * )NULL || ! max_value -> arg )/* MAXVALUE */
814840{
815841if (new -> increment_by > 0 )
816842new -> max_value = SEQ_MAXVALUE ;/* ascending seq */
@@ -820,7 +846,7 @@ init_params(CreateSeqStmt *seq, Form_pg_sequence new)
820846else
821847new -> max_value = defGetInt64 (max_value );
822848
823- if (min_value == (DefElem * )NULL )/* MINVALUE */
849+ if (min_value == (DefElem * )NULL || ! min_value -> arg )/* MINVALUE */
824850{
825851if (new -> increment_by > 0 )
826852new -> min_value = 1 ;/* ascending seq */