| From: | Michael Paquier <michael(at)paquier(dot)xyz> |
|---|---|
| To: | Postgres hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
| Subject: | One-off with syscache ID in get_catalog_object_by_oid_extended() |
| Date: | 2026-02-17 22:30:21 |
| Message-ID: | aZTr_R6JGmqokUBb@paquier.xyz |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
Hi all,
While reviewing the syscache code, I have bumped into the following
funny bit in objectaddress.c:
if (oidCacheId > 0)
{
if (locktup)
tuple = SearchSysCacheLockedCopy1(oidCacheId,
ObjectIdGetDatum(objectId));
else
tuple = SearchSysCacheCopy1(oidCacheId,
ObjectIdGetDatum(objectId));
if (!HeapTupleIsValid(tuple)) /* should not happen */
return NULL;
}
This is wrong, because SysCacheIdentifier starts at 0. This has no
consequence currently, because the first value in the enum is
AGGFNOID, something that we don't rely on for object type lookups.
Even if this code had the idea to use an ID of 0, the logic would just
get back to a systable lookup, that would still work, that's just less
efficient.
Simple patch attached, planned for a backpatch quickly as I am playing
with a different patch that reworks a bit this code.
Regards,
--
Michael
| Attachment | Content-Type | Size |
|---|---|---|
| cacheid-oneoff.patch | text/plain | 503 bytes |
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Peter Smith | 2026-02-17 22:37:55 | DOCS - Add an "Options" section for pg_controldata |
| Previous Message | Nathan Bossart | 2026-02-17 22:29:53 | Re: Speed up COPY FROM text/CSV parsing using SIMD |