Skip to content

Commit 8e6b3c2

Browse files
committed
check_wal_files: Use pg_ls_waldir() on PG10+
Close bucardo#145
1 parent c26294b commit 8e6b3c2

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

check_postgres.pl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8682,8 +8682,8 @@ sub check_wal_files {
86828682

86838683
## Figure out where the pg_xlog directory is
86848684
$SQL = qq{SELECT count(*) AS count FROM $lsfunc($lsargs) WHERE $lsfunc ~ E'^[0-9A-F]{24}$extrabit\$'}; ## no critic (RequireInterpolationOfMetachars)
8685-
my $SQL10 = $SQL;
8686-
$SQL10 =~ s/pg_xlog/pg_wal/g unless ($opt{lsfunc});
8685+
my $SQL10 = $opt{lsfunc} ? $SQL :
8686+
qq{SELECT count(*) AS count FROM pg_ls_waldir() WHERE name ~ E'^[0-9A-F]{24}$extrabit\$'}; ## no critic (RequireInterpolationOfMetachars)
86878687

86888688
my $info = run_command($SQL, {regex => qr[\d], version => [">9.6 $SQL10"] });
86898689

t/02_wal_files.t

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,9 @@ like ($cp->run('--critical=1'), qr{^$label CRITICAL}, $t);
4949

5050
$cp->drop_schema_if_exists();
5151
$cp->create_fake_pg_table('pg_ls_dir', 'text');
52+
if ($ver >= 100000) {
53+
$dbh->do("CREATE OR REPLACE FUNCTION cptest.pg_ls_waldir() RETURNS table(name text) AS 'SELECT * FROM cptest.pg_ls_dir' LANGUAGE SQL");
54+
}
5255
$dbh->commit();
5356

5457
like ($cp->run('--critical=1'), qr{^$label OK}, $t);
@@ -67,7 +70,7 @@ is ($cp->run('--critical=101 --output=mrtg'), "99\n0\n\n\n", $t);
6770

6871
# test --lsfunc
6972
my $xlogdir = $ver >= 100000 ? 'pg_wal' : 'pg_xlog';
70-
$dbh->do(qq{CREATE FUNCTION ls_xlog_dir()
73+
$dbh->do(qq{CREATE OR REPLACE FUNCTION ls_xlog_dir()
7174
RETURNS SETOF TEXT
7275
AS \$\$ SELECT pg_ls_dir('$xlogdir') \$\$
7376
LANGUAGE SQL

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy