pgsql: Fix dumps of partitioned tables with table AMs

Поиск
Список
Период
Сортировка
От Michael Paquier
Тема pgsql: Fix dumps of partitioned tables with table AMs
Дата
Msg-id E1rymyz-003HYt-Rj@gemulon.postgresql.org
обсуждение исходный текст
Список pgsql-committers
Fix dumps of partitioned tables with table AMs

pg_dump/restore failed to properly set the table access method for
partitioned tables, as it relies on SET queries that would change
default_table_access_method.  However, SET affects only tables and
materialized views, not partitioned tables which would always be
restored with their pg_class.relam set to 0, losing their table AM set
by either a CREATE TABLE .. USING or by a ALTER TABLE .. SET ACCESS
METHOD.

Appending a USING clause to the definition of CREATE TABLE is not
possible as users may specify --no-table-access-method at restore or for
a dump, meaning that the table AM portions may have to be skipped.
Rather than SET, the solution used by this commit is to generate an
extra ALTER TABLE .. SET ACCESS METHOD when restoring a partitioned
table, based on the table AM set in its TOC entry.  The choice of using
a SET query or an ALTER TABLE query for a relation requires the addition
of the relkind to the TOC entry to be able to choose between one or the
other.  Note that using ALTER TABLE SET ACCESS METHOD on a relation with
physical storage would require a full rewrite, which would be costly for
one.  This also creates problems with binary upgrades where the rewrite
would not be able to keep the OID of the relation consistent across the
upgrade.

This commit would normally require a protocol bump, but a45c78e3284b has
already done one for this release cycle.

Regression tests are adjusted with the new expected output, with some
tweaks for the table AMs of the partitions to make the output more
readable.

Issue introduced by 374c7a229042, that has added support for table AMs
in partitioned tables.

Author: Michael Paquier
Reviewed-by: Álvaro Herrera
Discussion: https://postgr.es/m/Zh4JLSvvtQgBJZkZ@paquier.xyz

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/f46bee346c3b6aab0a0f3f39dc734732b79ce1ed

Modified Files
--------------
src/bin/pg_dump/pg_backup_archiver.c | 70 ++++++++++++++++++++++++++++++++++--
src/bin/pg_dump/pg_backup_archiver.h |  5 ++-
src/bin/pg_dump/pg_dump.c            |  1 +
src/bin/pg_dump/t/002_pg_dump.pl     | 12 +++----
4 files changed, 79 insertions(+), 9 deletions(-)


В списке pgsql-committers по дате отправления:

Предыдущее
От: Peter Geoghegan
Дата:
Сообщение: pgsql: Remove overzealous array element type assertion.
Следующее
От: Peter Eisentraut
Дата:
Сообщение: pgsql: Update src/common/unicode/.gitignore