|
1 |
| -<!-- $PostgreSQL: pgsql/doc/src/sgml/catalogs.sgml,v 2.211 2009/11/20 20:38:09 tgl Exp $ --> |
| 1 | +<!-- $PostgreSQL: pgsql/doc/src/sgml/catalogs.sgml,v 2.212 2009/12/07 05:22:21 tgl Exp $ --> |
2 | 2 | <!--
|
3 | 3 | Documentation of the system catalogs, directed toward PostgreSQL developers
|
4 | 4 | -->
|
|
1536 | 1536 | <entry><type>bool</type></entry>
|
1537 | 1537 | <entry></entry>
|
1538 | 1538 | <entry>
|
1539 |
| - True if this is a table and it has (or recently had) any |
1540 |
| - indexes. This is set by <command>CREATE INDEX</command>, but |
1541 |
| - not cleared immediately by <command>DROP INDEX</command>. |
1542 |
| - <command>VACUUM</command> clears <structfield>relhasindex</> if it finds the |
1543 |
| - table has no indexes |
| 1539 | + True if this is a table and it has (or recently had) any indexes |
1544 | 1540 | </entry>
|
1545 | 1541 | </row>
|
1546 | 1542 |
|
|
1617 | 1613 | </entry>
|
1618 | 1614 | </row>
|
1619 | 1615 |
|
| 1616 | + <row> |
| 1617 | + <entry><structfield>relhasexclusion</structfield></entry> |
| 1618 | + <entry><type>bool</type></entry> |
| 1619 | + <entry></entry> |
| 1620 | + <entry> |
| 1621 | + For a table, true if the table has (or once had) any exclusion |
| 1622 | + constraints; for an index, true if the index supports an exclusion |
| 1623 | + constraint |
| 1624 | + </entry> |
| 1625 | + </row> |
| 1626 | + |
1620 | 1627 | <row>
|
1621 | 1628 | <entry><structfield>relhasrules</structfield></entry>
|
1622 | 1629 | <entry><type>bool</type></entry>
|
|
1680 | 1687 | </tbody>
|
1681 | 1688 | </tgroup>
|
1682 | 1689 | </table>
|
| 1690 | + |
| 1691 | + <para> |
| 1692 | + Several of the boolean flags in <structname>pg_class</> are maintained |
| 1693 | + lazily: they are guaranteed to be true if that's the correct state, but |
| 1694 | + may not be reset to false immediately when the condition is no longer |
| 1695 | + true. For example, <structfield>relhasindex</> is set by |
| 1696 | + <command>CREATE INDEX</command>, but it is never cleared by |
| 1697 | + <command>DROP INDEX</command>. Instead, <command>VACUUM</command> clears |
| 1698 | + <structfield>relhasindex</> if it finds the table has no indexes. This |
| 1699 | + arrangement avoids race conditions and improves concurrency. |
| 1700 | + </para> |
1683 | 1701 | </sect1>
|
1684 | 1702 |
|
1685 | 1703 | <sect1 id="catalog-pg-constraint">
|
|
1690 | 1708 | </indexterm>
|
1691 | 1709 |
|
1692 | 1710 | <para>
|
1693 |
| - The catalog <structname>pg_constraint</structname> stores check, primary key, unique, and foreign |
1694 |
| - key constraints on tables. (Column constraints are not treated |
1695 |
| - specially. Every column constraint is equivalent to some table |
1696 |
| - constraint.) Not-null constraints are represented in the |
1697 |
| - <structname>pg_attribute</> catalog. |
| 1711 | + The catalog <structname>pg_constraint</structname> stores check, primary |
| 1712 | + key, unique, foreign key, and exclusion constraints on tables. |
| 1713 | + (Column constraints are not treated specially. Every column constraint is |
| 1714 | + equivalent to some table constraint.) |
| 1715 | + Not-null constraints are represented in the <structname>pg_attribute</> |
| 1716 | + catalog, not here. |
1698 | 1717 | </para>
|
1699 | 1718 |
|
1700 | 1719 | <para>
|
|
1739 | 1758 | <literal>c</> = check constraint,
|
1740 | 1759 | <literal>f</> = foreign key constraint,
|
1741 | 1760 | <literal>p</> = primary key constraint,
|
1742 |
| - <literal>u</> = unique constraint |
| 1761 | + <literal>u</> = unique constraint, |
| 1762 | + <literal>x</> = exclusion constraint |
1743 | 1763 | </entry>
|
1744 | 1764 | </row>
|
1745 | 1765 |
|
|
1776 | 1796 | <entry><type>oid</type></entry>
|
1777 | 1797 | <entry><literal><link linkend="catalog-pg-class"><structname>pg_class</structname></link>.oid</literal></entry>
|
1778 | 1798 | <entry>The index supporting this constraint, if it's a unique, primary
|
1779 |
| - key, or foreign key constraint; else 0</entry> |
| 1799 | + key, foreign key, or exclusion constraint; else 0</entry> |
1780 | 1800 | </row>
|
1781 | 1801 |
|
1782 | 1802 | <row>
|
|
1828 | 1848 | <entry><type>bool</type></entry>
|
1829 | 1849 | <entry></entry>
|
1830 | 1850 | <entry>
|
1831 |
| - This constraint is defined locally in the relation. Note that a |
| 1851 | + This constraint is defined locally for the relation. Note that a |
1832 | 1852 | constraint can be locally defined and inherited simultaneously
|
1833 | 1853 | </entry>
|
1834 | 1854 | </row>
|
|
1838 | 1858 | <entry><type>int4</type></entry>
|
1839 | 1859 | <entry></entry>
|
1840 | 1860 | <entry>
|
1841 |
| - The number of direct ancestors this constraint has. A constraint with |
| 1861 | + The number of direct inheritance ancestors this constraint has. |
| 1862 | + A constraint with |
1842 | 1863 | a nonzero number of ancestors cannot be dropped nor renamed
|
1843 | 1864 | </entry>
|
1844 | 1865 | </row>
|
|
1878 | 1899 | <entry>If a foreign key, list of the equality operators for FK = FK comparisons</entry>
|
1879 | 1900 | </row>
|
1880 | 1901 |
|
| 1902 | + <row> |
| 1903 | + <entry><structfield>conexclop</structfield></entry> |
| 1904 | + <entry><type>oid[]</type></entry> |
| 1905 | + <entry><literal><link linkend="catalog-pg-operator"><structname>pg_operator</structname></link>.oid</></entry> |
| 1906 | + <entry>If an exclusion constraint, list of the per-column exclusion operators</entry> |
| 1907 | + </row> |
| 1908 | + |
1881 | 1909 | <row>
|
1882 | 1910 | <entry><structfield>conbin</structfield></entry>
|
1883 | 1911 | <entry><type>text</type></entry>
|
|
1895 | 1923 | </tgroup>
|
1896 | 1924 | </table>
|
1897 | 1925 |
|
| 1926 | + <para> |
| 1927 | + In the case of an exclusion constraint, <structfield>conkey</structfield> |
| 1928 | + is only useful for constraint elements that are simple column references. |
| 1929 | + For other cases, a zero appears in <structfield>conkey</structfield> |
| 1930 | + and the associated index must be consulted to discover the expression |
| 1931 | + that is constrained. (<structfield>conkey</structfield> thus has the |
| 1932 | + same contents as <structname>pg_index</>.<structfield>indkey</> for the |
| 1933 | + index.) |
| 1934 | + </para> |
| 1935 | + |
1898 | 1936 | <note>
|
1899 | 1937 | <para>
|
1900 | 1938 | <structfield>consrc</structfield> is not updated when referenced objects
|
|
1908 | 1946 | <para>
|
1909 | 1947 | <literal>pg_class.relchecks</literal> needs to agree with the
|
1910 | 1948 | number of check-constraint entries found in this table for each
|
1911 |
| - relation. |
| 1949 | + relation. Also, <literal>pg_class.relhasexclusion</literal> must |
| 1950 | + be true if there are any exclusion-constraint entries for the relation. |
1912 | 1951 | </para>
|
1913 | 1952 | </note>
|
1914 | 1953 |
|
|
0 commit comments