diff options
author | Michael Paquier <michael@paquier.xyz> | 2023-07-27 10:55:16 +0900 |
---|---|---|
committer | Michael Paquier <michael@paquier.xyz> | 2023-07-27 10:55:16 +0900 |
commit | f6a84546b1a0ae43c00a7f351bc45fbde342466a (patch) | |
tree | 019a2ed9e05b1ef3ac233a376177d4e033613beb /src/backend/utils/cache/syscache.c | |
parent | 31de7e60da34761365f94dc76cc2c1bf2172d1bc (diff) | |
download | postgresql-f6a84546b1a0ae43c00a7f351bc45fbde342466a.tar.gz postgresql-f6a84546b1a0ae43c00a7f351bc45fbde342466a.zip |
Add sanity asserts for index OID and attnums during cache init
There was already a check on the relation OID, but not its index OID and
the attributes that can be used during the syscache lookups. The two
assertions added by this commit are cheap, and actually useful for
developers to fasten the detection of incorrect data in a new entry
added in the syscache list, as these assertions are triggered during the
initial cache loading (initdb, or just backend startup), not requiring a
syscache that uses the new entry.
While on it, the relation OID check is switched to use OidIsValid().
Author: Aleksander Alekseev
Reviewed-by: Dagfinn Ilmari Mannsåker, Zhang Mingli, Michael Paquier
Discussion: https://postgr.es/m/CAJ7c6TOjUTJ0jxvWY6oJeP2-840OF8ch7qscZQsuVuotXTOS_g@mail.gmail.com
Diffstat (limited to 'src/backend/utils/cache/syscache.c')
-rw-r--r-- | src/backend/utils/cache/syscache.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/backend/utils/cache/syscache.c b/src/backend/utils/cache/syscache.c index 4e4a34bde80..8dbda0024f9 100644 --- a/src/backend/utils/cache/syscache.c +++ b/src/backend/utils/cache/syscache.c @@ -720,7 +720,9 @@ InitCatalogCache(void) * Assert that every enumeration value defined in syscache.h has been * populated in the cacheinfo array. */ - Assert(cacheinfo[cacheId].reloid != 0); + Assert(OidIsValid(cacheinfo[cacheId].reloid)); + Assert(OidIsValid(cacheinfo[cacheId].indoid)); + /* .nbuckets and .key[] are checked by InitCatCache() */ SysCache[cacheId] = InitCatCache(cacheId, cacheinfo[cacheId].reloid, |