• Stephen Frost's avatar
    Fix pg_dump handling of extension config tables · ebd092bc
    Stephen Frost authored
    Since 9.1, we've provided extensions with a way to denote
    "configuration" tables- tables created by an extension which the user
    may modify.  By marking these as "configuration" tables, the extension
    is asking for the data in these tables to be pg_dump'd (tables which
    are not marked in this way are assumed to be entirely handled during
    CREATE EXTENSION and are not included at all in a pg_dump).
    
    Unfortunately, pg_dump neglected to consider foreign key relationships
    between extension configuration tables and therefore could end up
    trying to reload the data in an order which would cause FK violations.
    
    This patch teaches pg_dump about these dependencies, so that the data
    dumped out is done so in the best order possible.  Note that there's no
    way to handle circular dependencies, but those have yet to be seen in
    the wild.
    
    The release notes for this should include a caution to users that
    existing pg_dump-based backups may be invalid due to this issue.  The
    data is all there, but restoring from it will require extracting the
    data for the configuration tables and then loading them in the correct
    order by hand.
    
    Discussed initially back in bug #6738, more recently brought up by
    Gilles Darold, who provided an initial patch which was further reworked
    by Michael Paquier.  Further modifications and documentation updates
    by me.
    
    Back-patch to 9.1 where we added the concept of extension configuration
    tables.
    ebd092bc
pg_dump.c 478 KB