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

Commitd0d6226

Browse files
committed
Fix thinko coming from000f3ad
pg_basebackup.c relies on the compression level to not be 0 to decide ifcompression should be used, but000f3ad missed the fact that thedefault compression (Z_DEFAULT_COMPRESSION) is -1, which would be usedif specifying --gzip without --compress.While on it, add some coverage for --gzip, as this is rather easy tomiss.Reported-by: Christoph BergDiscussion:https://postgr.es/m/YdhRDMLjabtXOnhY@msg.df7cb.de
1 parent27b77ec commitd0d6226

File tree

2 files changed

+18
-5
lines changed

2 files changed

+18
-5
lines changed

‎src/bin/pg_basebackup/pg_basebackup.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -524,7 +524,7 @@ LogStreamerMain(logstreamer_param *param)
524524
stream.do_sync);
525525
else
526526
stream.walmethod=CreateWalTarMethod(param->xlog,
527-
(compresslevel>0) ?
527+
(compresslevel!=0) ?
528528
COMPRESSION_GZIP :COMPRESSION_NONE,
529529
compresslevel,
530530
stream.do_sync);

‎src/bin/pg_basebackup/t/010_pg_basebackup.pl

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
use Fcntlqw(:seek);
1111
use PostgreSQL::Test::Cluster;
1212
use PostgreSQL::Test::Utils;
13-
use Test::Moretests=>113;
13+
use Test::Moretests=>115;
1414

1515
program_help_ok('pg_basebackup');
1616
program_version_ok('pg_basebackup');
@@ -630,7 +630,7 @@
630630
# Check ZLIB compression if available.
631631
SKIP:
632632
{
633-
skip"postgres was not built with ZLIB support",3
633+
skip"postgres was not built with ZLIB support",5
634634
if (!check_pg_config("#define HAVE_LIBZ 1"));
635635

636636
$node->command_ok(
@@ -641,12 +641,23 @@
641641
'--format','t'
642642
],
643643
'pg_basebackup with --compress');
644+
$node->command_ok(
645+
[
646+
'pg_basebackup','-D',
647+
"$tempdir/backup_gzip2",'--gzip',
648+
'--no-sync','--format',
649+
't'
650+
],
651+
'pg_basebackup with --gzip');
644652

645653
# Verify that the stored files are generated with their expected
646654
# names.
647655
my@zlib_files =glob"$tempdir/backup_gzip/*.tar.gz";
648656
is(scalar(@zlib_files), 2,
649-
"two files created with gzip (base.tar.gz and pg_wal.tar.gz)");
657+
"two files created with --compress (base.tar.gz and pg_wal.tar.gz)");
658+
my@zlib_files2 =glob"$tempdir/backup_gzip2/*.tar.gz";
659+
is(scalar(@zlib_files2), 2,
660+
"two files created with --gzip (base.tar.gz and pg_wal.tar.gz)");
650661

651662
# Check the integrity of the files generated.
652663
my$gzip =$ENV{GZIP_PROGRAM};
@@ -655,7 +666,9 @@
655666
||$gzipeq''
656667
|| system_log($gzip,'--version') != 0);
657668

658-
my$gzip_is_valid = system_log($gzip,'--test',@zlib_files);
669+
my$gzip_is_valid =
670+
system_log($gzip,'--test',@zlib_files,@zlib_files2);
659671
is($gzip_is_valid, 0,"gzip verified the integrity of compressed data");
660672
rmtree("$tempdir/backup_gzip");
673+
rmtree("$tempdir/backup_gzip2");
661674
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp