aboutsummaryrefslogtreecommitdiff
path: root/src/backend/utils/adt/pgstatfuncs.c
diff options
context:
space:
mode:
authorAndres Freund <andres@anarazel.de>2022-04-07 00:03:58 -0700
committerAndres Freund <andres@anarazel.de>2022-04-07 00:21:54 -0700
commitad401664b8012cafb64e8fce33fe40356c5bc686 (patch)
tree96cf785f2e29948d53d5e850dfccea8021d3bf5e /src/backend/utils/adt/pgstatfuncs.c
parent0f96965c658147d6d6bad096d2d4a2c9c665f4a9 (diff)
downloadpostgresql-ad401664b8012cafb64e8fce33fe40356c5bc686.tar.gz
postgresql-ad401664b8012cafb64e8fce33fe40356c5bc686.zip
pgstat: add pg_stat_have_stats() test helper.
Will be used by tests committed subsequently. Bumps catversion (this time for real, the one in 0f96965c658 got lost when rebasing over 5c279a6d350). Author: Melanie Plageman <melanieplageman@gmail.com> Discussion: https://postgr.es/m/CAAKRu_aNxL1WegCa45r=VAViCLnpOU7uNC7bTtGw+=QAPyYivw@mail.gmail.com
Diffstat (limited to 'src/backend/utils/adt/pgstatfuncs.c')
-rw-r--r--src/backend/utils/adt/pgstatfuncs.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/backend/utils/adt/pgstatfuncs.c b/src/backend/utils/adt/pgstatfuncs.c
index 5f1815727de..2bf8ab8f986 100644
--- a/src/backend/utils/adt/pgstatfuncs.c
+++ b/src/backend/utils/adt/pgstatfuncs.c
@@ -2394,3 +2394,21 @@ pg_stat_get_subscription_stats(PG_FUNCTION_ARGS)
/* Returns the record as Datum */
PG_RETURN_DATUM(HeapTupleGetDatum(heap_form_tuple(tupdesc, values, nulls)));
}
+
+/*
+ * Checks for presence of stats for object with provided kind, database oid,
+ * object oid.
+ *
+ * This is useful for tests, but not really anything else. Therefore not
+ * documented.
+ */
+Datum
+pg_stat_have_stats(PG_FUNCTION_ARGS)
+{
+ char *stats_type = text_to_cstring(PG_GETARG_TEXT_P(0));
+ Oid dboid = PG_GETARG_OID(1);
+ Oid objoid = PG_GETARG_OID(2);
+ PgStat_Kind kind = pgstat_get_kind_from_str(stats_type);
+
+ PG_RETURN_BOOL(pgstat_have_entry(kind, dboid, objoid));
+}