]> git.ipfire.org Git - thirdparty/postgresql.git/commit
Fix all known problems with pg_dump's handling of serial sequences
authorTom Lane <tgl@sss.pgh.pa.us>
Mon, 21 Aug 2006 00:57:26 +0000 (00:57 +0000)
committerTom Lane <tgl@sss.pgh.pa.us>
Mon, 21 Aug 2006 00:57:26 +0000 (00:57 +0000)
commit2b2a50722cb1863147b4a86b3db80553f989a14c
tree46bf05accbbb3e8dec43cfc0e55c99e4615ee337
parentdf18c51f2955f6dc30027c91546a607abd699c40
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.
29 files changed:
doc/src/sgml/datatype.sgml
doc/src/sgml/func.sgml
doc/src/sgml/ref/alter_sequence.sgml
doc/src/sgml/ref/alter_table.sgml
doc/src/sgml/ref/create_sequence.sgml
doc/src/sgml/ref/drop_sequence.sgml
src/backend/catalog/pg_depend.c
src/backend/catalog/pg_shdepend.c
src/backend/commands/sequence.c
src/backend/commands/tablecmds.c
src/backend/commands/view.c
src/backend/nodes/copyfuncs.c
src/backend/nodes/equalfuncs.c
src/backend/nodes/makefuncs.c
src/backend/nodes/outfuncs.c
src/backend/parser/analyze.c
src/backend/parser/gram.y
src/backend/utils/adt/ruleutils.c
src/bin/pg_dump/pg_dump.c
src/bin/pg_dump/pg_dump.h
src/include/catalog/catversion.h
src/include/catalog/dependency.h
src/include/nodes/makefuncs.h
src/include/nodes/parsenodes.h
src/test/regress/expected/alter_table.out
src/test/regress/expected/dependency.out
src/test/regress/expected/namespace.out
src/test/regress/expected/sequence.out
src/test/regress/sql/dependency.sql