mirror of
https://github.com/postgres/postgres.git
synced 2025-06-16 06:01:02 +03:00
Fix pg_dump handling of extension config tables
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.
This commit is contained in:
@ -721,6 +721,17 @@ SELECT pg_catalog.pg_extension_config_dump('my_config', 'WHERE NOT standard_entr
|
||||
a table as no longer a configuration table is to dissociate it from the
|
||||
extension with <command>ALTER EXTENSION ... DROP TABLE</>.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
Note that foreign key relationships between these tables will dictate the
|
||||
order in which the tables are dumped out by pg_dump. Specifically, pg_dump
|
||||
will attempt to dump the referenced-by table before the referencing table.
|
||||
As the foreign key relationships are set up at CREATE EXTENSION time (prior
|
||||
to data being loaded into the tables) circular dependencies are not
|
||||
supported. When circular dependencies exist, the data will still be dumped
|
||||
out but the dump will not be able to be restored directly and user
|
||||
intervention will be required.
|
||||
</para>
|
||||
</sect2>
|
||||
|
||||
<sect2>
|
||||
|
Reference in New Issue
Block a user