From d67995c0ab4c48c92b16fece5758ca14134615a3 Mon Sep 17 00:00:00 2001 From: Yugo Nagata Date: Fri, 1 Mar 2024 14:48:55 +0900 Subject: [PATCH] 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. --- pg_ivm.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/pg_ivm.c b/pg_ivm.c index ba14888..a1e6f27 100644 --- a/pg_ivm.c +++ b/pg_ivm.c @@ -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,