]> granicus.if.org Git - postgresql/commit
Improve the handling of SET CONSTRAINTS commands by having them search
authorTom Lane <tgl@sss.pgh.pa.us>
Sun, 17 Jan 2010 22:56:23 +0000 (22:56 +0000)
committerTom Lane <tgl@sss.pgh.pa.us>
Sun, 17 Jan 2010 22:56:23 +0000 (22:56 +0000)
commit9a915e596f38a97f10e00d388f18e178136937eb
treec0f85775a2423e0fb28c4d96d85569781668011e
parentee3b4188a78916544ef30e93fc1c9e5e780e07d5
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.
17 files changed:
doc/src/sgml/catalogs.sgml
doc/src/sgml/trigger.sgml
src/backend/catalog/index.c
src/backend/catalog/information_schema.sql
src/backend/commands/tablecmds.c
src/backend/commands/trigger.c
src/backend/tcop/utility.c
src/backend/utils/adt/ruleutils.c
src/bin/pg_dump/pg_dump.c
src/bin/psql/describe.c
src/include/catalog/catversion.h
src/include/catalog/indexing.h
src/include/catalog/pg_constraint.h
src/include/catalog/pg_trigger.h
src/include/commands/trigger.h
src/include/nodes/parsenodes.h
src/include/utils/rel.h