Subject: Re: ALTER TABLE SET ACCESS METHOD on partitioned tables

From: Zhihong Yu <[email-masked]>
Date: Wed, 18 May 2022 16:02:51 -0700

Hi,

+       tup = SearchSysCache1(RELOID, ObjectIdGetDatum(relid));
+       accessMethodId = ((Form_pg_class) GETSTRUCT(tup))->relam;

-   /* look up the access method, verify it is for a table */
-   if (accessMethod != NULL)
-       accessMethodId = get_table_am_oid(accessMethod, false);
+       if (!HeapTupleIsValid(tup))
+           elog(ERROR, "cache lookup failed for relation %u", relid);

Shouldn't the validity of tup be checked before relam field is accessed ?

Cheers