replace magic num in struct cachedesc with CATCACHE_MAXKEYS

From: Junwang Zhao <zhjwpku(at)gmail(dot)com>
To: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: replace magic num in struct cachedesc with CATCACHE_MAXKEYS
Date: 2024-08-15 10:25:13
Message-ID: CAEG8a3KypEJPtZ5DYuaFY+2SYQ3rR7QcvcWhZrYw9C9utJ9W_g@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

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] 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]: https://www.postgresql.org/message-id/flat/603c8f071003281532t5e6c68eex458825485d4fcd98%40mail.gmail.com

--
Regards
Junwang Zhao

Attachment Content-Type Size
v1-0001-replace-magic-num-with-CATCACHE_MAXKEYS.patch application/octet-stream 989 bytes

Browse pgsql-hackers by date

  From Date Subject
Next Message Aleksander Alekseev 2024-08-15 10:58:03 Re: [PATCH] Add get_bytes() and set_bytes() functions
Previous Message Dean Rasheed 2024-08-15 10:14:55 Re: [PATCH] Add get_bytes() and set_bytes() functions