pg.ddx.io pgsql-hackers@postgresql.org mailing list archive
help / color / mirror / Atom feedpg_dump/restore --no-tableam
9+ messages / 3 participants
[nested] [flat]
Commits from this thread:
2022-01-17 ca86a63d20 Fix typo in pg_dumpall.c
2022-01-17 2158628864 Add support for --no-table-access-method in pg_{dump,dumpall,restore}
* pg_dump/restore --no-tableam
@ 2021-12-07 15:39 Justin Pryzby <pryzby@telsasoft.com>
0 siblings, 1 reply; 9+ messages in thread
From: Justin Pryzby @ 2021-12-07 15:39 UTC (permalink / raw)
To: pgsql-hackers; +Cc: Andres Freund <andres@anarazel.de>
I first suggested this a couple years ago.
Is it desirable to implement in pg_dump and pg_restore ?
It'd be just like --tablespace.
On Tue, Jan 28, 2020 at 07:33:17AM -0600, Justin Pryzby wrote:
> I made these casual comments. If there's any agreement on their merit, it'd be
> nice to implement at least the first for v13.
>
> In <20190818193533.GL11185@telsasoft.com>, I wrote:
> > . What do you think about pg_restore --no-tableam; similar to
> > --no-tablespaces, it would allow restoring a table to a different AM:
> > PGOPTIONS='-c default_table_access_method=zedstore' pg_restore --no-tableam ./pg_dump.dat -d postgres
> > Otherwise, the dump says "SET default_table_access_method=heap", which
> > overrides any value from PGOPTIONS and precludes restoring to new AM.
>
> That appears to be a trivial variation on no-tablespace:
>
> /* do nothing in --no-tablespaces mode */
> if (ropt->noTablespace)
> return;
...
^ permalink raw reply [nested|flat] 9+ messages in thread
* Re: pg_dump/restore --no-tableam
@ 2022-01-03 21:44 Justin Pryzby <pryzby@telsasoft.com>
parent: Justin Pryzby <pryzby@telsasoft.com>
0 siblings, 3 replies; 9+ messages in thread
From: Justin Pryzby @ 2022-01-03 21:44 UTC (permalink / raw)
To: pgsql-hackers; +Cc: Andres Freund <andres@anarazel.de>
@cfbot: rebased
Attachments:
0001-Add-pg_dump-restore-no-table-am.patch (text/x-diff, 11.0K) download
From 69ae2ed5d00a97d351e1f6c45a9e406f33032898 Mon Sep 17 00:00:00 2001
From: Justin Pryzby <pryzbyj@telsasoft.com>
Date: Sun, 7 Mar 2021 19:35:37 -0600
Subject: [PATCH] Add pg_dump/restore --no-table-am..
This was for some reason omitted from 3b925e905.
---
doc/src/sgml/ref/pg_dump.sgml | 18 +++++++++++++++
doc/src/sgml/ref/pg_restore.sgml | 11 +++++++++
src/bin/pg_dump/pg_backup.h | 2 ++
src/bin/pg_dump/pg_backup_archiver.c | 12 ++++++++++
src/bin/pg_dump/pg_dump.c | 3 +++
src/bin/pg_dump/pg_restore.c | 4 ++++
src/bin/pg_dump/t/002_pg_dump.pl | 34 ++++++++++++++++++----------
7 files changed, 72 insertions(+), 12 deletions(-)
diff --git a/doc/src/sgml/ref/pg_dump.sgml b/doc/src/sgml/ref/pg_dump.sgml
index 0e1cfe0f8d6..edfeab50b8e 100644
--- a/doc/src/sgml/ref/pg_dump.sgml
+++ b/doc/src/sgml/ref/pg_dump.sgml
@@ -931,6 +931,24 @@ PostgreSQL documentation
</listitem>
</varlistentry>
+ <varlistentry>
+ <varlistentry>
+ <term><option>--no-table-am</option></term>
+ <listitem>
+ <para>
+ Do not output commands to select table access methods.
+ With this option, all objects will be created with whichever
+ table access method is the default during restore.
+ </para>
+
+ <para>
+ This option is ignored when emitting an archive (non-text) output
+ file. For the archive formats, you can specify the option when you
+ call <command>pg_restore</command>.
+ </para>
+ </listitem>
+ </varlistentry>
+
<varlistentry>
<term><option>--no-tablespaces</option></term>
<listitem>
diff --git a/doc/src/sgml/ref/pg_restore.sgml b/doc/src/sgml/ref/pg_restore.sgml
index 93ea937ac8e..a68f3a85b7e 100644
--- a/doc/src/sgml/ref/pg_restore.sgml
+++ b/doc/src/sgml/ref/pg_restore.sgml
@@ -649,6 +649,17 @@ PostgreSQL documentation
</listitem>
</varlistentry>
+ <varlistentry>
+ <term><option>--no-table-am</option></term>
+ <listitem>
+ <para>
+ Do not output commands to select table access methods.
+ With this option, all objects will be created with whichever
+ access method is the default during restore.
+ </para>
+ </listitem>
+ </varlistentry>
+
<varlistentry>
<term><option>--no-tablespaces</option></term>
<listitem>
diff --git a/src/bin/pg_dump/pg_backup.h b/src/bin/pg_dump/pg_backup.h
index 753252e05e0..47741ad6406 100644
--- a/src/bin/pg_dump/pg_backup.h
+++ b/src/bin/pg_dump/pg_backup.h
@@ -93,6 +93,7 @@ typedef struct _restoreOptions
{
int createDB; /* Issue commands to create the database */
int noOwner; /* Don't try to match original object owner */
+ int noTableAm; /* Don't issue tableAM-related commands */
int noTablespace; /* Don't issue tablespace-related commands */
int disable_triggers; /* disable triggers during data-only
* restore */
@@ -179,6 +180,7 @@ typedef struct _dumpOptions
int no_unlogged_table_data;
int serializable_deferrable;
int disable_triggers;
+ int outputNoTableAm;
int outputNoTablespaces;
int use_setsessauth;
int enable_row_security;
diff --git a/src/bin/pg_dump/pg_backup_archiver.c b/src/bin/pg_dump/pg_backup_archiver.c
index 8903a694ae9..0f62beac0fc 100644
--- a/src/bin/pg_dump/pg_backup_archiver.c
+++ b/src/bin/pg_dump/pg_backup_archiver.c
@@ -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-am 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 */
diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c
index 7af6dfa5759..532e721a695 100644
--- a/src/bin/pg_dump/pg_dump.c
+++ b/src/bin/pg_dump/pg_dump.c
@@ -389,6 +389,7 @@ main(int argc, char **argv)
{"if-exists", no_argument, &dopt.if_exists, 1},
{"inserts", no_argument, NULL, 9},
{"lock-wait-timeout", required_argument, NULL, 2},
+ {"no-table-am", no_argument, &dopt.outputNoTableAm, 1},
{"no-tablespaces", no_argument, &dopt.outputNoTablespaces, 1},
{"quote-all-identifiers", no_argument, "e_all_identifiers, 1},
{"load-via-partition-root", no_argument, &dopt.load_via_partition_root, 1},
@@ -933,6 +934,7 @@ main(int argc, char **argv)
ropt->superuser = dopt.outputSuperuser;
ropt->createDB = dopt.outputCreateDB;
ropt->noOwner = dopt.outputNoOwner;
+ ropt->noTableAm = dopt.outputNoTableAm;
ropt->noTablespace = dopt.outputNoTablespaces;
ropt->disable_triggers = dopt.disable_triggers;
ropt->use_setsessauth = dopt.use_setsessauth;
@@ -1038,6 +1040,7 @@ help(const char *progname)
printf(_(" --no-publications do not dump publications\n"));
printf(_(" --no-security-labels do not dump security label assignments\n"));
printf(_(" --no-subscriptions do not dump subscriptions\n"));
+ printf(_(" --no-table-am do not dump table access methods\n"));
printf(_(" --no-tablespaces do not dump tablespace assignments\n"));
printf(_(" --no-toast-compression do not dump TOAST compression methods\n"));
printf(_(" --no-unlogged-table-data do not dump unlogged table data\n"));
diff --git a/src/bin/pg_dump/pg_restore.c b/src/bin/pg_dump/pg_restore.c
index 64aaa80eeee..2da81782897 100644
--- a/src/bin/pg_dump/pg_restore.c
+++ b/src/bin/pg_dump/pg_restore.c
@@ -66,6 +66,7 @@ main(int argc, char **argv)
static int enable_row_security = 0;
static int if_exists = 0;
static int no_data_for_failed_tables = 0;
+ static int outputNoTableAm = 0;
static int outputNoTablespaces = 0;
static int use_setsessauth = 0;
static int no_comments = 0;
@@ -112,6 +113,7 @@ main(int argc, char **argv)
{"enable-row-security", no_argument, &enable_row_security, 1},
{"if-exists", no_argument, &if_exists, 1},
{"no-data-for-failed-tables", no_argument, &no_data_for_failed_tables, 1},
+ {"no-table-am", no_argument, &outputNoTableAm, 1},
{"no-tablespaces", no_argument, &outputNoTablespaces, 1},
{"role", required_argument, NULL, 2},
{"section", required_argument, NULL, 3},
@@ -358,6 +360,7 @@ main(int argc, char **argv)
opts->disable_triggers = disable_triggers;
opts->enable_row_security = enable_row_security;
opts->noDataForFailedTables = no_data_for_failed_tables;
+ opts->noTableAm = outputNoTableAm;
opts->noTablespace = outputNoTablespaces;
opts->use_setsessauth = use_setsessauth;
opts->no_comments = no_comments;
@@ -487,6 +490,7 @@ usage(const char *progname)
printf(_(" --no-publications do not restore publications\n"));
printf(_(" --no-security-labels do not restore security labels\n"));
printf(_(" --no-subscriptions do not restore subscriptions\n"));
+ printf(_(" --no-table-am do not restore table access methods\n"));
printf(_(" --no-tablespaces do not restore tablespace assignments\n"));
printf(_(" --section=SECTION restore named section (pre-data, data, or post-data)\n"));
printf(_(" --strict-names require table and/or schema include patterns to\n"
diff --git a/src/bin/pg_dump/t/002_pg_dump.pl b/src/bin/pg_dump/t/002_pg_dump.pl
index fd01651d9c4..a4a3ed114e5 100644
--- a/src/bin/pg_dump/t/002_pg_dump.pl
+++ b/src/bin/pg_dump/t/002_pg_dump.pl
@@ -247,13 +247,6 @@ my %pgdump_runs = (
'--exclude-database', '*dump_test*', '--no-sync',
],
},
- no_toast_compression => {
- dump_cmd => [
- 'pg_dump', '--no-sync',
- "--file=$tempdir/no_toast_compression.sql",
- '--no-toast-compression', 'postgres',
- ],
- },
no_blobs => {
dump_cmd => [
'pg_dump', '--no-sync',
@@ -275,6 +268,20 @@ my %pgdump_runs = (
'postgres',
],
},
+ no_table_am => {
+ dump_cmd => [
+ 'pg_dump', '--no-sync',
+ "--file=$tempdir/no_table_am.sql",
+ '--no-table-am', 'postgres',
+ ],
+ },
+ no_toast_compression => {
+ dump_cmd => [
+ 'pg_dump', '--no-sync',
+ "--file=$tempdir/no_toast_compression.sql",
+ '--no-toast-compression', 'postgres',
+ ],
+ },
only_dump_test_schema => {
dump_cmd => [
'pg_dump', '--no-sync',
@@ -422,10 +429,11 @@ my %full_runs = (
exclude_dump_test_schema => 1,
exclude_test_table => 1,
exclude_test_table_data => 1,
- no_toast_compression => 1,
no_blobs => 1,
no_owner => 1,
no_privs => 1,
+ no_table_am => 1,
+ no_toast_compression => 1,
pg_dumpall_dbprivs => 1,
pg_dumpall_exclude => 1,
schema_only => 1,);
@@ -2968,10 +2976,11 @@ my %tests = (
defaults => 1,
exclude_test_table => 1,
exclude_test_table_data => 1,
- no_toast_compression => 1,
no_blobs => 1,
no_privs => 1,
no_owner => 1,
+ no_table_am => 1,
+ no_toast_compression => 1,
only_dump_test_schema => 1,
pg_dumpall_dbprivs => 1,
pg_dumpall_exclude => 1,
@@ -3041,10 +3050,11 @@ my %tests = (
exclude_dump_test_schema => 1,
exclude_test_table => 1,
exclude_test_table_data => 1,
- no_toast_compression => 1,
no_blobs => 1,
no_privs => 1,
no_owner => 1,
+ no_table_am => 1,
+ no_toast_compression => 1,
pg_dumpall_dbprivs => 1,
pg_dumpall_exclude => 1,
role => 1,
@@ -3648,7 +3658,7 @@ my %tests = (
like => {
%full_runs, %dump_test_schema_runs, section_pre_data => 1,
},
- unlike => { exclude_dump_test_schema => 1 },
+ unlike => { exclude_dump_test_schema => 1, no_table_am => 1 },
},
'CREATE MATERIALIZED VIEW regress_pg_dump_matview_am' => {
@@ -3668,7 +3678,7 @@ my %tests = (
like => {
%full_runs, %dump_test_schema_runs, section_pre_data => 1,
},
- unlike => { exclude_dump_test_schema => 1 },
+ unlike => { exclude_dump_test_schema => 1, no_table_am => 1 },
});
#########################################
--
2.17.1
^ permalink raw reply [nested|flat] 9+ messages in thread
* Re: pg_dump/restore --no-tableam
@ 2022-01-04 12:01 Michael Paquier <michael@paquier.xyz>
parent: Justin Pryzby <pryzby@telsasoft.com>
2 siblings, 0 replies; 9+ messages in thread
From: Michael Paquier @ 2022-01-04 12:01 UTC (permalink / raw)
To: Justin Pryzby <pryzby@telsasoft.com>; +Cc: pgsql-hackers@postgresql.org, Andres Freund <andres@anarazel.de>
On Mon, Jan 03, 2022 at 03:44:24PM -0600, Justin Pryzby wrote:
> @cfbot: rebased
Hmm. This could be useful to provide more control in some logical
reload scenarios, so I'd agree to provide this switch. I'll look at
the patch later..
--
Michael
Attachments:
signature.asc (application/pgp-signature, 832B) download
^ permalink raw reply [nested|flat] 9+ messages in thread
* Re: pg_dump/restore --no-tableam
@ 2022-01-10 02:48 Andres Freund <andres@anarazel.de>
parent: Justin Pryzby <pryzby@telsasoft.com>
2 siblings, 0 replies; 9+ messages in thread
From: Andres Freund @ 2022-01-10 02:48 UTC (permalink / raw)
To: Justin Pryzby <pryzby@telsasoft.com>; +Cc: pgsql-hackers
Hi,
On 2022-01-03 15:44:24 -0600, Justin Pryzby wrote:
> @cfbot: rebased
> From 69ae2ed5d00a97d351e1f6c45a9e406f33032898 Mon Sep 17 00:00:00 2001
> From: Justin Pryzby <pryzbyj@telsasoft.com>
> Date: Sun, 7 Mar 2021 19:35:37 -0600
> Subject: [PATCH] Add pg_dump/restore --no-table-am..
>
> This was for some reason omitted from 3b925e905.
Seems the docs changes aren't quite right?
https://cirrus-ci.com/task/5864769860141056?logs=docs_build#L344
[02:43:01.356] ref/pg_dump.sgml:1162: parser error : Opening and ending tag mismatch: varlistentry line 934 and variablelist
[02:43:01.356] </variablelist>
[02:43:01.356] ^
....
> + <varlistentry>
> + <varlistentry>
Yup...
Greetings,
Andres Freund
^ permalink raw reply [nested|flat] 9+ messages in thread
* Re: pg_dump/restore --no-tableam
@ 2022-01-11 07:50 Michael Paquier <michael@paquier.xyz>
parent: Justin Pryzby <pryzby@telsasoft.com>
2 siblings, 1 reply; 9+ messages in thread
From: Michael Paquier @ 2022-01-11 07:50 UTC (permalink / raw)
To: Justin Pryzby <pryzby@telsasoft.com>; +Cc: pgsql-hackers@postgresql.org, Andres Freund <andres@anarazel.de>
On Mon, Jan 03, 2022 at 03:44:24PM -0600, Justin Pryzby wrote:
> + <varlistentry>
> + <varlistentry>
> + <term><option>--no-table-am</option></term>
> + <listitem>
> + <para>
> + Do not output commands to select table access methods.
> + With this option, all objects will be created with whichever
> + table access method is the default during restore.
> + </para>
Hmm. --no-table-am may not be the best choice. Should this be called
--no-table-access-method instead?
> - no_toast_compression => {
> - dump_cmd => [
> - 'pg_dump', '--no-sync',
> - "--file=$tempdir/no_toast_compression.sql",
> - '--no-toast-compression', 'postgres',
> - ],
> - },
Why is this command moved down?
--
Michael
Attachments:
signature.asc (application/pgp-signature, 832B) download
^ permalink raw reply [nested|flat] 9+ messages in thread
* Re: pg_dump/restore --no-tableam
@ 2022-01-12 04:09 Justin Pryzby <pryzby@telsasoft.com>
parent: Michael Paquier <michael@paquier.xyz>
0 siblings, 1 reply; 9+ messages in thread
From: Justin Pryzby @ 2022-01-12 04:09 UTC (permalink / raw)
To: Michael Paquier <michael@paquier.xyz>; +Cc: pgsql-hackers@postgresql.org, Andres Freund <andres@anarazel.de>
On Tue, Jan 11, 2022 at 04:50:23PM +0900, Michael Paquier wrote:
> On Mon, Jan 03, 2022 at 03:44:24PM -0600, Justin Pryzby wrote:
> > + <varlistentry>
> > + <varlistentry>
> > + <term><option>--no-table-am</option></term>
> > + <listitem>
> > + <para>
> > + Do not output commands to select table access methods.
> > + With this option, all objects will be created with whichever
> > + table access method is the default during restore.
> > + </para>
>
> Hmm. --no-table-am may not be the best choice. Should this be called
> --no-table-access-method instead?
I suppose you're right - I had previously renamed it from no-tableam.
> > - no_toast_compression => {
> > - dump_cmd => [
> > - 'pg_dump', '--no-sync',
> > - "--file=$tempdir/no_toast_compression.sql",
> > - '--no-toast-compression', 'postgres',
> > - ],
> > - },
>
> Why is this command moved down?
Because it looks like this is intended to be mostly alphabetical, but that
wasn't preserved by 63db0ac3f. It's most apparent in "my %full_runs".
The same could be said of no-privs, defaults_custom_format, pg_dumpall_globals,
section_data, but they've been that way forever.
--
Justin
Attachments:
0001-Add-pg_dump-restore-no-table-access-method.patch (text/x-diff, 11.1K) download
From 38da310269c1959994f2d7ab1cec9614209b60bb Mon Sep 17 00:00:00 2001
From: Justin Pryzby <pryzbyj@telsasoft.com>
Date: Sun, 7 Mar 2021 19:35:37 -0600
Subject: [PATCH] Add pg_dump/restore --no-table-access-method..
This was for some reason omitted from 3b925e905.
---
doc/src/sgml/ref/pg_dump.sgml | 17 ++++++++++++++
doc/src/sgml/ref/pg_restore.sgml | 11 +++++++++
src/bin/pg_dump/pg_backup.h | 2 ++
src/bin/pg_dump/pg_backup_archiver.c | 12 ++++++++++
src/bin/pg_dump/pg_dump.c | 3 +++
src/bin/pg_dump/pg_restore.c | 4 ++++
src/bin/pg_dump/t/002_pg_dump.pl | 34 ++++++++++++++++++----------
7 files changed, 71 insertions(+), 12 deletions(-)
diff --git a/doc/src/sgml/ref/pg_dump.sgml b/doc/src/sgml/ref/pg_dump.sgml
index 0e1cfe0f8d6..2f0042fd968 100644
--- a/doc/src/sgml/ref/pg_dump.sgml
+++ b/doc/src/sgml/ref/pg_dump.sgml
@@ -931,6 +931,23 @@ PostgreSQL documentation
</listitem>
</varlistentry>
+ <varlistentry>
+ <term><option>--no-table-access-method</option></term>
+ <listitem>
+ <para>
+ Do not output commands to select table access methods.
+ With this option, all objects will be created with whichever
+ table access method is the default during restore.
+ </para>
+
+ <para>
+ This option is ignored when emitting an archive (non-text) output
+ file. For the archive formats, you can specify the option when you
+ call <command>pg_restore</command>.
+ </para>
+ </listitem>
+ </varlistentry>
+
<varlistentry>
<term><option>--no-tablespaces</option></term>
<listitem>
diff --git a/doc/src/sgml/ref/pg_restore.sgml b/doc/src/sgml/ref/pg_restore.sgml
index 93ea937ac8e..526986eadb1 100644
--- a/doc/src/sgml/ref/pg_restore.sgml
+++ b/doc/src/sgml/ref/pg_restore.sgml
@@ -649,6 +649,17 @@ PostgreSQL documentation
</listitem>
</varlistentry>
+ <varlistentry>
+ <term><option>--no-table-access-method</option></term>
+ <listitem>
+ <para>
+ Do not output commands to select table access methods.
+ With this option, all objects will be created with whichever
+ access method is the default during restore.
+ </para>
+ </listitem>
+ </varlistentry>
+
<varlistentry>
<term><option>--no-tablespaces</option></term>
<listitem>
diff --git a/src/bin/pg_dump/pg_backup.h b/src/bin/pg_dump/pg_backup.h
index 753252e05e0..47741ad6406 100644
--- a/src/bin/pg_dump/pg_backup.h
+++ b/src/bin/pg_dump/pg_backup.h
@@ -93,6 +93,7 @@ typedef struct _restoreOptions
{
int createDB; /* Issue commands to create the database */
int noOwner; /* Don't try to match original object owner */
+ int noTableAm; /* Don't issue tableAM-related commands */
int noTablespace; /* Don't issue tablespace-related commands */
int disable_triggers; /* disable triggers during data-only
* restore */
@@ -179,6 +180,7 @@ typedef struct _dumpOptions
int no_unlogged_table_data;
int serializable_deferrable;
int disable_triggers;
+ int outputNoTableAm;
int outputNoTablespaces;
int use_setsessauth;
int enable_row_security;
diff --git a/src/bin/pg_dump/pg_backup_archiver.c b/src/bin/pg_dump/pg_backup_archiver.c
index 8903a694ae9..49bf0907cd2 100644
--- a/src/bin/pg_dump/pg_backup_archiver.c
+++ b/src/bin/pg_dump/pg_backup_archiver.c
@@ -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 */
diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c
index 92ab95724d2..c5f231118bd 100644
--- a/src/bin/pg_dump/pg_dump.c
+++ b/src/bin/pg_dump/pg_dump.c
@@ -389,6 +389,7 @@ main(int argc, char **argv)
{"if-exists", no_argument, &dopt.if_exists, 1},
{"inserts", no_argument, NULL, 9},
{"lock-wait-timeout", required_argument, NULL, 2},
+ {"no-table-access-method", no_argument, &dopt.outputNoTableAm, 1},
{"no-tablespaces", no_argument, &dopt.outputNoTablespaces, 1},
{"quote-all-identifiers", no_argument, "e_all_identifiers, 1},
{"load-via-partition-root", no_argument, &dopt.load_via_partition_root, 1},
@@ -933,6 +934,7 @@ main(int argc, char **argv)
ropt->superuser = dopt.outputSuperuser;
ropt->createDB = dopt.outputCreateDB;
ropt->noOwner = dopt.outputNoOwner;
+ ropt->noTableAm = dopt.outputNoTableAm;
ropt->noTablespace = dopt.outputNoTablespaces;
ropt->disable_triggers = dopt.disable_triggers;
ropt->use_setsessauth = dopt.use_setsessauth;
@@ -1038,6 +1040,7 @@ help(const char *progname)
printf(_(" --no-publications do not dump publications\n"));
printf(_(" --no-security-labels do not dump security label assignments\n"));
printf(_(" --no-subscriptions do not dump subscriptions\n"));
+ printf(_(" --no-table-access-method do not dump table access methods\n"));
printf(_(" --no-tablespaces do not dump tablespace assignments\n"));
printf(_(" --no-toast-compression do not dump TOAST compression methods\n"));
printf(_(" --no-unlogged-table-data do not dump unlogged table data\n"));
diff --git a/src/bin/pg_dump/pg_restore.c b/src/bin/pg_dump/pg_restore.c
index 64aaa80eeee..55bf1b69755 100644
--- a/src/bin/pg_dump/pg_restore.c
+++ b/src/bin/pg_dump/pg_restore.c
@@ -66,6 +66,7 @@ main(int argc, char **argv)
static int enable_row_security = 0;
static int if_exists = 0;
static int no_data_for_failed_tables = 0;
+ static int outputNoTableAm = 0;
static int outputNoTablespaces = 0;
static int use_setsessauth = 0;
static int no_comments = 0;
@@ -112,6 +113,7 @@ main(int argc, char **argv)
{"enable-row-security", no_argument, &enable_row_security, 1},
{"if-exists", no_argument, &if_exists, 1},
{"no-data-for-failed-tables", no_argument, &no_data_for_failed_tables, 1},
+ {"no-table-access-method", no_argument, &outputNoTableAm, 1},
{"no-tablespaces", no_argument, &outputNoTablespaces, 1},
{"role", required_argument, NULL, 2},
{"section", required_argument, NULL, 3},
@@ -358,6 +360,7 @@ main(int argc, char **argv)
opts->disable_triggers = disable_triggers;
opts->enable_row_security = enable_row_security;
opts->noDataForFailedTables = no_data_for_failed_tables;
+ opts->noTableAm = outputNoTableAm;
opts->noTablespace = outputNoTablespaces;
opts->use_setsessauth = use_setsessauth;
opts->no_comments = no_comments;
@@ -487,6 +490,7 @@ usage(const char *progname)
printf(_(" --no-publications do not restore publications\n"));
printf(_(" --no-security-labels do not restore security labels\n"));
printf(_(" --no-subscriptions do not restore subscriptions\n"));
+ printf(_(" --no-table-access-method do not restore table access methods\n"));
printf(_(" --no-tablespaces do not restore tablespace assignments\n"));
printf(_(" --section=SECTION restore named section (pre-data, data, or post-data)\n"));
printf(_(" --strict-names require table and/or schema include patterns to\n"
diff --git a/src/bin/pg_dump/t/002_pg_dump.pl b/src/bin/pg_dump/t/002_pg_dump.pl
index 4200bcb0d71..87eaeeb8c31 100644
--- a/src/bin/pg_dump/t/002_pg_dump.pl
+++ b/src/bin/pg_dump/t/002_pg_dump.pl
@@ -247,13 +247,6 @@ my %pgdump_runs = (
'--exclude-database', '*dump_test*', '--no-sync',
],
},
- no_toast_compression => {
- dump_cmd => [
- 'pg_dump', '--no-sync',
- "--file=$tempdir/no_toast_compression.sql",
- '--no-toast-compression', 'postgres',
- ],
- },
no_blobs => {
dump_cmd => [
'pg_dump', '--no-sync',
@@ -275,6 +268,20 @@ my %pgdump_runs = (
'postgres',
],
},
+ no_table_am => {
+ dump_cmd => [
+ 'pg_dump', '--no-sync',
+ "--file=$tempdir/no_table_am.sql",
+ '--no-table-access-method', 'postgres',
+ ],
+ },
+ no_toast_compression => {
+ dump_cmd => [
+ 'pg_dump', '--no-sync',
+ "--file=$tempdir/no_toast_compression.sql",
+ '--no-toast-compression', 'postgres',
+ ],
+ },
only_dump_test_schema => {
dump_cmd => [
'pg_dump', '--no-sync',
@@ -422,10 +429,11 @@ my %full_runs = (
exclude_dump_test_schema => 1,
exclude_test_table => 1,
exclude_test_table_data => 1,
- no_toast_compression => 1,
no_blobs => 1,
no_owner => 1,
no_privs => 1,
+ no_table_am => 1,
+ no_toast_compression => 1,
pg_dumpall_dbprivs => 1,
pg_dumpall_exclude => 1,
schema_only => 1,);
@@ -2968,10 +2976,11 @@ my %tests = (
defaults => 1,
exclude_test_table => 1,
exclude_test_table_data => 1,
- no_toast_compression => 1,
no_blobs => 1,
no_privs => 1,
no_owner => 1,
+ no_table_am => 1,
+ no_toast_compression => 1,
only_dump_test_schema => 1,
pg_dumpall_dbprivs => 1,
pg_dumpall_exclude => 1,
@@ -3041,10 +3050,11 @@ my %tests = (
exclude_dump_test_schema => 1,
exclude_test_table => 1,
exclude_test_table_data => 1,
- no_toast_compression => 1,
no_blobs => 1,
no_privs => 1,
no_owner => 1,
+ no_table_am => 1,
+ no_toast_compression => 1,
pg_dumpall_dbprivs => 1,
pg_dumpall_exclude => 1,
role => 1,
@@ -3648,7 +3658,7 @@ my %tests = (
like => {
%full_runs, %dump_test_schema_runs, section_pre_data => 1,
},
- unlike => { exclude_dump_test_schema => 1 },
+ unlike => { exclude_dump_test_schema => 1, no_table_am => 1 },
},
'CREATE MATERIALIZED VIEW regress_pg_dump_matview_am' => {
@@ -3668,7 +3678,7 @@ my %tests = (
like => {
%full_runs, %dump_test_schema_runs, section_pre_data => 1,
},
- unlike => { exclude_dump_test_schema => 1 },
+ unlike => { exclude_dump_test_schema => 1, no_table_am => 1 },
});
#########################################
--
2.17.1
^ permalink raw reply [nested|flat] 9+ messages in thread
* Re: pg_dump/restore --no-tableam
@ 2022-01-17 05:55 Michael Paquier <michael@paquier.xyz>
parent: Justin Pryzby <pryzby@telsasoft.com>
0 siblings, 1 reply; 9+ messages in thread
From: Michael Paquier @ 2022-01-17 05:55 UTC (permalink / raw)
To: Justin Pryzby <pryzby@telsasoft.com>; +Cc: pgsql-hackers@postgresql.org, Andres Freund <andres@anarazel.de>
On Tue, Jan 11, 2022 at 10:09:07PM -0600, Justin Pryzby wrote:
> I suppose you're right - I had previously renamed it from no-tableam.
Thanks for the new version. I have noticed that support for the
option with pg_dumpall was missing, but that looks useful to me like
the other switches.
> Because it looks like this is intended to be mostly alphabetical, but that
> wasn't preserved by 63db0ac3f. It's most apparent in "my %full_runs".
Sure. Now I am not sure that this is worth poking at if we don't
change the back-branches, as this could cause conflicts. So I have
left this change out at the end.
And, done.
--
Michael
Attachments:
signature.asc (application/pgp-signature, 832B) download
^ permalink raw reply [nested|flat] 9+ messages in thread
* Re: pg_dump/restore --no-tableam
@ 2022-01-17 06:20 Justin Pryzby <pryzby@telsasoft.com>
parent: Michael Paquier <michael@paquier.xyz>
0 siblings, 1 reply; 9+ messages in thread
From: Justin Pryzby @ 2022-01-17 06:20 UTC (permalink / raw)
To: Michael Paquier <michael@paquier.xyz>; +Cc: pgsql-hackers@postgresql.org, Andres Freund <andres@anarazel.de>
On Mon, Jan 17, 2022 at 02:55:58PM +0900, Michael Paquier wrote:
> On Tue, Jan 11, 2022 at 10:09:07PM -0600, Justin Pryzby wrote:
> > I suppose you're right - I had previously renamed it from no-tableam.
>
> Thanks for the new version. I have noticed that support for the
> option with pg_dumpall was missing, but that looks useful to me like
> the other switches.
I saw that you added it to pg_dumpall. But there's a typo in --help:
inline patch 1: src/bin/pg_dump/pg_dumpall.c (+1/-1 lines) download inline-1.patch
diff --git a/src/bin/pg_dump/pg_dumpall.c b/src/bin/pg_dump/pg_dumpall.c
index 1cab0dfdc75..94852e7cdbb 100644
--- a/src/bin/pg_dump/pg_dumpall.c
+++ b/src/bin/pg_dump/pg_dumpall.c
@@ -655,3 +655,3 @@ help(void)
printf(_(" --no-sync do not wait for changes to be written safely to disk\n"));
- printf(_(" --no-tables-access-method do not dump table access methods\n"));
+ printf(_(" --no-table-access-method do not dump table access methods\n"));
printf(_(" --no-tablespaces do not dump tablespace assignments\n"));
Feel free to leave it for now, and I'll add it to my typos branch.
> And, done.
Thanks!
--
Justin
^ permalink raw reply [nested|flat] 9+ messages in thread
* Re: pg_dump/restore --no-tableam
@ 2022-01-17 07:05 Michael Paquier <michael@paquier.xyz>
parent: Justin Pryzby <pryzby@telsasoft.com>
0 siblings, 0 replies; 9+ messages in thread
From: Michael Paquier @ 2022-01-17 07:05 UTC (permalink / raw)
To: Justin Pryzby <pryzby@telsasoft.com>; +Cc: pgsql-hackers@postgresql.org, Andres Freund <andres@anarazel.de>
On Mon, Jan 17, 2022 at 12:20:07AM -0600, Justin Pryzby wrote:
> I saw that you added it to pg_dumpall. But there's a typo in --help:
Thanks, fixed.
--
Michael
Attachments:
signature.asc (application/pgp-signature, 832B) download
^ permalink raw reply [nested|flat] 9+ messages in thread
end of thread, other threads:[~2022-01-17 07:05 UTC | newest]
Thread overview: 9+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2021-12-07 15:39 pg_dump/restore --no-tableam Justin Pryzby <pryzby@telsasoft.com>
2022-01-03 21:44 ` Justin Pryzby <pryzby@telsasoft.com>
2022-01-04 12:01 ` Michael Paquier <michael@paquier.xyz>
2022-01-10 02:48 ` Andres Freund <andres@anarazel.de>
2022-01-11 07:50 ` Michael Paquier <michael@paquier.xyz>
2022-01-12 04:09 ` Justin Pryzby <pryzby@telsasoft.com>
2022-01-17 05:55 ` Michael Paquier <michael@paquier.xyz>
2022-01-17 06:20 ` Justin Pryzby <pryzby@telsasoft.com>
2022-01-17 07:05 ` Michael Paquier <michael@paquier.xyz>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox