Commit e9cda08b authored by Bruce Momjian's avatar Bruce Momjian

Brief note about sequence cache not being cleared in other backends.

Actually clear the cache in the backend making the alteration.  This
follows in the footsteps of setval().

Rod Taylor
parent b4cea00a
<!-- $Header: /cvsroot/pgsql/doc/src/sgml/keywords.sgml,v 2.8 2002/11/11 20:14:03 petere Exp $ --> <!-- $Header: /cvsroot/pgsql/doc/src/sgml/keywords.sgml,v 2.9 2003/06/12 07:49:43 momjian Exp $ -->
<appendix id="sql-keywords-appendix"> <appendix id="sql-keywords-appendix">
<title><acronym>SQL</acronym> Key Words</title> <title><acronym>SQL</acronym> Key Words</title>
...@@ -872,6 +872,12 @@ ...@@ -872,6 +872,12 @@
<entry>reserved</entry> <entry>reserved</entry>
<entry>reserved</entry> <entry>reserved</entry>
</row> </row>
<row>
<entry><token>DEFAULTS</token></entry>
<entry>non-reserved</entry>
<entry></entry>
<entry></entry>
</row>
<row> <row>
<entry><token>DEFERRABLE</token></entry> <entry><token>DEFERRABLE</token></entry>
<entry>reserved</entry> <entry>reserved</entry>
...@@ -1100,6 +1106,12 @@ ...@@ -1100,6 +1106,12 @@
<entry>reserved</entry> <entry>reserved</entry>
<entry>reserved</entry> <entry>reserved</entry>
</row> </row>
<row>
<entry><token>EXCLUDING</token></entry>
<entry>non-reserved</entry>
<entry></entry>
<entry></entry>
</row>
<row> <row>
<entry><token>EXCLUSIVE</token></entry> <entry><token>EXCLUSIVE</token></entry>
<entry>non-reserved</entry> <entry>non-reserved</entry>
...@@ -1394,6 +1406,12 @@ ...@@ -1394,6 +1406,12 @@
<entry>reserved</entry> <entry>reserved</entry>
<entry>reserved</entry> <entry>reserved</entry>
</row> </row>
<row>
<entry><token>INCLUDING</token></entry>
<entry>non-reserved</entry>
<entry></entry>
<entry></entry>
</row>
<row> <row>
<entry><token>INCREMENT</token></entry> <entry><token>INCREMENT</token></entry>
<entry>non-reserved</entry> <entry>non-reserved</entry>
......
<!-- <!--
$Header: /cvsroot/pgsql/doc/src/sgml/ref/alter_sequence.sgml,v 1.1 2003/03/20 07:02:07 momjian Exp $ $Header: /cvsroot/pgsql/doc/src/sgml/ref/alter_sequence.sgml,v 1.2 2003/06/12 07:49:43 momjian Exp $
PostgreSQL documentation PostgreSQL documentation
--> -->
...@@ -236,6 +236,12 @@ ALTER SEQUENCE serial RESTART WITH 105; ...@@ -236,6 +236,12 @@ ALTER SEQUENCE serial RESTART WITH 105;
later aborts. This means that aborted transactions may leave unused "holes" in later aborts. This means that aborted transactions may leave unused "holes" in
the sequence of assigned values. setval operations are never rolled back, either. the sequence of assigned values. setval operations are never rolled back, either.
</para> </para>
<para>
<command>ALTER SEQUENCE</command> will not immediately affect backends, other than the
current one, which have cached sequence values. They must use up all cached values
prior to noticing the changed sequence parameters. The current backend will be
immediatly affected.
</para>
</refsect1> </refsect1>
......
<!-- <!--
$Header: /cvsroot/pgsql/doc/src/sgml/ref/create_table.sgml,v 1.68 2003/05/04 00:03:55 tgl Exp $ $Header: /cvsroot/pgsql/doc/src/sgml/ref/create_table.sgml,v 1.69 2003/06/12 07:49:43 momjian Exp $
PostgreSQL documentation PostgreSQL documentation
--> -->
...@@ -18,7 +18,8 @@ PostgreSQL documentation ...@@ -18,7 +18,8 @@ PostgreSQL documentation
<synopsis> <synopsis>
CREATE [ [ GLOBAL | LOCAL ] { TEMPORARY | TEMP } ] TABLE <replaceable class="PARAMETER">table_name</replaceable> ( CREATE [ [ GLOBAL | LOCAL ] { TEMPORARY | TEMP } ] TABLE <replaceable class="PARAMETER">table_name</replaceable> (
{ <replaceable class="PARAMETER">column_name</replaceable> <replaceable class="PARAMETER">data_type</replaceable> [ DEFAULT <replaceable>default_expr</> ] [ <replaceable class="PARAMETER">column_constraint</replaceable> [, ... ] ] { <replaceable class="PARAMETER">column_name</replaceable> <replaceable class="PARAMETER">data_type</replaceable> [ DEFAULT <replaceable>default_expr</> ] [ <replaceable class="PARAMETER">column_constraint</replaceable> [, ... ] ]
| <replaceable>table_constraint</replaceable> } [, ... ] | <replaceable>table_constraint</replaceable>
| LIKE <replaceable>parent_table</replaceable> [ { INCLUDING | EXCLUDING } DEFAULTS ] } [, ... ]
) )
[ INHERITS ( <replaceable>parent_table</replaceable> [, ... ] ) ] [ INHERITS ( <replaceable>parent_table</replaceable> [, ... ] ) ]
[ WITH OIDS | WITHOUT OIDS ] [ WITH OIDS | WITHOUT OIDS ]
...@@ -172,6 +173,26 @@ and <replaceable class="PARAMETER">table_constraint</replaceable> is: ...@@ -172,6 +173,26 @@ and <replaceable class="PARAMETER">table_constraint</replaceable> is:
</listitem> </listitem>
</varlistentry> </varlistentry>
<varlistentry>
<term><literal>LIKE <replaceable>parent_table</replaceable> [ { INCLUDING | EXCLUDING } DEFAULTS ]</literal></term>
<listitem>
<para>
The <literal>LIKE</literal> clause specifies a table from which
the new table automatically inherits all column names, their datatypes, and
<literal>NOT NULL</literal> constraints.
</para>
<para>
Unlike <literal>INHERITS</literal>, the new table and inherited table
are complete decoupled after creation has been completed. Data inserted
into the new table will not be reflected into the parent table.
</para>
<para>
Default expressions for the inherited column definitions will only be included if
<literal>INCLUDING DEFAULTS</literal> is specified. The default is to exclude
default expressions.
</listitem>
</varlistentry>
<varlistentry> <varlistentry>
<term><literal>INHERITS ( <replaceable>parent_table</replaceable> [, ... ] )</literal></term> <term><literal>INHERITS ( <replaceable>parent_table</replaceable> [, ... ] )</literal></term>
<listitem> <listitem>
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/commands/sequence.c,v 1.95 2003/03/21 03:55:21 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/commands/sequence.c,v 1.96 2003/06/12 07:49:43 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -345,6 +345,11 @@ AlterSequence(AlterSeqStmt *stmt) ...@@ -345,6 +345,11 @@ AlterSequence(AlterSeqStmt *stmt)
seq->log_cnt = 1; seq->log_cnt = 1;
} }
/* save info in local cache */
elm->last = new.last_value; /* last returned number */
elm->cached = new.last_value; /* last cached number (forget cached
* values) */
START_CRIT_SECTION(); START_CRIT_SECTION();
/* XLOG stuff */ /* XLOG stuff */
......
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