aboutsummaryrefslogtreecommitdiff
path: root/src/backend/utils/adt/ruleutils.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2010-10-10 13:43:33 -0400
committerTom Lane <tgl@sss.pgh.pa.us>2010-10-10 13:45:07 -0400
commit2ec993a7cbdd8e251817ac6bbc9a704ce8346f73 (patch)
tree1568fb4b00b6fa7997755113a3d0bbfead45c1fb /src/backend/utils/adt/ruleutils.c
parentf7b15b5098ee89a2628129fbbef9901bded9d27b (diff)
downloadpostgresql-2ec993a7cbdd8e251817ac6bbc9a704ce8346f73.tar.gz
postgresql-2ec993a7cbdd8e251817ac6bbc9a704ce8346f73.zip
Support triggers on views.
This patch adds the SQL-standard concept of an INSTEAD OF trigger, which is fired instead of performing a physical insert/update/delete. The trigger function is passed the entire old and/or new rows of the view, and must figure out what to do to the underlying tables to implement the update. So this feature can be used to implement updatable views using trigger programming style rather than rule hacking. In passing, this patch corrects the names of some columns in the information_schema.triggers view. It seems the SQL committee renamed them somewhere between SQL:99 and SQL:2003. Dean Rasheed, reviewed by Bernd Helmle; some additional hacking by me.
Diffstat (limited to 'src/backend/utils/adt/ruleutils.c')
-rw-r--r--src/backend/utils/adt/ruleutils.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index 578b9ce2b7b..f1c1d04ee09 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -545,8 +545,13 @@ pg_get_triggerdef_worker(Oid trigid, bool pretty)
if (TRIGGER_FOR_BEFORE(trigrec->tgtype))
appendStringInfo(&buf, "BEFORE");
- else
+ else if (TRIGGER_FOR_AFTER(trigrec->tgtype))
appendStringInfo(&buf, "AFTER");
+ else if (TRIGGER_FOR_INSTEAD(trigrec->tgtype))
+ appendStringInfo(&buf, "INSTEAD OF");
+ else
+ elog(ERROR, "unexpected tgtype value: %d", trigrec->tgtype);
+
if (TRIGGER_FOR_INSERT(trigrec->tgtype))
{
appendStringInfo(&buf, " INSERT");