aboutsummaryrefslogtreecommitdiff
path: root/src/backend/utils/adt/pgstatfuncs.c
diff options
context:
space:
mode:
authorMagnus Hagander <magnus@hagander.net>2019-04-17 13:51:48 +0200
committerMagnus Hagander <magnus@hagander.net>2019-04-17 13:51:48 +0200
commit252b707bc41cc9bf6c55c18d8cb302a6176b7e48 (patch)
tree81ad76fd40b266f9ace5614ee1372df865e8c869 /src/backend/utils/adt/pgstatfuncs.c
parent9010156445c420361c2cef9557751c0b8b52644b (diff)
downloadpostgresql-252b707bc41cc9bf6c55c18d8cb302a6176b7e48.tar.gz
postgresql-252b707bc41cc9bf6c55c18d8cb302a6176b7e48.zip
Return NULL for checksum failures if checksums are not enabled
Returning 0 could falsely indicate that there is no problem. NULL correctly indicates that there is no information about potential problems. Also return 0 as numbackends instead of NULL for shared objects (as no connection can be made to a shared object only). Author: Julien Rouhaud <rjuju123@gmail.com> Reviewed-by: Robert Treat <rob@xzilla.net>
Diffstat (limited to 'src/backend/utils/adt/pgstatfuncs.c')
-rw-r--r--src/backend/utils/adt/pgstatfuncs.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/backend/utils/adt/pgstatfuncs.c b/src/backend/utils/adt/pgstatfuncs.c
index 97f41fb46c1..05240bfd142 100644
--- a/src/backend/utils/adt/pgstatfuncs.c
+++ b/src/backend/utils/adt/pgstatfuncs.c
@@ -15,6 +15,7 @@
#include "postgres.h"
#include "access/htup_details.h"
+#include "access/xlog.h"
#include "catalog/pg_authid.h"
#include "catalog/pg_type.h"
#include "common/ip.h"
@@ -1526,6 +1527,9 @@ pg_stat_get_db_checksum_failures(PG_FUNCTION_ARGS)
int64 result;
PgStat_StatDBEntry *dbentry;
+ if (!DataChecksumsEnabled())
+ PG_RETURN_NULL();
+
if ((dbentry = pgstat_fetch_stat_dbentry(dbid)) == NULL)
result = 0;
else
@@ -1541,6 +1545,9 @@ pg_stat_get_db_checksum_last_failure(PG_FUNCTION_ARGS)
TimestampTz result;
PgStat_StatDBEntry *dbentry;
+ if (!DataChecksumsEnabled())
+ PG_RETURN_NULL();
+
if ((dbentry = pgstat_fetch_stat_dbentry(dbid)) == NULL)
result = 0;
else