aboutsummaryrefslogtreecommitdiff
path: root/src/backend/utils/adt/lockfuncs.c
diff options
context:
space:
mode:
authorMichael Paquier <michael@paquier.xyz>2020-02-03 14:48:42 +0900
committerMichael Paquier <michael@paquier.xyz>2020-02-03 14:48:42 +0900
commitf1f10a1ba9e17e606a7b217ccccdd3cc4d8cb771 (patch)
tree2ad0e6861232bcef32bc0924469de3958b86cdb4 /src/backend/utils/adt/lockfuncs.c
parent6148e2b9a6399b77e10e277c32d701b84703820f (diff)
downloadpostgresql-f1f10a1ba9e17e606a7b217ccccdd3cc4d8cb771.tar.gz
postgresql-f1f10a1ba9e17e606a7b217ccccdd3cc4d8cb771.zip
Add declaration-level assertions for compile-time checks
Those new assertions can be used at file scope, outside of any function for compilation checks. This commit provides implementations for C and C++, and fallback implementations. Author: Peter Smith Reviewed-by: Andres Freund, Kyotaro Horiguchi, Dagfinn Ilmari Mannsåker, Michael Paquier Discussion: https://postgr.es/m/201DD0641B056142AC8C6645EC1B5F62014B8E8030@SYD1217
Diffstat (limited to 'src/backend/utils/adt/lockfuncs.c')
-rw-r--r--src/backend/utils/adt/lockfuncs.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/backend/utils/adt/lockfuncs.c b/src/backend/utils/adt/lockfuncs.c
index 9a7da12a5b7..7e47ebeb6f6 100644
--- a/src/backend/utils/adt/lockfuncs.c
+++ b/src/backend/utils/adt/lockfuncs.c
@@ -36,6 +36,9 @@ const char *const LockTagTypeNames[] = {
"advisory"
};
+StaticAssertDecl(lengthof(LockTagTypeNames) == (LOCKTAG_ADVISORY + 1),
+ "array length mismatch");
+
/* This must match enum PredicateLockTargetType (predicate_internals.h) */
static const char *const PredicateLockTagTypeNames[] = {
"relation",
@@ -43,6 +46,9 @@ static const char *const PredicateLockTagTypeNames[] = {
"tuple"
};
+StaticAssertDecl(lengthof(PredicateLockTagTypeNames) == (PREDLOCKTAG_TUPLE + 1),
+ "array length mismatch");
+
/* Working status for pg_lock_status */
typedef struct
{