aboutsummaryrefslogtreecommitdiff
path: root/doc/src
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2010-01-17 22:56:23 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2010-01-17 22:56:23 +0000
commit9a915e596f38a97f10e00d388f18e178136937eb (patch)
treec0f85775a2423e0fb28c4d96d85569781668011e /doc/src
parentee3b4188a78916544ef30e93fc1c9e5e780e07d5 (diff)
downloadpostgresql-9a915e596f38a97f10e00d388f18e178136937eb.tar.gz
postgresql-9a915e596f38a97f10e00d388f18e178136937eb.zip
Improve the handling of SET CONSTRAINTS commands by having them search
pg_constraint before searching pg_trigger. This allows saner handling of corner cases; in particular we now say "constraint is not deferrable" rather than "constraint does not exist" when the command is applied to a constraint that's inherently non-deferrable. Per a gripe several months ago from hubert depesz lubaczewski. To make this work without breaking user-defined constraint triggers, we have to add entries for them to pg_constraint. However, in return we can remove the pgconstrname column from pg_constraint, which represents a fairly sizable space savings. I also replaced the tgisconstraint column with tgisinternal; the old meaning of tgisconstraint can now be had by testing for nonzero tgconstraint, while there is no other way to get the old meaning of nonzero tgconstraint, namely that the trigger was internally generated rather than being user-created. In passing, fix an old misstatement in the docs and comments, namely that pg_trigger.tgdeferrable is exactly redundant with pg_constraint.condeferrable. Actually, we mark RI action triggers as nondeferrable even when they belong to a nominally deferrable FK constraint. The SET CONSTRAINTS code now relies on that instead of hard-coding a list of exception OIDs.
Diffstat (limited to 'doc/src')
-rw-r--r--doc/src/sgml/catalogs.sgml38
-rw-r--r--doc/src/sgml/trigger.sgml4
2 files changed, 21 insertions, 21 deletions
diff --git a/doc/src/sgml/catalogs.sgml b/doc/src/sgml/catalogs.sgml
index ca90cd56caf..f917652a085 100644
--- a/doc/src/sgml/catalogs.sgml
+++ b/doc/src/sgml/catalogs.sgml
@@ -1,4 +1,4 @@
-<!-- $PostgreSQL: pgsql/doc/src/sgml/catalogs.sgml,v 2.217 2010/01/10 01:23:08 rhaas Exp $ -->
+<!-- $PostgreSQL: pgsql/doc/src/sgml/catalogs.sgml,v 2.218 2010/01/17 22:56:21 tgl Exp $ -->
<!--
Documentation of the system catalogs, directed toward PostgreSQL developers
-->
@@ -1722,6 +1722,11 @@
</para>
<para>
+ User-defined constraint triggers (created with <command>CREATE CONSTRAINT
+ TRIGGER</>) also give rise to an entry in this table.
+ </para>
+
+ <para>
Check constraints on domains are stored here, too.
</para>
@@ -1764,6 +1769,7 @@
<literal>f</> = foreign key constraint,
<literal>p</> = primary key constraint,
<literal>u</> = unique constraint,
+ <literal>t</> = constraint trigger,
<literal>x</> = exclusion constraint
</entry>
</row>
@@ -1873,7 +1879,8 @@
<entry><structfield>conkey</structfield></entry>
<entry><type>int2[]</type></entry>
<entry><literal><link linkend="catalog-pg-attribute"><structname>pg_attribute</structname></link>.attnum</></entry>
- <entry>If a table constraint (including a foreign key), list of the constrained columns</entry>
+ <entry>If a table constraint (including foreign keys, but not constraint
+ triggers), list of the constrained columns</entry>
</row>
<row>
@@ -4826,17 +4833,11 @@
</row>
<row>
- <entry><structfield>tgisconstraint</structfield></entry>
+ <entry><structfield>tgisinternal</structfield></entry>
<entry><type>bool</type></entry>
<entry></entry>
- <entry>True if trigger is a <quote>constraint trigger</></entry>
- </row>
-
- <row>
- <entry><structfield>tgconstrname</structfield></entry>
- <entry><type>name</type></entry>
- <entry></entry>
- <entry>Constraint name, if a constraint trigger</entry>
+ <entry>True if trigger is internally generated (usually, to enforce
+ the constraint identified by <structfield>tgconstraint</>)</entry>
</row>
<row>
@@ -4857,7 +4858,7 @@
<entry><structfield>tgconstraint</structfield></entry>
<entry><type>oid</type></entry>
<entry><literal><link linkend="catalog-pg-constraint"><structname>pg_constraint</structname></link>.oid</literal></entry>
- <entry>The <structname>pg_constraint</> entry owning the trigger, if any</entry>
+ <entry>The <structname>pg_constraint</> entry associated with the trigger, if any</entry>
</row>
<row>
@@ -4919,13 +4920,12 @@
<note>
<para>
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
- triggers with no corresponding <structname>pg_constraint</> entry.
+ <structfield>tgconstrrelid</>, <structfield>tgconstrindid</>,
+ <structfield>tgdeferrable</>, and <structfield>tginitdeferred</> are
+ largely redundant with the referenced <structname>pg_constraint</> entry.
+ However, it is possible for a non-deferrable trigger to be associated
+ with a deferrable constraint: foreign key constraints can have some
+ deferrable and some non-deferrable triggers.
</para>
</note>
diff --git a/doc/src/sgml/trigger.sgml b/doc/src/sgml/trigger.sgml
index 49571ca7c5c..5418f314a31 100644
--- a/doc/src/sgml/trigger.sgml
+++ b/doc/src/sgml/trigger.sgml
@@ -1,4 +1,4 @@
-<!-- $PostgreSQL: pgsql/doc/src/sgml/trigger.sgml,v 1.61 2009/11/23 21:41:20 petere Exp $ -->
+<!-- $PostgreSQL: pgsql/doc/src/sgml/trigger.sgml,v 1.62 2010/01/17 22:56:21 tgl Exp $ -->
<chapter id="triggers">
<title>Triggers</title>
@@ -506,7 +506,7 @@ typedef struct Trigger
Oid tgfoid;
int16 tgtype;
bool tgenabled;
- bool tgisconstraint;
+ bool tgisinternal;
Oid tgconstrrelid;
Oid tgconstrindid;
Oid tgconstraint;