mirror of https://github.com/citusdata/citus.git
Not read heaptuple after closing pg_rewrite (#5255)
(cherry picked from commit cc49e63222
)
onder_10_1_comm
parent
6460fc45e4
commit
3bd991d215
|
@ -1212,18 +1212,31 @@ GetDependingView(Form_pg_depend pg_depend)
|
||||||
true, NULL, 1, rkey);
|
true, NULL, 1, rkey);
|
||||||
|
|
||||||
HeapTuple rewriteTup = systable_getnext(rscan);
|
HeapTuple rewriteTup = systable_getnext(rscan);
|
||||||
|
if (!HeapTupleIsValid(rewriteTup))
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
* This function already verified that objid's classid is
|
||||||
|
* RewriteRelationId, so it should exists. But be on the
|
||||||
|
* safe side.
|
||||||
|
*/
|
||||||
|
ereport(ERROR, (errmsg("catalog lookup failed for view %u",
|
||||||
|
pg_depend->objid)));
|
||||||
|
}
|
||||||
|
|
||||||
Form_pg_rewrite pg_rewrite = (Form_pg_rewrite) GETSTRUCT(rewriteTup);
|
Form_pg_rewrite pg_rewrite = (Form_pg_rewrite) GETSTRUCT(rewriteTup);
|
||||||
|
|
||||||
bool isView = get_rel_relkind(pg_rewrite->ev_class) == RELKIND_VIEW;
|
bool isView = get_rel_relkind(pg_rewrite->ev_class) == RELKIND_VIEW;
|
||||||
bool isMatView = get_rel_relkind(pg_rewrite->ev_class) == RELKIND_MATVIEW;
|
bool isMatView = get_rel_relkind(pg_rewrite->ev_class) == RELKIND_MATVIEW;
|
||||||
bool isDifferentThanRef = pg_rewrite->ev_class != pg_depend->refobjid;
|
bool isDifferentThanRef = pg_rewrite->ev_class != pg_depend->refobjid;
|
||||||
|
|
||||||
|
Oid dependingView = InvalidOid;
|
||||||
|
if ((isView || isMatView) && isDifferentThanRef)
|
||||||
|
{
|
||||||
|
dependingView = pg_rewrite->ev_class;
|
||||||
|
}
|
||||||
|
|
||||||
systable_endscan(rscan);
|
systable_endscan(rscan);
|
||||||
relation_close(rewriteRel, AccessShareLock);
|
relation_close(rewriteRel, AccessShareLock);
|
||||||
|
|
||||||
if ((isView || isMatView) && isDifferentThanRef)
|
return dependingView;
|
||||||
{
|
|
||||||
return pg_rewrite->ev_class;
|
|
||||||
}
|
|
||||||
return InvalidOid;
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue