]> begriffs open source - ai-pg/blob - full-docs/src/sgml/html/catalog-pg-depend.html
WIP: toc builder
[ai-pg] / full-docs / src / sgml / html / catalog-pg-depend.html
1 <?xml version="1.0" encoding="UTF-8" standalone="no"?>
2 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>52.18. pg_depend</title><link rel="stylesheet" type="text/css" href="stylesheet.css" /><link rev="made" href="pgsql-docs@lists.postgresql.org" /><meta name="generator" content="DocBook XSL Stylesheets Vsnapshot" /><link rel="prev" href="catalog-pg-default-acl.html" title="52.17. pg_default_acl" /><link rel="next" href="catalog-pg-description.html" title="52.19. pg_description" /></head><body id="docContent" class="container-fluid col-10"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="5" align="center">52.18. <code class="structname">pg_depend</code></th></tr><tr><td width="10%" align="left"><a accesskey="p" href="catalog-pg-default-acl.html" title="52.17. pg_default_acl">Prev</a> </td><td width="10%" align="left"><a accesskey="u" href="catalogs.html" title="Chapter 52. System Catalogs">Up</a></td><th width="60%" align="center">Chapter 52. System Catalogs</th><td width="10%" align="right"><a accesskey="h" href="index.html" title="PostgreSQL 18.0 Documentation">Home</a></td><td width="10%" align="right"> <a accesskey="n" href="catalog-pg-description.html" title="52.19. pg_description">Next</a></td></tr></table><hr /></div><div class="sect1" id="CATALOG-PG-DEPEND"><div class="titlepage"><div><div><h2 class="title" style="clear: both">52.18. <code class="structname">pg_depend</code> <a href="#CATALOG-PG-DEPEND" class="id_link">#</a></h2></div></div></div><a id="id-1.10.4.20.2" class="indexterm"></a><p>
3    The catalog <code class="structname">pg_depend</code> records the dependency
4    relationships between database objects.  This information allows
5    <code class="command">DROP</code> commands to find which other objects must be dropped
6    by <code class="command">DROP CASCADE</code> or prevent dropping in the <code class="command">DROP
7    RESTRICT</code> case.
8   </p><p>
9    See also <a class="link" href="catalog-pg-shdepend.html" title="52.48. pg_shdepend"><code class="structname">pg_shdepend</code></a>,
10    which performs a similar function for dependencies involving objects
11    that are shared across a database cluster.
12   </p><div class="table" id="id-1.10.4.20.5"><p class="title"><strong>Table 52.18. <code class="structname">pg_depend</code> Columns</strong></p><div class="table-contents"><table class="table" summary="pg_depend Columns" border="1"><colgroup><col /></colgroup><thead><tr><th class="catalog_table_entry"><p class="column_definition">
13        Column Type
14       </p>
15       <p>
16        Description
17       </p></th></tr></thead><tbody><tr><td class="catalog_table_entry"><p class="column_definition">
18        <code class="structfield">classid</code> <code class="type">oid</code>
19        (references <a class="link" href="catalog-pg-class.html" title="52.11. pg_class"><code class="structname">pg_class</code></a>.<code class="structfield">oid</code>)
20       </p>
21       <p>
22        The OID of the system catalog the dependent object is in
23       </p></td></tr><tr><td class="catalog_table_entry"><p class="column_definition">
24        <code class="structfield">objid</code> <code class="type">oid</code>
25        (references any OID column)
26       </p>
27       <p>
28        The OID of the specific dependent object
29       </p></td></tr><tr><td class="catalog_table_entry"><p class="column_definition">
30        <code class="structfield">objsubid</code> <code class="type">int4</code>
31       </p>
32       <p>
33        For a table column, this is the column number (the
34        <code class="structfield">objid</code> and <code class="structfield">classid</code> refer to the
35        table itself).  For all other object types, this column is
36        zero.
37       </p></td></tr><tr><td class="catalog_table_entry"><p class="column_definition">
38        <code class="structfield">refclassid</code> <code class="type">oid</code>
39        (references <a class="link" href="catalog-pg-class.html" title="52.11. pg_class"><code class="structname">pg_class</code></a>.<code class="structfield">oid</code>)
40       </p>
41       <p>
42        The OID of the system catalog the referenced object is in
43       </p></td></tr><tr><td class="catalog_table_entry"><p class="column_definition">
44        <code class="structfield">refobjid</code> <code class="type">oid</code>
45        (references any OID column)
46       </p>
47       <p>
48        The OID of the specific referenced object
49       </p></td></tr><tr><td class="catalog_table_entry"><p class="column_definition">
50        <code class="structfield">refobjsubid</code> <code class="type">int4</code>
51       </p>
52       <p>
53        For a table column, this is the column number (the
54        <code class="structfield">refobjid</code> and <code class="structfield">refclassid</code> refer
55        to the table itself).  For all other object types, this column
56        is zero.
57       </p></td></tr><tr><td class="catalog_table_entry"><p class="column_definition">
58        <code class="structfield">deptype</code> <code class="type">char</code>
59       </p>
60       <p>
61        A code defining the specific semantics of this dependency relationship; see text
62       </p></td></tr></tbody></table></div></div><br class="table-break" /><p>
63    In all cases, a <code class="structname">pg_depend</code> entry indicates that the
64    referenced object cannot be dropped without also dropping the dependent
65    object.  However, there are several subflavors identified by
66    <code class="structfield">deptype</code>:
67
68    </p><div class="variablelist"><dl class="variablelist"><dt><span class="term"><code class="symbol">DEPENDENCY_NORMAL</code> (<code class="literal">n</code>)</span></dt><dd><p>
69        A normal relationship between separately-created objects.  The
70        dependent object can be dropped without affecting the
71        referenced object.  The referenced object can only be dropped
72        by specifying <code class="literal">CASCADE</code>, in which case the dependent
73        object is dropped, too.  Example: a table column has a normal
74        dependency on its data type.
75       </p></dd><dt><span class="term"><code class="symbol">DEPENDENCY_AUTO</code> (<code class="literal">a</code>)</span></dt><dd><p>
76        The dependent object can be dropped separately from the
77        referenced object, and should be automatically dropped
78        (regardless of <code class="literal">RESTRICT</code> or <code class="literal">CASCADE</code>
79        mode) if the referenced object is dropped.  Example: a named
80        constraint on a table is made auto-dependent on the table, so
81        that it will go away if the table is dropped.
82       </p></dd><dt><span class="term"><code class="symbol">DEPENDENCY_INTERNAL</code> (<code class="literal">i</code>)</span></dt><dd><p>
83        The dependent object was created as part of creation of the
84        referenced object, and is really just a part of its internal
85        implementation.  A direct <code class="command">DROP</code> of the dependent
86        object will be disallowed outright (we'll tell the user to issue
87        a <code class="command">DROP</code> against the referenced object, instead).
88        A <code class="command">DROP</code> of the referenced object will result in
89        automatically dropping the dependent object
90        whether <code class="literal">CASCADE</code> is specified or not.  If the
91        dependent object has to be dropped due to a dependency on some other
92        object being removed, its drop is converted to a drop of the referenced
93        object, so that <code class="literal">NORMAL</code> and <code class="literal">AUTO</code>
94        dependencies of the dependent object behave much like they were
95        dependencies of the referenced object.
96        Example: a view's <code class="literal">ON SELECT</code> rule is made
97        internally dependent on the view, preventing it from being dropped
98        while the view remains.  Dependencies of the rule (such as tables it
99        refers to) act as if they were dependencies of the view.
100       </p></dd><dt><span class="term"><code class="symbol">DEPENDENCY_PARTITION_PRI</code> (<code class="literal">P</code>)<br /></span><span class="term"><code class="symbol">DEPENDENCY_PARTITION_SEC</code> (<code class="literal">S</code>)</span></dt><dd><p>
101        The dependent object was created as part of creation of the
102        referenced object, and is really just a part of its internal
103        implementation; however, unlike <code class="literal">INTERNAL</code>,
104        there is more than one such referenced object.  The dependent object
105        must not be dropped unless at least one of these referenced objects
106        is dropped; if any one is, the dependent object should be dropped
107        whether or not <code class="literal">CASCADE</code> is specified.  Also
108        unlike <code class="literal">INTERNAL</code>, a drop of some other object
109        that the dependent object depends on does not result in automatic
110        deletion of any partition-referenced object.  Hence, if the drop
111        does not cascade to at least one of these objects via some other
112        path, it will be refused.  (In most cases, the dependent object
113        shares all its non-partition dependencies with at least one
114        partition-referenced object, so that this restriction does not
115        result in blocking any cascaded delete.)
116        Primary and secondary partition dependencies behave identically
117        except that the primary dependency is preferred for use in error
118        messages; hence, a partition-dependent object should have one
119        primary partition dependency and one or more secondary partition
120        dependencies.
121        Note that partition dependencies are made in addition to, not
122        instead of, any dependencies the object would normally have.  This
123        simplifies <code class="command">ATTACH/DETACH PARTITION</code> operations:
124        the partition dependencies need only be added or removed.
125        Example: a child partitioned index is made partition-dependent
126        on both the partition table it is on and the parent partitioned
127        index, so that it goes away if either of those is dropped, but
128        not otherwise.  The dependency on the parent index is primary,
129        so that if the user tries to drop the child partitioned index,
130        the error message will suggest dropping the parent index instead
131        (not the table).
132       </p></dd><dt><span class="term"><code class="symbol">DEPENDENCY_EXTENSION</code> (<code class="literal">e</code>)</span></dt><dd><p>
133        The dependent object is a member of the <em class="firstterm">extension</em> that is
134        the referenced object (see
135        <a class="link" href="catalog-pg-extension.html" title="52.22. pg_extension"><code class="structname">pg_extension</code></a>).
136        The dependent object can be dropped only via
137        <a class="link" href="sql-dropextension.html" title="DROP EXTENSION"><code class="command">DROP EXTENSION</code></a> on the referenced object.
138        Functionally this dependency type acts the same as
139        an <code class="literal">INTERNAL</code> dependency, but it's kept separate for
140        clarity and to simplify <span class="application">pg_dump</span>.
141       </p></dd><dt><span class="term"><code class="symbol">DEPENDENCY_AUTO_EXTENSION</code> (<code class="literal">x</code>)</span></dt><dd><p>
142        The dependent object is not a member of the extension that is the
143        referenced object (and so it should not be ignored
144        by <span class="application">pg_dump</span>), but it cannot function
145        without the extension and should be auto-dropped if the extension is.
146        The dependent object may be dropped on its own as well.
147        Functionally this dependency type acts the same as
148        an <code class="literal">AUTO</code> dependency, but it's kept separate for
149        clarity and to simplify <span class="application">pg_dump</span>.
150       </p></dd></dl></div><p>
151
152    Other dependency flavors might be needed in future.
153   </p><p>
154    Note that it's quite possible for two objects to be linked by more than
155    one <code class="structname">pg_depend</code> entry.  For example, a child
156    partitioned index would have both a partition-type dependency on its
157    associated partition table, and an auto dependency on each column of
158    that table that it indexes.  This sort of situation expresses the union
159    of multiple dependency semantics.  A dependent object can be dropped
160    without <code class="literal">CASCADE</code> if any of its dependencies satisfies
161    its condition for automatic dropping.  Conversely, all the
162    dependencies' restrictions about which objects must be dropped together
163    must be satisfied.
164   </p><p>
165    Most objects created during <span class="application">initdb</span> are
166    considered <span class="quote">“<span class="quote">pinned</span>”</span>, which means that the system itself
167    depends on them.  Therefore, they are never allowed to be dropped.
168    Also, knowing that pinned objects will not be dropped, the dependency
169    mechanism doesn't bother to make <code class="structname">pg_depend</code>
170    entries showing dependencies on them.  Thus, for example, a table
171    column of type <code class="type">numeric</code> notionally has
172    a <code class="literal">NORMAL</code> dependency on the <code class="type">numeric</code>
173    data type, but no such entry actually appears
174    in <code class="structname">pg_depend</code>.
175   </p></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="catalog-pg-default-acl.html" title="52.17. pg_default_acl">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="catalogs.html" title="Chapter 52. System Catalogs">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="catalog-pg-description.html" title="52.19. pg_description">Next</a></td></tr><tr><td width="40%" align="left" valign="top">52.17. <code class="structname">pg_default_acl</code> </td><td width="20%" align="center"><a accesskey="h" href="index.html" title="PostgreSQL 18.0 Documentation">Home</a></td><td width="40%" align="right" valign="top"> 52.19. <code class="structname">pg_description</code></td></tr></table></div></body></html>