postgresql/src/bin/pg_dump
Michael Paquier f46bee346c 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 a45c78e328 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 374c7a2290, 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
2024-04-22 15:15:36 +09:00
..
po Update copyright for 2024 2024-01-03 20:49:05 -05:00
t Fix dumps of partitioned tables with table AMs 2024-04-22 15:15:36 +09:00
.gitignore Clean up after pg_dump test runs. 2016-05-06 22:28:01 -04:00
Makefile Update copyright for 2024 2024-01-03 20:49:05 -05:00
common.c Rearrange pg_dump's handling of large objects for better efficiency. 2024-04-01 16:25:56 -04:00
compress_gzip.c Use printf's %m format instead of strerror(errno) in more places 2024-03-12 10:02:54 +09:00
compress_gzip.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
compress_io.c Update copyright for 2024 2024-01-03 20:49:05 -05:00
compress_io.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
compress_lz4.c Make the order of the header file includes consistent 2024-03-13 15:07:00 +01:00
compress_lz4.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
compress_none.c Use printf's %m format instead of strerror(errno) in more places 2024-03-12 10:02:54 +09:00
compress_none.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
compress_zstd.c Make the order of the header file includes consistent 2024-03-13 15:07:00 +01:00
compress_zstd.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
dumputils.c Reintroduce MAINTAIN privilege and pg_maintain predefined role. 2024-03-13 14:49:26 -05:00
dumputils.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
filter.c Update copyright for 2024 2024-01-03 20:49:05 -05:00
filter.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
meson.build Update copyright for 2024 2024-01-03 20:49:05 -05:00
nls.mk Add missing file to nls Makefile 2023-11-30 10:56:51 +01:00
parallel.c Rename static function to avoid conflicting names 2024-02-07 22:16:21 +01:00
parallel.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
pg_backup.h Invent --transaction-size option for pg_restore. 2024-04-01 16:46:24 -04:00
pg_backup_archiver.c Fix dumps of partitioned tables with table AMs 2024-04-22 15:15:36 +09:00
pg_backup_archiver.h Fix dumps of partitioned tables with table AMs 2024-04-22 15:15:36 +09:00
pg_backup_custom.c Rearrange pg_dump's handling of large objects for better efficiency. 2024-04-01 16:25:56 -04:00
pg_backup_db.c Invent --transaction-size option for pg_restore. 2024-04-01 16:46:24 -04:00
pg_backup_db.h Revert "pg_dump: Lock all relations, not just plain tables". 2020-11-06 15:48:04 -05:00
pg_backup_directory.c Rearrange pg_dump's handling of large objects for better efficiency. 2024-04-01 16:25:56 -04:00
pg_backup_null.c Rearrange pg_dump's handling of large objects for better efficiency. 2024-04-01 16:25:56 -04:00
pg_backup_tar.c Rearrange pg_dump's handling of large objects for better efficiency. 2024-04-01 16:25:56 -04:00
pg_backup_tar.h Fix tar files emitted by pg_dump and pg_basebackup to be POSIX conformant. 2012-09-28 15:19:15 -04:00
pg_backup_utils.c Update copyright for 2024 2024-01-03 20:49:05 -05:00
pg_backup_utils.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
pg_dump.c Fix dumps of partitioned tables with table AMs 2024-04-22 15:15:36 +09:00
pg_dump.h Rearrange pg_dump's handling of large objects for better efficiency. 2024-04-01 16:25:56 -04:00
pg_dump_sort.c Revert indexed and enlargable binary heap implementation. 2024-04-11 17:18:05 +09:00
pg_dumpall.c Convert uses of hash_string_pointer to fasthash equivalent 2024-04-06 12:20:40 +07:00
pg_restore.c Invent --transaction-size option for pg_restore. 2024-04-01 16:46:24 -04:00