pg_dumpall misses --no-toast-compression

Started by Michael Paquierover 4 years ago6 messages
#1Michael Paquier
michael@paquier.xyz
1 attachment(s)

Hi all,

I have bumped into $subject while playing with this feature, and this
can be really useful to be able to reset the compression method for
all the tables at restore. The patch is simple but that's perhaps too
late for 14, so I am adding it to the next CF.

Thanks,
--
Michael

Attachments:

dumpall-compression.patchtext/x-diff; charset=us-asciiDownload
diff --git a/src/bin/pg_dump/pg_dumpall.c b/src/bin/pg_dump/pg_dumpall.c
index 007a3d0f9a..c29101704a 100644
--- a/src/bin/pg_dump/pg_dumpall.c
+++ b/src/bin/pg_dump/pg_dumpall.c
@@ -77,6 +77,7 @@ static int	no_comments = 0;
 static int	no_publications = 0;
 static int	no_security_labels = 0;
 static int	no_subscriptions = 0;
+static int	no_toast_compression = 0;
 static int	no_unlogged_table_data = 0;
 static int	no_role_passwords = 0;
 static int	server_version;
@@ -144,6 +145,7 @@ main(int argc, char *argv[])
 		{"no-security-labels", no_argument, &no_security_labels, 1},
 		{"no-subscriptions", no_argument, &no_subscriptions, 1},
 		{"no-sync", no_argument, NULL, 4},
+		{"no-toast-compression", no_argument, &no_toast_compression, 1},
 		{"no-unlogged-table-data", no_argument, &no_unlogged_table_data, 1},
 		{"on-conflict-do-nothing", no_argument, &on_conflict_do_nothing, 1},
 		{"rows-per-insert", required_argument, NULL, 7},
@@ -428,6 +430,8 @@ main(int argc, char *argv[])
 		appendPQExpBufferStr(pgdumpopts, " --no-security-labels");
 	if (no_subscriptions)
 		appendPQExpBufferStr(pgdumpopts, " --no-subscriptions");
+	if (no_toast_compression)
+		appendPQExpBufferStr(pgdumpopts, " --no-toast-compression");
 	if (no_unlogged_table_data)
 		appendPQExpBufferStr(pgdumpopts, " --no-unlogged-table-data");
 	if (on_conflict_do_nothing)
@@ -651,6 +655,7 @@ help(void)
 	printf(_("  --no-subscriptions           do not dump subscriptions\n"));
 	printf(_("  --no-sync                    do not wait for changes to be written safely to disk\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"));
 	printf(_("  --on-conflict-do-nothing     add ON CONFLICT DO NOTHING to INSERT commands\n"));
 	printf(_("  --quote-all-identifiers      quote all identifiers, even if not key words\n"));
diff --git a/doc/src/sgml/ref/pg_dumpall.sgml b/doc/src/sgml/ref/pg_dumpall.sgml
index 3c2f9c774f..805c47d5c1 100644
--- a/doc/src/sgml/ref/pg_dumpall.sgml
+++ b/doc/src/sgml/ref/pg_dumpall.sgml
@@ -458,6 +458,18 @@ PostgreSQL documentation
       </listitem>
      </varlistentry>
 
+     <varlistentry>
+      <term><option>--no-toast-compression</option></term>
+      <listitem>
+       <para>
+        Do not output commands to set <acronym>TOAST</acronym> compression
+        methods.
+        With this option, all objects will be created using whichever
+        compression method is the default during restore.
+       </para>
+      </listitem>
+     </varlistentry>
+     
      <varlistentry>
       <term><option>--no-unlogged-table-data</option></term>
       <listitem>
#2Dilip Kumar
dilipbalaut@gmail.com
In reply to: Michael Paquier (#1)
Re: pg_dumpall misses --no-toast-compression

On Mon, May 17, 2021 at 6:42 AM Michael Paquier <michael@paquier.xyz> wrote:

Hi all,

I have bumped into $subject while playing with this feature, and this
can be really useful to be able to reset the compression method for
all the tables at restore.

This makes sense

The patch is simple but that's perhaps too

late for 14, so I am adding it to the next CF.

+1

--
Regards,
Dilip Kumar
EnterpriseDB: http://www.enterprisedb.com

#3Daniel Gustafsson
daniel@yesql.se
In reply to: Michael Paquier (#1)
Re: pg_dumpall misses --no-toast-compression

On 17 May 2021, at 03:12, Michael Paquier <michael@paquier.xyz> wrote:

I have bumped into $subject while playing with this feature, and this
can be really useful to be able to reset the compression method for
all the tables at restore. The patch is simple but that's perhaps too
late for 14, so I am adding it to the next CF.

I think there is a reasonable case to be made for this fixing an oversight in
bbe0a81db69bd10bd166907c3701492a29aca294 as opposed to adding a brand new
feature. Save for --no-synchronized-snapshots all --no-xxx options in pg_dump
are mirrored in pg_dumpall.

--
Daniel Gustafsson https://vmware.com/

#4Tom Lane
tgl@sss.pgh.pa.us
In reply to: Daniel Gustafsson (#3)
Re: pg_dumpall misses --no-toast-compression

Daniel Gustafsson <daniel@yesql.se> writes:

On 17 May 2021, at 03:12, Michael Paquier <michael@paquier.xyz> wrote:
I have bumped into $subject while playing with this feature, and this
can be really useful to be able to reset the compression method for
all the tables at restore. The patch is simple but that's perhaps too
late for 14, so I am adding it to the next CF.

I think there is a reasonable case to be made for this fixing an oversight in
bbe0a81db69bd10bd166907c3701492a29aca294 as opposed to adding a brand new
feature. Save for --no-synchronized-snapshots all --no-xxx options in pg_dump
are mirrored in pg_dumpall.

+1, seems more like fixing an oversight than anything else.

regards, tom lane

#5Michael Paquier
michael@paquier.xyz
In reply to: Tom Lane (#4)
Re: pg_dumpall misses --no-toast-compression

On Mon, May 17, 2021 at 10:38:15AM -0400, Tom Lane wrote:

Daniel Gustafsson <daniel@yesql.se> writes:

I think there is a reasonable case to be made for this fixing an oversight in
bbe0a81db69bd10bd166907c3701492a29aca294 as opposed to adding a brand new
feature. Save for --no-synchronized-snapshots all --no-xxx options in pg_dump
are mirrored in pg_dumpall.

+1, seems more like fixing an oversight than anything else.

Okay, thanks. I don't mind taking care of that on HEAD once beta1 is
shipped, then.
--
Michael

#6Michael Paquier
michael@paquier.xyz
In reply to: Michael Paquier (#5)
Re: pg_dumpall misses --no-toast-compression

On Tue, May 18, 2021 at 09:48:59AM +0900, Michael Paquier wrote:

Okay, thanks. I don't mind taking care of that on HEAD once beta1 is
shipped, then.

Beta1 just got tagged, so this one has been applied as of 694da19.
--
Michael