Brief note about sequence cache not being cleared in other backends.
authorBruce Momjian
Thu, 12 Jun 2003 07:49:43 +0000 (07:49 +0000)
committerBruce Momjian
Thu, 12 Jun 2003 07:49:43 +0000 (07:49 +0000)
Actually clear the cache in the backend making the alteration.  This
follows in the footsteps of setval().

Rod Taylor

doc/src/sgml/keywords.sgml
doc/src/sgml/ref/alter_sequence.sgml
doc/src/sgml/ref/create_table.sgml
src/backend/commands/sequence.c

index 783b401e3f20392053e05eceea5af5ec0aad9c81..26764553f874b2b5b8b1ab32f00804c70f32bed8 100644 (file)
@@ -1,4 +1,4 @@
-
+
 
 
  <acronym>SQL</acronym> Key Words
     reserved
     reserved
    
+   
+    DEFAULTS
+    non-reserved
+    
+    
+   
    
     DEFERRABLE
     reserved
     reserved
     reserved
    
+   
+    EXCLUDING
+    non-reserved
+    
+    
+   
    
     EXCLUSIVE
     non-reserved
     reserved
     reserved
    
+   
+    INCLUDING
+    non-reserved
+    
+    
+   
    
     INCREMENT
     non-reserved
index c6c3a7e33c09b79c0ad09d2aec3d954e3908647a..28a81022aabde3164cbb861c4d7e3b3adb6642a2 100644 (file)
@@ -1,5 +1,5 @@
 
 
@@ -236,6 +236,12 @@ ALTER SEQUENCE serial RESTART WITH 105;
    later aborts. This means that aborted transactions may leave unused "holes" in
    the sequence of assigned values. setval operations are never rolled back, either.
   
+  
+   ALTER SEQUENCE 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.
+  
  
 
 
index 9a29b645aae843dda0964acd0acf8fe59c9049a5..2a33de6dfb5e209fc571ce83482f929a7ac959bc 100644 (file)
@@ -1,5 +1,5 @@
 
 
@@ -18,7 +18,8 @@ PostgreSQL documentation
 
 CREATE [ [ GLOBAL | LOCAL ] { TEMPORARY | TEMP } ] TABLE table_name (
     { column_name data_type [ DEFAULT default_expr ] [ column_constraint [, ... ] ]
-    | table_constraint }  [, ... ]
+    | table_constraint
+    | LIKE parent_table [ { INCLUDING | EXCLUDING } DEFAULTS ] }  [, ... ]
 )
 [ INHERITS ( parent_table [, ... ] ) ]
 [ WITH OIDS | WITHOUT OIDS ]
@@ -172,6 +173,26 @@ and table_constraint is:
     
    
 
+   
+    LIKE parent_table [ { INCLUDING | EXCLUDING } DEFAULTS ]
+    
+     
+      The LIKE clause specifies a table from which
+      the new table automatically inherits all column names, their datatypes, and
+      NOT NULL constraints.
+     
+     
+      Unlike INHERITS, 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.
+     
+     
+      Default expressions for the inherited column definitions will only be included if
+      INCLUDING DEFAULTS is specified.  The default is to exclude
+      default expressions.
+    
+   
+
    
     INHERITS ( parent_table [, ... ] )
     
index 308ee21310545f50a69beaecee209caaa0c1d20f..cb4948263083b32ba23d7c423874174327259abc 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * 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)
        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();
 
    /* XLOG stuff */