1
0
mirror of https://github.com/postgres/postgres.git synced 2025-06-14 18:42:34 +03:00

Add system catalog columns pg_constraint.conindid and pg_trigger.tgconstrindid.

conindid is the index supporting a constraint.  We can use this not only for
unique/primary-key constraints, but also foreign-key constraints, which
depend on the unique index that constrains the referenced columns.
tgconstrindid is just copied from the constraint's conindid field, or is
zero for triggers not associated with constraints.

This is mainly intended as infrastructure for upcoming patches, but it has
some virtue in itself, since it exposes a relationship that you formerly
had to grovel in pg_depend to determine.  I simplified one information_schema
view accordingly.  (There is a pg_dump query that could also use conindid,
but I left it alone because it wasn't clear it'd get any faster.)
This commit is contained in:
Tom Lane
2009-07-28 02:56:31 +00:00
parent 36942504fc
commit c1b9ec24ef
15 changed files with 120 additions and 78 deletions

View File

@ -1,4 +1,4 @@
<!-- $PostgreSQL: pgsql/doc/src/sgml/catalogs.sgml,v 2.201 2009/07/01 23:57:33 tgl Exp $ -->
<!-- $PostgreSQL: pgsql/doc/src/sgml/catalogs.sgml,v 2.202 2009/07/28 02:56:29 tgl Exp $ -->
<!--
Documentation of the system catalogs, directed toward PostgreSQL developers
-->
@ -1748,6 +1748,14 @@
<entry>The domain this constraint is on; 0 if not a domain constraint</entry>
</row>
<row>
<entry><structfield>conindid</structfield></entry>
<entry><type>oid</type></entry>
<entry><literal><link linkend="catalog-pg-class"><structname>pg_class</structname></link>.oid</literal></entry>
<entry>The index supporting this constraint, if it's a unique, primary
key, or foreign key constraint; else 0</entry>
</row>
<row>
<entry><structfield>confrelid</structfield></entry>
<entry><type>oid</type></entry>
@ -4510,6 +4518,13 @@
<entry>The table referenced by a referential integrity constraint</entry>
</row>
<row>
<entry><structfield>tgconstrindid</structfield></entry>
<entry><type>oid</type></entry>
<entry><literal><link linkend="catalog-pg-class"><structname>pg_class</structname></link>.oid</literal></entry>
<entry>The index supporting a unique, primary key, or referential integrity constraint</entry>
</row>
<row>
<entry><structfield>tgconstraint</structfield></entry>
<entry><type>oid</type></entry>
@ -4560,6 +4575,7 @@
When <structfield>tgconstraint</> is nonzero,
<structfield>tgisconstraint</> must be true, and
<structfield>tgconstrname</>, <structfield>tgconstrrelid</>,
<structfield>tgconstrindid</>,
<structfield>tgdeferrable</>, <structfield>tginitdeferred</> are redundant
with the referenced <structname>pg_constraint</> entry. The reason we
keep these fields is that we support <quote>stand-alone</> constraint

View File

@ -1,4 +1,4 @@
<!-- $PostgreSQL: pgsql/doc/src/sgml/trigger.sgml,v 1.56 2009/05/27 01:18:06 tgl Exp $ -->
<!-- $PostgreSQL: pgsql/doc/src/sgml/trigger.sgml,v 1.57 2009/07/28 02:56:29 tgl Exp $ -->
<chapter id="triggers">
<title>Triggers</title>
@ -486,6 +486,7 @@ typedef struct Trigger
bool tgenabled;
bool tgisconstraint;
Oid tgconstrrelid;
Oid tgconstrindid;
Oid tgconstraint;
bool tgdeferrable;
bool tginitdeferred;
@ -497,7 +498,7 @@ typedef struct Trigger
</programlisting>
where <structfield>tgname</> is the trigger's name,
<structfield>tgnargs</> is number of arguments in
<structfield>tgnargs</> is the number of arguments in
<structfield>tgargs</>, and <structfield>tgargs</> is an array of
pointers to the arguments specified in the <command>CREATE
TRIGGER</command> statement. The other members are for internal use