mirror of
https://github.com/postgres/postgres.git
synced 2025-11-06 07:49:08 +03:00
Fix all known problems with pg_dump's handling of serial sequences
by abandoning the idea that it should say SERIAL in the dump. Instead, dump serial sequences and column defaults just like regular ones. Add a new backend command ALTER SEQUENCE OWNED BY to let pg_dump recreate the sequence-to-column dependency that was formerly created "behind the scenes" by SERIAL. This restores SERIAL to being truly "just a macro" consisting of component operations that can be stated explicitly in SQL. Furthermore, the new command allows sequence ownership to be reassigned, so that old mistakes can be cleaned up. Also, downgrade the OWNED-BY dependency from INTERNAL to AUTO, since there is no longer any very compelling argument why the sequence couldn't be dropped while keeping the column. (This forces initdb, to be sure the right kinds of dependencies are in there.) Along the way, add checks to prevent ALTER OWNER or SET SCHEMA on an owned sequence; you can now only do this indirectly by changing the owning table's owner or schema. This is an oversight in previous releases, but probably not worth back-patching.
This commit is contained in:
@@ -7,7 +7,7 @@
|
||||
* Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* $PostgreSQL: pgsql/src/include/nodes/parsenodes.h,v 1.323 2006/08/12 20:05:56 tgl Exp $
|
||||
* $PostgreSQL: pgsql/src/include/nodes/parsenodes.h,v 1.324 2006/08/21 00:57:26 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -393,10 +393,6 @@ typedef struct RangeFunction
|
||||
* parsetree produced by gram.y, but transformCreateStmt will remove
|
||||
* the item and set raw_default instead. CONSTR_DEFAULT items
|
||||
* should not appear in any subsequent processing.
|
||||
*
|
||||
* The "support" field, if not null, denotes a supporting relation that
|
||||
* should be linked by an internal dependency to the column. Currently
|
||||
* this is only used to link a SERIAL column's sequence to the column.
|
||||
*/
|
||||
typedef struct ColumnDef
|
||||
{
|
||||
@@ -409,7 +405,6 @@ typedef struct ColumnDef
|
||||
Node *raw_default; /* default value (untransformed parse tree) */
|
||||
char *cooked_default; /* nodeToString representation */
|
||||
List *constraints; /* other constraints on column */
|
||||
RangeVar *support; /* supporting relation, if any */
|
||||
} ColumnDef;
|
||||
|
||||
/*
|
||||
|
||||
Reference in New Issue
Block a user