replace magic num in struct cachedesc with CATCACHE_MAXKEYS
Hi hackers,
I noticed that there is a magic number which can be replaced by CATCACHE_MAXKEYS
in struct cachedesc, I checked some other struct like CatCache, CatCTup, they
all use CATCACHE_MAXKEYS.
I did some search on pg-hackers, and found an old thread[0]/messages/by-id/603c8f071003281532t5e6c68eex458825485d4fcd98@mail.gmail.com that
Robert proposed to change
the maximum number of keys for a syscache from 4 to 5.
It seems to me that the *five-key syscaches* feature is not necessary
since the idea was
14 years old and we still use 4 keys without any problems(I might be wrong).
However, in that patch, there is a change that seems reasonable.
--- a/src/backend/utils/cache/syscache.c
+++ b/src/backend/utils/cache/syscache.c
@@ -95,7 +95,7 @@ struct cachedesc
Oid reloid; /* OID of the
relation being cached */
Oid indoid; /* OID of
index relation for this cache */
int nkeys; /* # of keys
needed for cache lookup */
- int key[4]; /* attribute
numbers of key attrs */
+ int key[CATCACHE_MAXKEYS]; /* attribute
numbers of key attrs */
int nbuckets; /* number of
hash buckets for this cache */
};
[0]: /messages/by-id/603c8f071003281532t5e6c68eex458825485d4fcd98@mail.gmail.com
--
Regards
Junwang Zhao
Attachments:
v1-0001-replace-magic-num-with-CATCACHE_MAXKEYS.patchapplication/octet-stream; name=v1-0001-replace-magic-num-with-CATCACHE_MAXKEYS.patchDownload
From a12208dd668c440b68c4151bb5e9f7013468c358 Mon Sep 17 00:00:00 2001
From: Zhao Junwang <zhjwpku@gmail.com>
Date: Thu, 15 Aug 2024 07:01:52 +0000
Subject: [PATCH v1] replace magic num in struct cachedesc with CATCACHE_MAXKEYS
Signed-off-by: Zhao Junwang <zhjwpku@gmail.com>
---
src/backend/utils/cache/syscache.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/backend/utils/cache/syscache.c b/src/backend/utils/cache/syscache.c
index 3e03dfc991..793919c128 100644
--- a/src/backend/utils/cache/syscache.c
+++ b/src/backend/utils/cache/syscache.c
@@ -68,7 +68,7 @@ struct cachedesc
Oid reloid; /* OID of the relation being cached */
Oid indoid; /* OID of index relation for this cache */
int nkeys; /* # of keys needed for cache lookup */
- int key[4]; /* attribute numbers of key attrs */
+ int key[CATCACHE_MAXKEYS]; /* attribute numbers of key attrs */
int nbuckets; /* number of hash buckets for this cache */
};
--
2.39.2
On 15.08.24 12:25, Junwang Zhao wrote:
I noticed that there is a magic number which can be replaced by CATCACHE_MAXKEYS
in struct cachedesc, I checked some other struct like CatCache, CatCTup, they
all use CATCACHE_MAXKEYS.
The "syscache" is the only user of the "catcache" right now. But I
think they are formally separate. So I don't think the "4" in the
syscache is necessarily the same as CATCACHE_MAXKEYS. For example,
increasing CATCACHE_MAXKEYS, hypothetically, wouldn't by itself make the
syscache support more than 4 keys.
On Fri, Aug 23, 2024 at 9:02 PM Peter Eisentraut <peter@eisentraut.org> wrote:
On 15.08.24 12:25, Junwang Zhao wrote:
I noticed that there is a magic number which can be replaced by CATCACHE_MAXKEYS
in struct cachedesc, I checked some other struct like CatCache, CatCTup, they
all use CATCACHE_MAXKEYS.The "syscache" is the only user of the "catcache" right now. But I
think they are formally separate. So I don't think the "4" in the
syscache is necessarily the same as CATCACHE_MAXKEYS. For example,
increasing CATCACHE_MAXKEYS, hypothetically, wouldn't by itself make the
syscache support more than 4 keys.
Thanks for your explanation.
CF status changed to withdrawn.
--
Regards
Junwang Zhao