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

Commit6c77bb4

Browse files
committed
Replace use of stat()[7] by -s switch in TAP tests to retrieve file size
The list form of stat() is an inelegant API as it relies on the positionof the file size in the list returned in result. Like in any otherplaces of the tree, replace that with a -s switch instead.Another suggestion from Dagfinn is File::Stat, which we've been alreadyusing for some other fields. It really comes down to a matter of tasteto choose that over -s, and the latter is more used in the tree.Author: Bertrand DrouvotReviewed-by: Dagfinn Ilmari MannsåkerDiscussion:https://postgr.es/m/b2020df7-d0fc-4ea5-b2a9-7efc6d36b2ac@gmail.com
1 parent06c0c36 commit6c77bb4

File tree

3 files changed

+5
-13
lines changed

3 files changed

+5
-13
lines changed

‎src/bin/pg_controldata/t/001_pg_controldata.pl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
# check with a corrupted pg_control
2525

2626
my$pg_control =$node->data_dir .'/global/pg_control';
27-
my$size =(stat($pg_control))[7];
27+
my$size =-s$pg_control;
2828

2929
openmy$fh,'>',$pg_controlor BAIL_OUT($!);
3030
binmode$fh;

‎src/bin/pg_resetwal/t/002_corrupted.pl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
$node->init;
1515

1616
my$pg_control =$node->data_dir .'/global/pg_control';
17-
my$size =(stat($pg_control))[7];
17+
my$size =-s$pg_control;
1818

1919
# Read out the head of the file to get PG_CONTROL_VERSION in
2020
# particular.

‎src/test/recovery/t/019_replslot_limit.pl

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@
173173
"ALTER SYSTEM SET max_wal_size='40MB'; SELECT pg_reload_conf()");
174174

175175
# Advance WAL again. The slot loses the oldest segment by the next checkpoint
176-
my$logstart =get_log_size($node_primary);
176+
my$logstart =-s$node_primary->logfile;
177177
advance_wal($node_primary, 7);
178178

179179
# Now create another checkpoint and wait until the WARNING is issued
@@ -229,7 +229,7 @@
229229
is($oldestseg,$redoseg,"check that segments have been removed");
230230

231231
# The standby no longer can connect to the primary
232-
$logstart =get_log_size($node_standby);
232+
$logstart =-s$node_standby->logfile;
233233
$node_standby->start;
234234

235235
my$failed = 0;
@@ -368,7 +368,7 @@
368368
"SELECT pid FROM pg_stat_activity WHERE backend_type = 'walreceiver'");
369369
like($receiverpid,qr/^[0-9]+$/,"have walreceiver pid$receiverpid");
370370

371-
$logstart =get_log_size($node_primary3);
371+
$logstart =-s$node_primary3->logfile;
372372
# freeze walsender and walreceiver. Slot will still be active, but walreceiver
373373
# won't get anything anymore.
374374
kill'STOP',$senderpid,$receiverpid;
@@ -433,12 +433,4 @@ sub advance_wal
433433
return;
434434
}
435435

436-
# return the size of logfile of $node in bytes
437-
subget_log_size
438-
{
439-
my ($node) =@_;
440-
441-
return (stat$node->logfile)[7];
442-
}
443-
444436
done_testing();

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp