Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitbedc1f0

Browse files
committed
Rework code defining default compression for dir/custom formats in pg_dump
As written, pg_dump would call twice parse_compress_specification() forthe custom and directory formats to build a compression specification ifno compression option is defined, as these formats should be compressedby default when compiled with zlib, or use no compression without zlib.This made the code logic quite confusing, and the first compressionspecification built would be incorrect before being overwritten by thesecond one.Rather than creating two compression specifications, this commit changesa bit the order of the checks for the compression options so ascompression_algorithm_str is now set to a correct value for the customand format directory when no compression option is defined. This makesthe code easier to understand, as parse_compress_specification() is nowcalled once for all the format, with or without user-specifiedcompression methods. One comment was also confusing for the non-zlibcase, so remove it while on it.This code has been introduced in5e73a60 when adding support forcompression specifications in pg_dump.Per discussion with Justin Pryzby and Georgios Kokolatos.Discussion:https://postgr.es/m/20230225050214.GH1653@telsasoft.com
1 parent7b7fa85 commitbedc1f0

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

‎src/bin/pg_dump/pg_dump.c

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -721,6 +721,21 @@ main(int argc, char **argv)
721721
if (archiveFormat == archNull)
722722
plainText = 1;
723723

724+
/*
725+
* Custom and directory formats are compressed by default with gzip when
726+
* available, not the others. If gzip is not available, no compression is
727+
* done by default.
728+
*/
729+
if ((archiveFormat == archCustom || archiveFormat == archDirectory) &&
730+
!user_compression_defined)
731+
{
732+
#ifdef HAVE_LIBZ
733+
compression_algorithm_str = "gzip";
734+
#else
735+
compression_algorithm_str = "none";
736+
#endif
737+
}
738+
724739
/*
725740
* Compression options
726741
*/
@@ -749,21 +764,6 @@ main(int argc, char **argv)
749764
pg_log_warning("compression option \"%s\" is not currently supported by pg_dump",
750765
"workers");
751766

752-
/*
753-
* Custom and directory formats are compressed by default with gzip when
754-
* available, not the others.
755-
*/
756-
if ((archiveFormat == archCustom || archiveFormat == archDirectory) &&
757-
!user_compression_defined)
758-
{
759-
#ifdef HAVE_LIBZ
760-
parse_compress_specification(PG_COMPRESSION_GZIP, NULL,
761-
&compression_spec);
762-
#else
763-
/* Nothing to do in the default case */
764-
#endif
765-
}
766-
767767
/*
768768
* If emitting an archive format, we always want to emit a DATABASE item,
769769
* in case --create is specified at pg_restore time.

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp