codekingpro/portable-devtools
114k
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>53.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="53.17. pg_default_acl" /><link rel="next" href="catalog-pg-description.html" title="53.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">53.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="53.17. pg_default_acl">Prev</a> </td><td width="10%" align="left"><a accesskey="u" href="catalogs.html" title="Chapter 53. System Catalogs">Up</a></td><th width="60%" align="center">Chapter 53. System Catalogs</th><td width="10%" align="right"><a accesskey="h" href="index.html" title="PostgreSQL 16.3 Documentation">Home</a></td><td width="10%" align="right"> <a accesskey="n" href="catalog-pg-description.html" title="53.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">53.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 dependency4 relationships between database objects. This information allows5 <code class="command">DROP</code> commands to find which other objects must be dropped6 by <code class="command">DROP CASCADE</code> or prevent dropping in the <code class="command">DROP7 RESTRICT</code> case.8 </p><p>9 See also <a class="link" href="catalog-pg-shdepend.html" title="53.48. pg_shdepend"><code class="structname">pg_shdepend</code></a>,10 which performs a similar function for dependencies involving objects11 that are shared across a database cluster.12 </p><div class="table" id="id-1.10.4.20.5"><p class="title"><strong>Table 53.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 Type14 </p>15 <p>16 Description17 </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="53.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 in23 </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 object29 </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 (the34 <code class="structfield">objid</code> and <code class="structfield">classid</code> refer to the35 table itself). For all other object types, this column is36 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="53.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 in43 </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 object49 </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 (the54 <code class="structfield">refobjid</code> and <code class="structfield">refclassid</code> refer55 to the table itself). For all other object types, this column56 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 text62 </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 the64 referenced object cannot be dropped without also dropping the dependent65 object. However, there are several subflavors identified by66 <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. The70 dependent object can be dropped without affecting the71 referenced object. The referenced object can only be dropped72 by specifying <code class="literal">CASCADE</code>, in which case the dependent73 object is dropped, too. Example: a table column has a normal74 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 the77 referenced object, and should be automatically dropped78 (regardless of <code class="literal">RESTRICT</code> or <code class="literal">CASCADE</code>79 mode) if the referenced object is dropped. Example: a named80 constraint on a table is made auto-dependent on the table, so81 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 the84 referenced object, and is really just a part of its internal85 implementation. A direct <code class="command">DROP</code> of the dependent86 object will be disallowed outright (we'll tell the user to issue87 a <code class="command">DROP</code> against the referenced object, instead).88 A <code class="command">DROP</code> of the referenced object will result in89 automatically dropping the dependent object90 whether <code class="literal">CASCADE</code> is specified or not. If the91 dependent object has to be dropped due to a dependency on some other92 object being removed, its drop is converted to a drop of the referenced93 object, so that <code class="literal">NORMAL</code> and <code class="literal">AUTO</code>94 dependencies of the dependent object behave much like they were95 dependencies of the referenced object.96 Example: a view's <code class="literal">ON SELECT</code> rule is made97 internally dependent on the view, preventing it from being dropped98 while the view remains. Dependencies of the rule (such as tables it99 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 the102 referenced object, and is really just a part of its internal103 implementation; however, unlike <code class="literal">INTERNAL</code>,104 there is more than one such referenced object. The dependent object105 must not be dropped unless at least one of these referenced objects106 is dropped; if any one is, the dependent object should be dropped107 whether or not <code class="literal">CASCADE</code> is specified. Also108 unlike <code class="literal">INTERNAL</code>, a drop of some other object109 that the dependent object depends on does not result in automatic110 deletion of any partition-referenced object. Hence, if the drop111 does not cascade to at least one of these objects via some other112 path, it will be refused. (In most cases, the dependent object113 shares all its non-partition dependencies with at least one114 partition-referenced object, so that this restriction does not115 result in blocking any cascaded delete.)116 Primary and secondary partition dependencies behave identically117 except that the primary dependency is preferred for use in error118 messages; hence, a partition-dependent object should have one119 primary partition dependency and one or more secondary partition120 dependencies.121 Note that partition dependencies are made in addition to, not122 instead of, any dependencies the object would normally have. This123 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-dependent126 on both the partition table it is on and the parent partitioned127 index, so that it goes away if either of those is dropped, but128 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 instead131 (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 is134 the referenced object (see135 <a class="link" href="catalog-pg-extension.html" title="53.22. pg_extension"><code class="structname">pg_extension</code></a>).136 The dependent object can be dropped only via137 <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 as139 an <code class="literal">INTERNAL</code> dependency, but it's kept separate for140 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 the143 referenced object (and so it should not be ignored144 by <span class="application">pg_dump</span>), but it cannot function145 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 as148 an <code class="literal">AUTO</code> dependency, but it's kept separate for149 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 than155 one <code class="structname">pg_depend</code> entry. For example, a child156 partitioned index would have both a partition-type dependency on its157 associated partition table, and an auto dependency on each column of158 that table that it indexes. This sort of situation expresses the union159 of multiple dependency semantics. A dependent object can be dropped160 without <code class="literal">CASCADE</code> if any of its dependencies satisfies161 its condition for automatic dropping. Conversely, all the162 dependencies' restrictions about which objects must be dropped together163 must be satisfied.164 </p><p>165 Most objects created during <span class="application">initdb</span> are166 considered <span class="quote">“<span class="quote">pinned</span>”</span>, which means that the system itself167 depends on them. Therefore, they are never allowed to be dropped.168 Also, knowing that pinned objects will not be dropped, the dependency169 mechanism doesn't bother to make <code class="structname">pg_depend</code>170 entries showing dependencies on them. Thus, for example, a table171 column of type <code class="type">numeric</code> notionally has172 a <code class="literal">NORMAL</code> dependency on the <code class="type">numeric</code>173 data type, but no such entry actually appears174 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="53.17. pg_default_acl">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="catalogs.html" title="Chapter 53. System Catalogs">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="catalog-pg-description.html" title="53.19. pg_description">Next</a></td></tr><tr><td width="40%" align="left" valign="top">53.17. <code class="structname">pg_default_acl</code> </td><td width="20%" align="center"><a accesskey="h" href="index.html" title="PostgreSQL 16.3 Documentation">Home</a></td><td width="40%" align="right" valign="top"> 53.19. <code class="structname">pg_description</code></td></tr></table></div></body></html>