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,