Tweak CREATE SEQUENCE grammar to be more SQL1999 standards compliant.
authorBruce Momjian
Sun, 10 Nov 2002 00:10:20 +0000 (00:10 +0000)
committerBruce Momjian
Sun, 10 Nov 2002 00:10:20 +0000 (00:10 +0000)
Neil Conway

doc/src/sgml/ref/create_sequence.sgml
src/backend/commands/sequence.c
src/backend/parser/gram.y

index 3db79850c8a04b9ca8299c0af125a2fe77207be3..4e36dfbe77139df9612ea643ccdc38a12be1d6d8 100644 (file)
@@ -1,5 +1,5 @@
 
 
@@ -21,9 +21,9 @@ PostgreSQL documentation
    1999-07-20
   
   
-CREATE [ TEMPORARY | TEMP ] SEQUENCE seqname [ INCREMENT increment ]
+CREATE [ TEMPORARY | TEMP ] SEQUENCE seqname [ INCREMENT [ BY ] increment ]
     [ MINVALUE minvalue ] [ MAXVALUE maxvalue ]
-    [ START start ] [ CACHE cache ] [ CYCLE ]
+    [ START [ WITH ] start ] [ CACHE cache ] [ [ NO ] CYCLE ]
   
   
   
@@ -130,8 +130,8 @@ CREATE [ TEMPORARY | TEMP ] SEQUENCE seqname
       CYCLE
       
        
-   The optional CYCLE keyword may be used to enable the sequence
-   to wrap around when the
+   The optional  keyword may be used to enable
+   the sequence to wrap around when the
    maxvalue or
    minvalue has been
    reached by
@@ -140,11 +140,22 @@ CREATE [ TEMPORARY | TEMP ] SEQUENCE seqname
    minvalue or
    maxvalue,
    respectively.
-   Without CYCLE, after the limit is reached nextval calls
-   will return an error.
        
       
      
+
+    
+     NO CYCLE
+     
+      
+   If the optional  keyword is specified, any
+   calls to nextval after the sequence has reached
+   its maximum value will return an error.  If neither
+    or  are specified,
+    is the default.
+      
+     
+   
     
    
   
index f6ace0d2d9342789afb64162fcd2bc8775848944..31fb270c63e6f49256d0232f43f289c23b73711d 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *   $Header: /cvsroot/pgsql/src/backend/commands/sequence.c,v 1.88 2002/09/22 19:42:50 tgl Exp $
+ *   $Header: /cvsroot/pgsql/src/backend/commands/sequence.c,v 1.89 2002/11/10 00:10:20 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -798,11 +798,7 @@ init_params(CreateSeqStmt *seq, Form_pg_sequence new)
        else if (strcmp(defel->defname, "cache") == 0)
            cache_value = defel;
        else if (strcmp(defel->defname, "cycle") == 0)
-       {
-           if (defel->arg != (Node *) NULL)
-               elog(ERROR, "DefineSequence: CYCLE ??");
-           new->is_cycled = true;
-       }
+           new->is_cycled = (defel->arg != NULL);
        else
            elog(ERROR, "DefineSequence: option \"%s\" not recognized",
                 defel->defname);
index 5fe83ac41db061a531aaf7c0d1daa705d7d5a29b..1ce4cc1bfde9c58d9af79c5c9de852a0d6effb41 100644 (file)
@@ -11,7 +11,7 @@
  *
  *
  * IDENTIFICATION
- *   $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 2.374 2002/11/09 23:56:39 momjian Exp $
+ *   $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 2.375 2002/11/10 00:10:20 momjian Exp $
  *
  * HISTORY
  *   AUTHOR            DATE            MAJOR EVENT
@@ -1893,11 +1893,15 @@ OptSeqElem: CACHE NumericOnly
                }
            | CYCLE
                {
-                   $$ = makeDefElem("cycle", (Node *)NULL);
+                   $$ = makeDefElem("cycle", (Node *)true);
                }
-           | INCREMENT NumericOnly
+           | NO CYCLE
                {
-                   $$ = makeDefElem("increment", (Node *)$2);
+                   $$ = makeDefElem("cycle", (Node *)false);
+               }
+           | INCREMENT opt_by NumericOnly
+               {
+                   $$ = makeDefElem("increment", (Node *)$3);
                }
            | MAXVALUE NumericOnly
                {
@@ -1907,12 +1911,16 @@ OptSeqElem: CACHE NumericOnly
                {
                    $$ = makeDefElem("minvalue", (Node *)$2);
                }
-           | START NumericOnly
+           | START opt_with NumericOnly
                {
-                   $$ = makeDefElem("start", (Node *)$2);
+                   $$ = makeDefElem("start", (Node *)$3);
                }
        ;
 
+opt_by:        BY              {}
+           | /* empty */   {}
+     ;
+
 NumericOnly:
            FloatOnly                               { $$ = $1; }
            | IntegerOnly                           { $$ = $1; }