children = find_all_inheritors(reloid, NoLock, NULL);
foreach(lc, children)
{
Oid childreloid = lfirst_oid(lc);
/* Parent already locked. */ if (childreloid == reloid) continue;
if (!nowait)
LockRelationOid(childreloid, lockmode); elseif (!ConditionalLockRelationOid(childreloid, lockmode))
{ /* try to throw error by name; relation could be deleted... */ char *relname = get_rel_name(childreloid);
if (!relname) continue; /* child concurrently dropped, just skip it */
ereport(ERROR,
(errcode(ERRCODE_LOCK_NOT_AVAILABLE),
errmsg("could not obtain lock on relation \"%s\"",
relname)));
}
typedefstruct
{
LOCKMODE lockmode; /* lock mode to use */ bool nowait; /* no wait mode */
Oid check_as_user; /* user for checking the privilege */
Oid viewoid; /* OID of the view to be locked */
List *ancestor_views; /* OIDs of ancestor views */
} LockViewRecurse_context;
/* Currently, we only allow plain tables or views to be locked. */ if (relkind != RELKIND_RELATION && relkind != RELKIND_PARTITIONED_TABLE &&
relkind != RELKIND_VIEW) continue;
/* *Wemightbedealingwithaself-referentialview.Ifso,we *canjuststoprecursing,sincewealreadylockedit.
*/ if (list_member_oid(context->ancestor_views, relid)) continue;
/* We have enough rights to lock the relation; do so. */ if (!context->nowait)
LockRelationOid(relid, context->lockmode); elseif (!ConditionalLockRelationOid(relid, context->lockmode))
ereport(ERROR,
(errcode(ERRCODE_LOCK_NOT_AVAILABLE),
errmsg("could not obtain lock on relation \"%s\"",
relname)));
¤ Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.0.11Bemerkung:
(vorverarbeitet am 2026-10-11)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.