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

Commit252b707

Browse files
committed
Return NULL for checksum failures if checksums are not enabled
Returning 0 could falsely indicate that there is no problem. NULLcorrectly indicates that there is no information about potentialproblems.Also return 0 as numbackends instead of NULL for shared objects (as noconnection can be made to a shared object only).Author: Julien Rouhaud <rjuju123@gmail.com>Reviewed-by: Robert Treat <rob@xzilla.net>
1 parent9010156 commit252b707

File tree

4 files changed

+13
-4
lines changed

4 files changed

+13
-4
lines changed

‎doc/src/sgml/monitoring.sgml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2600,13 +2600,15 @@ SELECT pid, wait_event_type, wait_event FROM pg_stat_activity WHERE wait_event i
26002600
<entry><structfield>checksum_failures</structfield></entry>
26012601
<entry><type>bigint</type></entry>
26022602
<entry>Number of data page checksum failures detected in this
2603-
database</entry>
2603+
database (or on a shared object), or NULL if data checksums are not
2604+
enabled.</entry>
26042605
</row>
26052606
<row>
26062607
<entry><structfield>checksum_last_failure</structfield></entry>
26072608
<entry><type>timestamp with time zone</type></entry>
26082609
<entry>Time at which the last data page checksum failure was detected in
2609-
this database, or on a shared object.</entry>
2610+
this database (or on a shared object), or NULL if data checksums are not
2611+
enabled.</entry>
26102612
</row>
26112613
<row>
26122614
<entry><structfield>blk_read_time</structfield></entry>

‎src/backend/catalog/system_views.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -817,7 +817,7 @@ CREATE VIEW pg_stat_database AS
817817
D.oidAS datid,
818818
D.datnameAS datname,
819819
CASE
820-
WHEN (D.oid= (0)::oid) THENNULL::integer
820+
WHEN (D.oid= (0)::oid) THEN0
821821
ELSE pg_stat_get_db_numbackends(D.oid)
822822
ENDAS numbackends,
823823
pg_stat_get_db_xact_commit(D.oid)AS xact_commit,

‎src/backend/utils/adt/pgstatfuncs.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include"postgres.h"
1616

1717
#include"access/htup_details.h"
18+
#include"access/xlog.h"
1819
#include"catalog/pg_authid.h"
1920
#include"catalog/pg_type.h"
2021
#include"common/ip.h"
@@ -1526,6 +1527,9 @@ pg_stat_get_db_checksum_failures(PG_FUNCTION_ARGS)
15261527
int64result;
15271528
PgStat_StatDBEntry*dbentry;
15281529

1530+
if (!DataChecksumsEnabled())
1531+
PG_RETURN_NULL();
1532+
15291533
if ((dbentry=pgstat_fetch_stat_dbentry(dbid))==NULL)
15301534
result=0;
15311535
else
@@ -1541,6 +1545,9 @@ pg_stat_get_db_checksum_last_failure(PG_FUNCTION_ARGS)
15411545
TimestampTzresult;
15421546
PgStat_StatDBEntry*dbentry;
15431547

1548+
if (!DataChecksumsEnabled())
1549+
PG_RETURN_NULL();
1550+
15441551
if ((dbentry=pgstat_fetch_stat_dbentry(dbid))==NULL)
15451552
result=0;
15461553
else

‎src/test/regress/expected/rules.out

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1806,7 +1806,7 @@ pg_stat_bgwriter| SELECT pg_stat_get_bgwriter_timed_checkpoints() AS checkpoints
18061806
pg_stat_database| SELECT d.oid AS datid,
18071807
d.datname,
18081808
CASE
1809-
WHEN (d.oid = (0)::oid) THENNULL::integer
1809+
WHEN (d.oid = (0)::oid) THEN0
18101810
ELSE pg_stat_get_db_numbackends(d.oid)
18111811
END AS numbackends,
18121812
pg_stat_get_db_xact_commit(d.oid) AS xact_commit,

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp