Check if PgIvmImmvRelationId is invalid before open it (#78)
When pg_ivm is installed shared_preload_libraries without executing CREATE EXTENSION command, the hook function is set while the catalog table pg_ivm_immv is not created. In this case, the hook function failed to open the catalog table and an error was raised. Although this way of installing pg_ivm was not considered, it would be nice to reduce any possible troubles on users. Therefore, to prevent this error, check if PgIvmImmvRelationId is invalid before open it. When this is invalid, pg_ivm_immv relation is not created yet, so there are not any IMMVs, so we don't have to do anything in this hook function. Review and commit message by Yugo Nagata
This commit is contained in:
parent
01f0ea0eb1
commit
8f5bb5300a
1 changed files with 7 additions and 2 deletions
9
pg_ivm.c
9
pg_ivm.c
|
|
@ -385,11 +385,16 @@ PgIvmObjectAccessHook(ObjectAccessType access, Oid classId,
|
|||
|
||||
if (access == OAT_DROP && classId == RelationRelationId && !OidIsValid(subId))
|
||||
{
|
||||
Relation pgIvmImmv = table_open(PgIvmImmvRelationId(), AccessShareLock);
|
||||
Relation pgIvmImmv;
|
||||
SysScanDesc scan;
|
||||
ScanKeyData key;
|
||||
HeapTuple tup;
|
||||
|
||||
Oid pgIvmImmvOid = PgIvmImmvRelationId();
|
||||
|
||||
if (pgIvmImmvOid == InvalidOid)
|
||||
return;
|
||||
|
||||
pgIvmImmv = table_open(pgIvmImmvOid, AccessShareLock);
|
||||
ScanKeyInit(&key,
|
||||
Anum_pg_ivm_immv_immvrelid,
|
||||
BTEqualStrategyNumber, F_OIDEQ,
|
||||
|
|
|
|||
Loading…
Reference in a new issue