Fix an error raised when dropping pg_ivm extension

Previously, DROP EXTENSION pg_ivm failed due to the failure of
opening the index on pg_ivm_immv in PgIvmObjectAccessHook that is
called on dropping pg_ivm_immv, because when pg_ivm_immv is being
dropped, the index on it is already dropped.

This is fixed to return immediately from the hook function if the
dropped table is pg_ivm_immv.
This commit is contained in:
Yugo Nagata 2024-03-01 14:48:55 +09:00
parent 8f5bb5300a
commit d67995c0ab

View file

@ -390,9 +390,18 @@ PgIvmObjectAccessHook(ObjectAccessType access, Oid classId,
ScanKeyData key;
HeapTuple tup;
Oid pgIvmImmvOid = PgIvmImmvRelationId();
/* pg_ivm_immv is not created yet, so there are no IMMVs, either. */
if (pgIvmImmvOid == InvalidOid)
return;
/*
* When the dropped table is pg_ivm_immv, we don't need to continue
* any more. Also, in this case, the index on it is already dropped,
* so the index scan below will fail and raise an error.
*/
if (objectId == pgIvmImmOid)
return;
pgIvmImmv = table_open(pgIvmImmvOid, AccessShareLock);
ScanKeyInit(&key,