1
0
mirror of https://github.com/postgres/postgres.git synced 2025-10-16 17:07:43 +03:00

Add support for --no-table-access-method in pg_{dump,dumpall,restore}

The logic is similar to default_tablespace in some ways, so as no SET
queries on default_table_access_method are generated before dumping or
restoring an object (table or materialized view support table AMs) when
specifying this new option.

This option is useful to enforce the use of a default access method even
if some tables included in a dump use an AM different than the system's
default.

There are already two cases in the TAP tests of pg_dump with a table and
a materialized view that use a non-default table AM, and these are
extended that the new option does not generate SET clauses on
default_table_access_method.

Author: Justin Pryzby
Discussion: https://postgr.es/m/20211207153930.GR17618@telsasoft.com
This commit is contained in:
Michael Paquier
2022-01-17 14:51:46 +09:00
parent f47ed79cc8
commit 2158628864
9 changed files with 79 additions and 2 deletions

View File

@@ -194,6 +194,7 @@ dumpOptionsFromRestoreOptions(RestoreOptions *ropt)
dopt->outputSuperuser = ropt->superuser;
dopt->outputCreateDB = ropt->createDB;
dopt->outputNoOwner = ropt->noOwner;
dopt->outputNoTableAm = ropt->noTableAm;
dopt->outputNoTablespaces = ropt->noTablespace;
dopt->disable_triggers = ropt->disable_triggers;
dopt->use_setsessauth = ropt->use_setsessauth;
@@ -3171,6 +3172,11 @@ _reconnectToDB(ArchiveHandle *AH, const char *dbname)
if (AH->currSchema)
free(AH->currSchema);
AH->currSchema = NULL;
if (AH->currTableAm)
free(AH->currTableAm);
AH->currTableAm = NULL;
if (AH->currTablespace)
free(AH->currTablespace);
AH->currTablespace = NULL;
@@ -3340,10 +3346,15 @@ _selectTablespace(ArchiveHandle *AH, const char *tablespace)
static void
_selectTableAccessMethod(ArchiveHandle *AH, const char *tableam)
{
RestoreOptions *ropt = AH->public.ropt;
PQExpBuffer cmd;
const char *want,
*have;
/* do nothing in --no-table-access-method mode */
if (ropt->noTableAm)
return;
have = AH->currTableAm;
want = tableam;
@@ -4770,6 +4781,7 @@ CloneArchive(ArchiveHandle *AH)
clone->connCancel = NULL;
clone->currUser = NULL;
clone->currSchema = NULL;
clone->currTableAm = NULL;
clone->currTablespace = NULL;
/* savedPassword must be local in case we change it while connecting */