Postgresql 中文操作指南
53.48. pg_shdepend #
目录 pg_shdepend 记录了数据库对象和共享对象(如角色)之间的依赖关系。PostgreSQL 可以通过这些信息来确保在尝试删除这些对象之前,它们没有引用。
The catalog pg_shdepend records the dependency relationships between database objects and shared objects, such as roles. This information allows PostgreSQL to ensure that those objects are unreferenced before attempting to delete them.
另请参阅 pg_depend ,它为单个数据库内涉及对象的依赖关系执行类似的功能。
See also pg_depend, which performs a similar function for dependencies involving objects within a single database.
与大多数系统目录不同,pg_shdepend 在群集的所有数据库中共享:每个群集只有一个 pg_shdepend 副本,而不是每个数据库一个。
Unlike most system catalogs, pg_shdepend is shared across all databases of a cluster: there is only one copy of pg_shdepend per cluster, not one per database.
Table 53.48. pg_shdepend Columns
Table 53.48. pg_shdepend Columns
Column Type Description |
dbid oid (references pg_database.oid) The OID of the database the dependent object is in, or zero for a shared object |
classid oid (references pg_class.oid) The OID of the system catalog the dependent object is in |
objid oid (references any OID column) The OID of the specific dependent object |
objsubid int4 For a table column, this is the column number (the objid and classid refer to the table itself). For all other object types, this column is zero. |
refclassid oid (references pg_class.oid) The OID of the system catalog the referenced object is in (must be a shared catalog) |
refobjid oid (references any OID column) The OID of the specific referenced object |
deptype char A code defining the specific semantics of this dependency relationship; see text |
在所有情况下,pg_shdepend 项表示引用对象不能被丢弃,除非同时丢弃依赖对象。但是,有几个由 deptype 标识的子类别:
In all cases, a pg_shdepend entry indicates that the referenced object cannot be dropped without also dropping the dependent object. However, there are several subflavors identified by deptype:
-
SHARED_DEPENDENCY_OWNER (o)
-
The referenced object (which must be a role) is the owner of the dependent object.
-
-
SHARED_DEPENDENCY_ACL (a)
-
The referenced object (which must be a role) is mentioned in the ACL (access control list, i.e., privileges list) of the dependent object. (A SHARED_DEPENDENCY_ACL entry is not made for the owner of the object, since the owner will have a SHARED_DEPENDENCY_OWNER entry anyway.)
-
-
SHARED_DEPENDENCY_POLICY (r)
-
The referenced object (which must be a role) is mentioned as the target of a dependent policy object.
-
-
SHARED_DEPENDENCY_TABLESPACE (t)
-
The referenced object (which must be a tablespace) is mentioned as the tablespace for a relation that doesn’t have storage.
-
将来可能需要其他依赖关系类别。特别注意,当前定义仅支持角色和表空间作为引用对象。
Other dependency flavors might be needed in future. Note in particular that the current definition only supports roles and tablespaces as referenced objects.
与 pg_depend 目录类似,在 initdb 期间创建的大多数对象都被视为“固定的”。在 pg_shdepend 中不会创建任何以固定对象作为引用对象或依赖对象的项。
As in the pg_depend catalog, most objects created during initdb are considered “pinned”. No entries are made in pg_shdepend that would have a pinned object as either referenced or dependent object.