summaryrefslogtreecommitdiffstats
path: root/doc/src/sgml/html/catalog-pg-depend.html
blob: 9f783b644748c8abe6425b4cf810f181a31ddbd0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!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>51.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 V1.79.1" /><link rel="prev" href="catalog-pg-default-acl.html" title="51.17. pg_default_acl" /><link rel="next" href="catalog-pg-description.html" title="51.19. pg_description" /></head><body id="docContent" class="container-fluid col-10"><div xmlns="http://www.w3.org/TR/xhtml1/transitional" class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="5" align="center">51.18. <code xmlns="http://www.w3.org/1999/xhtml" class="structname">pg_depend</code></th></tr><tr><td width="10%" align="left"><a accesskey="p" href="catalog-pg-default-acl.html" title="51.17. pg_default_acl">Prev</a> </td><td width="10%" align="left"><a accesskey="u" href="catalogs.html" title="Chapter 51. System Catalogs">Up</a></td><th width="60%" align="center">Chapter 51. System Catalogs</th><td width="10%" align="right"><a accesskey="h" href="index.html" title="PostgreSQL 13.4 Documentation">Home</a></td><td width="10%" align="right"> <a accesskey="n" href="catalog-pg-description.html" title="51.19. pg_description">Next</a></td></tr></table><hr></hr></div><div class="sect1" id="CATALOG-PG-DEPEND"><div class="titlepage"><div><div><h2 class="title" style="clear: both">51.18. <code class="structname">pg_depend</code></h2></div></div></div><a id="id-1.10.4.20.2" class="indexterm"></a><p>
   The catalog <code class="structname">pg_depend</code> records the dependency
   relationships between database objects.  This information allows
   <code class="command">DROP</code> commands to find which other objects must be dropped
   by <code class="command">DROP CASCADE</code> or prevent dropping in the <code class="command">DROP
   RESTRICT</code> case.
  </p><p>
   See also <a class="link" href="catalog-pg-shdepend.html" title="51.46. pg_shdepend"><code class="structname">pg_shdepend</code></a>,
   which performs a similar function for dependencies involving objects
   that are shared across a database cluster.
  </p><div class="table" id="id-1.10.4.20.5"><p class="title"><strong>Table 51.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">
       Column Type
      </p>
      <p>
       Description
      </p></th></tr></thead><tbody><tr><td class="catalog_table_entry"><p class="column_definition">
       <code class="structfield">classid</code> <code class="type">oid</code>
       (references <a class="link" href="catalog-pg-class.html" title="51.11. pg_class"><code class="structname">pg_class</code></a>.<code class="structfield">oid</code>)
      </p>
      <p>
       The OID of the system catalog the dependent object is in
      </p></td></tr><tr><td class="catalog_table_entry"><p class="column_definition">
       <code class="structfield">objid</code> <code class="type">oid</code>
       (references any OID column)
      </p>
      <p>
       The OID of the specific dependent object
      </p></td></tr><tr><td class="catalog_table_entry"><p class="column_definition">
       <code class="structfield">objsubid</code> <code class="type">int4</code>
      </p>
      <p>
       For a table column, this is the column number (the
       <code class="structfield">objid</code> and <code class="structfield">classid</code> refer to the
       table itself).  For all other object types, this column is
       zero.
      </p></td></tr><tr><td class="catalog_table_entry"><p class="column_definition">
       <code class="structfield">refclassid</code> <code class="type">oid</code>
       (references <a class="link" href="catalog-pg-class.html" title="51.11. pg_class"><code class="structname">pg_class</code></a>.<code class="structfield">oid</code>)
      </p>
      <p>
       The OID of the system catalog the referenced object is in
      </p></td></tr><tr><td class="catalog_table_entry"><p class="column_definition">
       <code class="structfield">refobjid</code> <code class="type">oid</code>
       (references any OID column)
      </p>
      <p>
       The OID of the specific referenced object
      </p></td></tr><tr><td class="catalog_table_entry"><p class="column_definition">
       <code class="structfield">refobjsubid</code> <code class="type">int4</code>
      </p>
      <p>
       For a table column, this is the column number (the
       <code class="structfield">refobjid</code> and <code class="structfield">refclassid</code> refer
       to the table itself).  For all other object types, this column
       is zero.
      </p></td></tr><tr><td class="catalog_table_entry"><p class="column_definition">
       <code class="structfield">deptype</code> <code class="type">char</code>
      </p>
      <p>
       A code defining the specific semantics of this dependency relationship; see text
      </p></td></tr></tbody></table></div></div><br class="table-break" /><p>
   In all cases, a <code class="structname">pg_depend</code> entry indicates that the
   referenced object cannot be dropped without also dropping the dependent
   object.  However, there are several subflavors identified by
   <code class="structfield">deptype</code>:

   </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>
       A normal relationship between separately-created objects.  The
       dependent object can be dropped without affecting the
       referenced object.  The referenced object can only be dropped
       by specifying <code class="literal">CASCADE</code>, in which case the dependent
       object is dropped, too.  Example: a table column has a normal
       dependency on its data type.
      </p></dd><dt><span class="term"><code class="symbol">DEPENDENCY_AUTO</code> (<code class="literal">a</code>)</span></dt><dd><p>
       The dependent object can be dropped separately from the
       referenced object, and should be automatically dropped
       (regardless of <code class="literal">RESTRICT</code> or <code class="literal">CASCADE</code>
       mode) if the referenced object is dropped.  Example: a named
       constraint on a table is made auto-dependent on the table, so
       that it will go away if the table is dropped.
      </p></dd><dt><span class="term"><code class="symbol">DEPENDENCY_INTERNAL</code> (<code class="literal">i</code>)</span></dt><dd><p>
       The dependent object was created as part of creation of the
       referenced object, and is really just a part of its internal
       implementation.  A direct <code class="command">DROP</code> of the dependent
       object will be disallowed outright (we'll tell the user to issue
       a <code class="command">DROP</code> against the referenced object, instead).
       A <code class="command">DROP</code> of the referenced object will result in
       automatically dropping the dependent object
       whether <code class="literal">CASCADE</code> is specified or not.  If the
       dependent object has to be dropped due to a dependency on some other
       object being removed, its drop is converted to a drop of the referenced
       object, so that <code class="literal">NORMAL</code> and <code class="literal">AUTO</code>
       dependencies of the dependent object behave much like they were
       dependencies of the referenced object.
       Example: a view's <code class="literal">ON SELECT</code> rule is made
       internally dependent on the view, preventing it from being dropped
       while the view remains.  Dependencies of the rule (such as tables it
       refers to) act as if they were dependencies of the view.
      </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>
       The dependent object was created as part of creation of the
       referenced object, and is really just a part of its internal
       implementation; however, unlike <code class="literal">INTERNAL</code>,
       there is more than one such referenced object.  The dependent object
       must not be dropped unless at least one of these referenced objects
       is dropped; if any one is, the dependent object should be dropped
       whether or not <code class="literal">CASCADE</code> is specified.  Also
       unlike <code class="literal">INTERNAL</code>, a drop of some other object
       that the dependent object depends on does not result in automatic
       deletion of any partition-referenced object.  Hence, if the drop
       does not cascade to at least one of these objects via some other
       path, it will be refused.  (In most cases, the dependent object
       shares all its non-partition dependencies with at least one
       partition-referenced object, so that this restriction does not
       result in blocking any cascaded delete.)
       Primary and secondary partition dependencies behave identically
       except that the primary dependency is preferred for use in error
       messages; hence, a partition-dependent object should have one
       primary partition dependency and one or more secondary partition
       dependencies.
       Note that partition dependencies are made in addition to, not
       instead of, any dependencies the object would normally have.  This
       simplifies <code class="command">ATTACH/DETACH PARTITION</code> operations:
       the partition dependencies need only be added or removed.
       Example: a child partitioned index is made partition-dependent
       on both the partition table it is on and the parent partitioned
       index, so that it goes away if either of those is dropped, but
       not otherwise.  The dependency on the parent index is primary,
       so that if the user tries to drop the child partitioned index,
       the error message will suggest dropping the parent index instead
       (not the table).
      </p></dd><dt><span class="term"><code class="symbol">DEPENDENCY_EXTENSION</code> (<code class="literal">e</code>)</span></dt><dd><p>
       The dependent object is a member of the <em class="firstterm">extension</em> that is
       the referenced object (see
       <a class="link" href="catalog-pg-extension.html" title="51.22. pg_extension"><code class="structname">pg_extension</code></a>).
       The dependent object can be dropped only via
       <code class="command">DROP EXTENSION</code> on the referenced object.
       Functionally this dependency type acts the same as
       an <code class="literal">INTERNAL</code> dependency, but it's kept separate for
       clarity and to simplify <span class="application">pg_dump</span>.
      </p></dd><dt><span class="term"><code class="symbol">DEPENDENCY_AUTO_EXTENSION</code> (<code class="literal">x</code>)</span></dt><dd><p>
       The dependent object is not a member of the extension that is the
       referenced object (and so it should not be ignored
       by <span class="application">pg_dump</span>), but it cannot function
       without the extension and should be auto-dropped if the extension is.
       The dependent object may be dropped on its own as well.
       Functionally this dependency type acts the same as
       an <code class="literal">AUTO</code> dependency, but it's kept separate for
       clarity and to simplify <span class="application">pg_dump</span>.
      </p></dd><dt><span class="term"><code class="symbol">DEPENDENCY_PIN</code> (<code class="literal">p</code>)</span></dt><dd><p>
       There is no dependent object; this type of entry is a signal
       that the system itself depends on the referenced object, and so
       that object must never be deleted.  Entries of this type are
       created only by <code class="command">initdb</code>.  The columns for the
       dependent object contain zeroes.
      </p></dd></dl></div><p>

   Other dependency flavors might be needed in future.
  </p><p>
   Note that it's quite possible for two objects to be linked by more than
   one <code class="structname">pg_depend</code> entry.  For example, a child
   partitioned index would have both a partition-type dependency on its
   associated partition table, and an auto dependency on each column of
   that table that it indexes.  This sort of situation expresses the union
   of multiple dependency semantics.  A dependent object can be dropped
   without <code class="literal">CASCADE</code> if any of its dependencies satisfies
   its condition for automatic dropping.  Conversely, all the
   dependencies' restrictions about which objects must be dropped together
   must be satisfied.
  </p></div><div xmlns="http://www.w3.org/TR/xhtml1/transitional" class="navfooter"><hr></hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="catalog-pg-default-acl.html" title="51.17. pg_default_acl">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="catalogs.html" title="Chapter 51. System Catalogs">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="catalog-pg-description.html" title="51.19. pg_description">Next</a></td></tr><tr><td width="40%" align="left" valign="top">51.17. <code xmlns="http://www.w3.org/1999/xhtml" class="structname">pg_default_acl</code> </td><td width="20%" align="center"><a accesskey="h" href="index.html" title="PostgreSQL 13.4 Documentation">Home</a></td><td width="40%" align="right" valign="top"> 51.19. <code xmlns="http://www.w3.org/1999/xhtml" class="structname">pg_description</code></td></tr></table></div></body></html>