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

Commit41ed5bb

Browse files
committed
Restore use of zlib default compression in pg_dump directory mode.
This was broken by commit0e7e355 andfriends, which ignored the fact that gzopen() will treat "-1" in themode argument as an invalid character, which it ignores, and a flag forcompression level 1. Now, when this value is encountered no compressionlevel flag is passed to gzopen, leaving it to use the zlib default.Also, enforce the documented allowed range for pg_dump's -Z option,namely 0 .. 9, and remove some consequently dead code frompg_backup_tar.c.Problem reported by Marc Mamin.Backpatch to 9.1, like the patch that introduced the bug.
1 parentb755133 commit41ed5bb

File tree

3 files changed

+19
-11
lines changed

3 files changed

+19
-11
lines changed

‎src/bin/pg_dump/compress_io.c

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -546,11 +546,21 @@ cfopen(const char *path, const char *mode, int compression)
546546
if (compression!=0)
547547
{
548548
#ifdefHAVE_LIBZ
549-
charmode_compression[32];
549+
if (compression!=Z_DEFAULT_COMPRESSION)
550+
{
551+
/* user has specified a compression level, so tell zlib to use it */
552+
charmode_compression[32];
553+
554+
snprintf(mode_compression,sizeof(mode_compression),"%s%d",
555+
mode,compression);
556+
fp->compressedfp=gzopen(path,mode_compression);
557+
}
558+
else
559+
{
560+
/* don't specify a level, just use the zlib default */
561+
fp->compressedfp=gzopen(path,mode);
562+
}
550563

551-
snprintf(mode_compression,sizeof(mode_compression),"%s%d",
552-
mode,compression);
553-
fp->compressedfp=gzopen(path,mode_compression);
554564
fp->uncompressedfp=NULL;
555565
if (fp->compressedfp==NULL)
556566
{

‎src/bin/pg_dump/pg_backup_tar.c

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -209,13 +209,6 @@ InitArchiveFmt_Tar(ArchiveHandle *AH)
209209

210210
ctx->hasSeek=checkSeek(ctx->tarFH);
211211

212-
if (AH->compression<0||AH->compression>9)
213-
AH->compression=Z_DEFAULT_COMPRESSION;
214-
215-
/* Don't compress into tar files unless asked to do so */
216-
if (AH->compression==Z_DEFAULT_COMPRESSION)
217-
AH->compression=0;
218-
219212
/*
220213
* We don't support compression because reading the files back is not
221214
* possible since gzdopen uses buffered IO which totally screws file

‎src/bin/pg_dump/pg_dump.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -513,6 +513,11 @@ main(int argc, char **argv)
513513

514514
case'Z':/* Compression Level */
515515
compressLevel=atoi(optarg);
516+
if (compressLevel<0||compressLevel>9)
517+
{
518+
write_msg(NULL,"compression level must be in range 0..9\n");
519+
exit_nicely(1);
520+
}
516521
break;
517522

518523
case0:

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp