diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2009-10-14 22:14:25 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2009-10-14 22:14:25 +0000 |
commit | b2734a0d792df710aeeab21242cfa21ab470c773 (patch) | |
tree | fea1d5961054f413f63995339f1aa6037d825b9e /src/backend/utils/adt/ruleutils.c | |
parent | be922e8555a87263973a038c54171f2db833810d (diff) | |
download | postgresql-b2734a0d792df710aeeab21242cfa21ab470c773.tar.gz postgresql-b2734a0d792df710aeeab21242cfa21ab470c773.zip |
Support SQL-compliant triggers on columns, ie fire only if certain columns
are named in the UPDATE's SET list.
Note: the schema of pg_trigger has not actually changed; we've just started
to use a column that was there all along. catversion bumped anyway so that
this commit is included in the history of potentially interesting changes
to system catalog contents.
Itagaki Takahiro
Diffstat (limited to 'src/backend/utils/adt/ruleutils.c')
-rw-r--r-- | src/backend/utils/adt/ruleutils.c | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index 35c530bbdac..8538c74d123 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -9,7 +9,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/adt/ruleutils.c,v 1.309 2009/10/10 01:43:49 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/utils/adt/ruleutils.c,v 1.310 2009/10/14 22:14:23 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -543,6 +543,23 @@ pg_get_triggerdef_worker(Oid trigid, bool pretty) appendStringInfo(&buf, " OR UPDATE"); else appendStringInfo(&buf, " UPDATE"); + /* tgattr is first var-width field, so OK to access directly */ + if (trigrec->tgattr.dim1 > 0) + { + int i; + + appendStringInfoString(&buf, " OF "); + for (i = 0; i < trigrec->tgattr.dim1; i++) + { + char *attname; + + if (i > 0) + appendStringInfoString(&buf, ", "); + attname = get_relid_attribute_name(trigrec->tgrelid, + trigrec->tgattr.values[i]); + appendStringInfoString(&buf, quote_identifier(attname)); + } + } } if (TRIGGER_FOR_TRUNCATE(trigrec->tgtype)) { |