• Tom Lane's avatar
    Fix all known problems with pg_dump's handling of serial sequences · 2b2a5072
    Tom Lane authored
    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.
    2b2a5072
tablecmds.c 200 KB