Commit 3eabc449 authored by Bruce Momjian's avatar Bruce Momjian

Tweak CREATE SEQUENCE grammar to be more SQL1999 standards compliant.

Neil Conway
parent ebb53183
<!-- <!--
$Header: /cvsroot/pgsql/doc/src/sgml/ref/create_sequence.sgml,v 1.28 2002/05/18 15:44:47 petere Exp $ $Header: /cvsroot/pgsql/doc/src/sgml/ref/create_sequence.sgml,v 1.29 2002/11/10 00:10:20 momjian Exp $
PostgreSQL documentation PostgreSQL documentation
--> -->
...@@ -21,9 +21,9 @@ PostgreSQL documentation ...@@ -21,9 +21,9 @@ PostgreSQL documentation
<date>1999-07-20</date> <date>1999-07-20</date>
</refsynopsisdivinfo> </refsynopsisdivinfo>
<synopsis> <synopsis>
CREATE [ TEMPORARY | TEMP ] SEQUENCE <replaceable class="parameter">seqname</replaceable> [ INCREMENT <replaceable class="parameter">increment</replaceable> ] CREATE [ TEMPORARY | TEMP ] SEQUENCE <replaceable class="parameter">seqname</replaceable> [ INCREMENT [ BY ] <replaceable class="parameter">increment</replaceable> ]
[ MINVALUE <replaceable class="parameter">minvalue</replaceable> ] [ MAXVALUE <replaceable class="parameter">maxvalue</replaceable> ] [ MINVALUE <replaceable class="parameter">minvalue</replaceable> ] [ MAXVALUE <replaceable class="parameter">maxvalue</replaceable> ]
[ START <replaceable class="parameter">start</replaceable> ] [ CACHE <replaceable class="parameter">cache</replaceable> ] [ CYCLE ] [ START [ WITH ] <replaceable class="parameter">start</replaceable> ] [ CACHE <replaceable class="parameter">cache</replaceable> ] [ [ NO ] CYCLE ]
</synopsis> </synopsis>
<refsect2 id="R2-SQL-CREATESEQUENCE-1"> <refsect2 id="R2-SQL-CREATESEQUENCE-1">
...@@ -130,8 +130,8 @@ CREATE [ TEMPORARY | TEMP ] SEQUENCE <replaceable class="parameter">seqname</rep ...@@ -130,8 +130,8 @@ CREATE [ TEMPORARY | TEMP ] SEQUENCE <replaceable class="parameter">seqname</rep
<term>CYCLE</term> <term>CYCLE</term>
<listitem> <listitem>
<para> <para>
The optional CYCLE keyword may be used to enable the sequence The optional <option>CYCLE</option> keyword may be used to enable
to wrap around when the the sequence to wrap around when the
<replaceable class="parameter">maxvalue</replaceable> or <replaceable class="parameter">maxvalue</replaceable> or
<replaceable class="parameter">minvalue</replaceable> has been <replaceable class="parameter">minvalue</replaceable> has been
reached by reached by
...@@ -140,11 +140,22 @@ CREATE [ TEMPORARY | TEMP ] SEQUENCE <replaceable class="parameter">seqname</rep ...@@ -140,11 +140,22 @@ CREATE [ TEMPORARY | TEMP ] SEQUENCE <replaceable class="parameter">seqname</rep
<replaceable class="parameter">minvalue</replaceable> or <replaceable class="parameter">minvalue</replaceable> or
<replaceable class="parameter">maxvalue</replaceable>, <replaceable class="parameter">maxvalue</replaceable>,
respectively. respectively.
Without CYCLE, after the limit is reached <function>nextval</> calls
will return an error.
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
<varlistentry>
<term>NO CYCLE</term>
<listitem>
<para>
If the optional <option>NO CYCLE</option> keyword is specified, any
calls to <function>nextval</function> after the sequence has reached
its maximum value will return an error. If neither
<option>CYCLE</option> or <option>NO CYCLE</option> are specified,
<option>NO CYCLE</option> is the default.
</para>
</listitem>
</varlistentry>
</variablelist> </variablelist>
</para> </para>
</refsect2> </refsect2>
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * 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) ...@@ -798,11 +798,7 @@ init_params(CreateSeqStmt *seq, Form_pg_sequence new)
else if (strcmp(defel->defname, "cache") == 0) else if (strcmp(defel->defname, "cache") == 0)
cache_value = defel; cache_value = defel;
else if (strcmp(defel->defname, "cycle") == 0) else if (strcmp(defel->defname, "cycle") == 0)
{ new->is_cycled = (defel->arg != NULL);
if (defel->arg != (Node *) NULL)
elog(ERROR, "DefineSequence: CYCLE ??");
new->is_cycled = true;
}
else else
elog(ERROR, "DefineSequence: option \"%s\" not recognized", elog(ERROR, "DefineSequence: option \"%s\" not recognized",
defel->defname); defel->defname);
......
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
* *
* *
* IDENTIFICATION * 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 * HISTORY
* AUTHOR DATE MAJOR EVENT * AUTHOR DATE MAJOR EVENT
...@@ -1893,11 +1893,15 @@ OptSeqElem: CACHE NumericOnly ...@@ -1893,11 +1893,15 @@ OptSeqElem: CACHE NumericOnly
} }
| CYCLE | 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 | MAXVALUE NumericOnly
{ {
...@@ -1907,12 +1911,16 @@ OptSeqElem: CACHE NumericOnly ...@@ -1907,12 +1911,16 @@ OptSeqElem: CACHE NumericOnly
{ {
$$ = makeDefElem("minvalue", (Node *)$2); $$ = makeDefElem("minvalue", (Node *)$2);
} }
| START NumericOnly | START opt_with NumericOnly
{ {
$$ = makeDefElem("start", (Node *)$2); $$ = makeDefElem("start", (Node *)$3);
} }
; ;
opt_by: BY {}
| /* empty */ {}
;
NumericOnly: NumericOnly:
FloatOnly { $$ = $1; } FloatOnly { $$ = $1; }
| IntegerOnly { $$ = $1; } | IntegerOnly { $$ = $1; }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment