On Thu, Apr 15, 2021 at 09:12:52PM -0400, Andrew Dunstan wrote: > It's worked on fairywren, I will double check on drongo and if all is > well will commit.
Thanks Andrew. For the archive's sake, this has been committed as of 3c5b068. While reading the commit, I have noticed that you used SEEK_SET instead of 0 as I did in my own patch. That makes the code easier to understand. Could it be better to apply the same style to all the perl scripts doing some seek() calls? Please see the attached. -- Michael
diff --git a/src/bin/pg_amcheck/t/003_check.pl b/src/bin/pg_amcheck/t/003_check.pl index 66dd14e498..2da9631da4 100644 --- a/src/bin/pg_amcheck/t/003_check.pl +++ b/src/bin/pg_amcheck/t/003_check.pl @@ -3,6 +3,8 @@ use warnings; use PostgresNode; use TestLib; + +use Fcntl qw(:seek); use Test::More tests => 63; my ($node, $port, %corrupt_page, %remove_relation); @@ -84,7 +86,7 @@ sub corrupt_first_page # Corrupt some line pointers. The values are chosen to hit the # various line-pointer-corruption checks in verify_heapam.c # on both little-endian and big-endian architectures. - seek($fh, 32, 0) + seek($fh, 32, SEEK_SET) or BAIL_OUT("seek failed: $!"); syswrite( $fh, diff --git a/src/bin/pg_amcheck/t/004_verify_heapam.pl b/src/bin/pg_amcheck/t/004_verify_heapam.pl index 3c1277adf3..b842f7bc6d 100644 --- a/src/bin/pg_amcheck/t/004_verify_heapam.pl +++ b/src/bin/pg_amcheck/t/004_verify_heapam.pl @@ -4,6 +4,7 @@ use warnings; use PostgresNode; use TestLib; +use Fcntl qw(:seek); use Test::More; # This regression test demonstrates that the pg_amcheck binary correctly @@ -95,7 +96,7 @@ sub read_tuple { my ($fh, $offset) = @_; my ($buffer, %tup); - seek($fh, $offset, 0) + seek($fh, $offset, SEEK_SET) or BAIL_OUT("seek failed: $!"); defined(sysread($fh, $buffer, HEAPTUPLE_PACK_LENGTH)) or BAIL_OUT("sysread failed: $!"); @@ -172,7 +173,7 @@ sub write_tuple $tup->{c_va_extinfo}, $tup->{c_va_valueid}, $tup->{c_va_toastrelid}); - seek($fh, $offset, 0) + seek($fh, $offset, SEEK_SET) or BAIL_OUT("seek failed: $!"); defined(syswrite($fh, $buffer, HEAPTUPLE_PACK_LENGTH)) or BAIL_OUT("syswrite failed: $!"); diff --git a/src/bin/pg_basebackup/t/010_pg_basebackup.pl b/src/bin/pg_basebackup/t/010_pg_basebackup.pl index 089c9cb851..a9dfe88aaa 100644 --- a/src/bin/pg_basebackup/t/010_pg_basebackup.pl +++ b/src/bin/pg_basebackup/t/010_pg_basebackup.pl @@ -4,6 +4,7 @@ use Cwd; use Config; use File::Basename qw(basename dirname); use File::Path qw(rmtree); +use Fcntl qw(:seek); use PostgresNode; use TestLib; use Test::More tests => 110; @@ -555,7 +556,7 @@ my $block_size = $node->safe_psql('postgres', 'SHOW block_size;'); # induce corruption system_or_bail 'pg_ctl', '-D', $pgdata, 'stop'; open $file, '+<', "$pgdata/$file_corrupt1"; -seek($file, $pageheader_size, 0); +seek($file, $pageheader_size, SEEK_SET); syswrite($file, "\0\0\0\0\0\0\0\0\0"); close $file; system_or_bail 'pg_ctl', '-D', $pgdata, 'start'; @@ -574,7 +575,7 @@ open $file, '+<', "$pgdata/$file_corrupt1"; for my $i (1 .. 5) { my $offset = $pageheader_size + $i * $block_size; - seek($file, $offset, 0); + seek($file, $offset, SEEK_SET); syswrite($file, "\0\0\0\0\0\0\0\0\0"); } close $file; @@ -591,7 +592,7 @@ rmtree("$tempdir/backup_corrupt2"); # induce corruption in a second file system_or_bail 'pg_ctl', '-D', $pgdata, 'stop'; open $file, '+<', "$pgdata/$file_corrupt2"; -seek($file, $pageheader_size, 0); +seek($file, $pageheader_size, SEEK_SET); syswrite($file, "\0\0\0\0\0\0\0\0\0"); close $file; system_or_bail 'pg_ctl', '-D', $pgdata, 'start'; diff --git a/src/bin/pg_checksums/t/002_actions.pl b/src/bin/pg_checksums/t/002_actions.pl index 8a81f36a06..d52bbac5fa 100644 --- a/src/bin/pg_checksums/t/002_actions.pl +++ b/src/bin/pg_checksums/t/002_actions.pl @@ -5,6 +5,8 @@ use strict; use warnings; use PostgresNode; use TestLib; + +use Fcntl qw(:seek); use Test::More tests => 63; @@ -50,7 +52,7 @@ sub check_relation_corruption # Time to create some corruption open my $file, '+<', "$pgdata/$file_corrupted"; - seek($file, $pageheader_size, 0); + seek($file, $pageheader_size, SEEK_SET); syswrite($file, "\0\0\0\0\0\0\0\0\0"); close $file; diff --git a/contrib/amcheck/t/001_verify_heapam.pl b/contrib/amcheck/t/001_verify_heapam.pl index 6050feb712..bf47c2ed37 100644 --- a/contrib/amcheck/t/001_verify_heapam.pl +++ b/contrib/amcheck/t/001_verify_heapam.pl @@ -4,6 +4,7 @@ use warnings; use PostgresNode; use TestLib; +use Fcntl qw(:seek); use Test::More tests => 80; my ($node, $result); @@ -124,7 +125,7 @@ sub corrupt_first_page # Corrupt some line pointers. The values are chosen to hit the # various line-pointer-corruption checks in verify_heapam.c # on both little-endian and big-endian architectures. - seek($fh, 32, 0) + seek($fh, 32, SEEK_SET) or BAIL_OUT("seek failed: $!"); syswrite( $fh,
signature.asc
Description: PGP signature