summaryrefslogtreecommitdiff
path: root/src/include/utils/pgstat_internal.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/include/utils/pgstat_internal.h')
-rw-r--r--src/include/utils/pgstat_internal.h17
1 files changed, 16 insertions, 1 deletions
diff --git a/src/include/utils/pgstat_internal.h b/src/include/utils/pgstat_internal.h
index 6cf00008f63..bf75ebcef31 100644
--- a/src/include/utils/pgstat_internal.h
+++ b/src/include/utils/pgstat_internal.h
@@ -48,7 +48,13 @@
* PgStatShared_Common as the first element.
*/
-/* struct for shared statistics hash entry key. */
+/*
+ * Struct for shared statistics hash entry key.
+ *
+ * NB: We assume that this struct contains no padding. Also, 8 bytes
+ * allocated for the object ID are good enough to ensure the uniqueness
+ * of the hash key, hence the addition of new fields is not recommended.
+ */
typedef struct PgStat_HashKey
{
PgStat_Kind kind; /* statistics entry kind */
@@ -58,6 +64,15 @@ typedef struct PgStat_HashKey
} PgStat_HashKey;
/*
+ * PgStat_HashKey should not have any padding. Checking that the structure
+ * size matches with the sum of each field is a check simple enough to
+ * enforce this policy.
+ */
+StaticAssertDecl((sizeof(PgStat_Kind) + sizeof(uint64) + sizeof(Oid)) ==
+ sizeof(PgStat_HashKey),
+ "PgStat_HashKey should have no padding");
+
+/*
* Shared statistics hash entry. Doesn't itself contain any stats, but points
* to them (with ->body). That allows the stats entries themselves to be of
* variable size.