From a6496a233868410690a0fc1137bde774c61e9c5c Mon Sep 17 00:00:00 2001 From: Peter Eisentraut Date: Thu, 13 Sep 2001 18:17:44 +0000 Subject: [PATCH] Update compatibility information. --- doc/src/sgml/ref/create_trigger.sgml | 166 ++++++++++++++++++--------- doc/src/sgml/ref/drop_trigger.sgml | 88 +++++++------- 2 files changed, 157 insertions(+), 97 deletions(-) diff --git a/doc/src/sgml/ref/create_trigger.sgml b/doc/src/sgml/ref/create_trigger.sgml index 9079bda9a7e..35701b0aece 100644 --- a/doc/src/sgml/ref/create_trigger.sgml +++ b/doc/src/sgml/ref/create_trigger.sgml @@ -1,9 +1,13 @@ + + 2001-09-13 + + CREATE TRIGGER SQL - Language Statements @@ -134,78 +138,55 @@ CREATE PostgreSQL Programmer's Guide for more information. + - - - 1998-09-21 - - - Notes - - - CREATE TRIGGER is a Postgres - language extension. - - - Only the relation owner may create a trigger on this relation. - - - As of the current release, STATEMENT triggers are not implemented. - - - Refer to DROP TRIGGER for information on how to - remove triggers. - - + + Notes + + + To create a trigger on a table, the user must have the + TRIGGER privilege on the table. + + + + As of the current release, STATEMENT triggers are not implemented. + + + + Refer to the command for + information on how to remove triggers. + - - Usage - + Examples + Check if the specified distributor code exists in the distributors table before appending or updating a row in the table films: - + CREATE TRIGGER if_dist_exists BEFORE INSERT OR UPDATE ON films FOR EACH ROW EXECUTE PROCEDURE check_primary_key ('did', 'distributors', 'did'); - + + Before cancelling a distributor or updating its code, remove every reference to the table films: - + CREATE TRIGGER if_film_exists BEFORE DELETE OR UPDATE ON distributors FOR EACH ROW EXECUTE PROCEDURE check_foreign_key (1, 'CASCADE', 'did', 'films', 'did'); - + - - - - Compatibility - - - - - 1998-09-21 - - - SQL92 - + + The second example can also be done by using a foreign key, + constraint as in: - - There is no CREATE TRIGGER in SQL92. - - - - The second example above may also be done by using a FOREIGN KEY - constraint as in: - - + CREATE TABLE distributors ( did DECIMAL(3), name VARCHAR(40), @@ -213,9 +194,84 @@ CREATE TABLE distributors ( FOREIGN KEY(did) REFERENCES films ON UPDATE CASCADE ON DELETE CASCADE ); - - - + + + + + + Compatibility + + + + SQL92 + + + There is no CREATE TRIGGER statement in SQL92. + + + + + + SQL99 + + + The CREATE TRIGGER statement in + PostgreSQL implements a subset of the + SQL99 standard. The following functionality is missing: + + + + SQL99 allows triggers to fire on updates to specific columns + (e.g., AFTER UPDATE OF col1, col2). + + + + + + SQL99 allows you to define aliases for the old + and new rows or tables for use in the definiton + of the triggered action (e.g., CREATE TRIGGER ... ON + tablename REFERENCING OLD ROW AS somename NEW ROW AS + othername ...). Since + PostgreSQL allows trigger + procedures to be written in any number of user-defined + languages, access to the data is handled in a + language-specific way. + + + + + + PostgreSQL only has row-level + triggers, no statement-level triggers. + + + + + + PostgreSQL only allows the + execution of a stored procedure for the triggered action. + SQL99 allows the execution of a number of other SQL commands, + such as CREATE TABLE as triggered action. + This limitation is not hard to work around by creating a + stored procedure that executes these commands. + + + + + + + + + + + See Also + + + + + PostgreSQL Programmer's Guide + diff --git a/doc/src/sgml/ref/drop_trigger.sgml b/doc/src/sgml/ref/drop_trigger.sgml index 81a9219f100..f1bfdadf61f 100644 --- a/doc/src/sgml/ref/drop_trigger.sgml +++ b/doc/src/sgml/ref/drop_trigger.sgml @@ -1,9 +1,13 @@ + + 2001-09-13 + + DROP TRIGGER @@ -101,58 +105,58 @@ ERROR: DropTrigger: there is no trigger name DROP TRIGGER will remove all references to an existing trigger definition. To execute this command the current - user must be the owner of the trigger. + user must be the owner of the table for which the trigger is defined. - - - - 1998-09-22 - - - Notes - - - DROP TRIGGER is a Postgres - language extension. - - - Refer to CREATE TRIGGER for - information on how to create triggers. - - - - - - Usage - + + + Examples + Destroy the if_dist_exists trigger on table films: - + DROP TRIGGER if_dist_exists ON films; - + - - - Compatibility - + + Compatibility - - - 1998-09-22 - - - SQL92 - - - There is no DROP TRIGGER statement in - SQL92. - - + + + SQL92 + + + There is no DROP TRIGGER statement in + SQL92. + + + + + + SQL99 + + + The DROP TRIGGER statement in + PostgreSQL is incompatible with + SQL99. In SQL99, trigger names are not local to tables, so the + command is simply DROP TRIGGER + name. + + + + + + + + See Also + + + +