1
1
<!--
2
- $PostgreSQL: pgsql/doc/src/sgml/trigger.sgml,v 1.39 2004/12/30 03:13:56 tgl Exp $
2
+ $PostgreSQL: pgsql/doc/src/sgml/trigger.sgml,v 1.40 2005/01/22 22:06:27 momjian Exp $
3
3
-->
4
4
5
5
<chapter id="triggers">
@@ -271,10 +271,10 @@ CALLED_AS_TRIGGER(fcinfo)
271
271
</programlisting>
272
272
which expands to
273
273
<programlisting>
274
- ((fcinfo)-> context != NULL && IsA((fcinfo)-> context, TriggerData))
274
+ ((fcinfo)-> context != NULL && IsA((fcinfo)-> context, TriggerData))
275
275
</programlisting>
276
276
If this returns true, then it is safe to cast
277
- <literal>fcinfo-> context</> to type <literal>TriggerData
277
+ <literal>fcinfo-> context</> to type <literal>TriggerData
278
278
*</literal> and make use of the pointed-to
279
279
<structname>TriggerData</> structure. The function must
280
280
<emphasis>not</emphasis> alter the <structname>TriggerData</>
@@ -393,8 +393,8 @@ typedef struct TriggerData
393
393
A pointer to a structure describing the relation that the trigger fired for.
394
394
Look at <filename>utils/rel.h</> for details about
395
395
this structure. The most interesting things are
396
- <literal>tg_relation-> rd_att</> (descriptor of the relation
397
- tuples) and <literal>tg_relation-> rd_rel-> relname</>
396
+ <literal>tg_relation-> rd_att</> (descriptor of the relation
397
+ tuples) and <literal>tg_relation-> rd_rel-> relname</>
398
398
(relation name; the type is not <type>char*</> but
399
399
<type>NameData</>; use
400
400
<literal>SPI_getrelname(tg_relation)</> to get a <type>char*</> if you
@@ -541,7 +541,7 @@ PG_FUNCTION_INFO_V1(trigf);
541
541
Datum
542
542
trigf(PG_FUNCTION_ARGS)
543
543
{
544
- TriggerData *trigdata = (TriggerData *) fcinfo-> context;
544
+ TriggerData *trigdata = (TriggerData *) fcinfo-> context;
545
545
TupleDesc tupdesc;
546
546
HeapTuple rettuple;
547
547
char *when;
@@ -554,22 +554,22 @@ trigf(PG_FUNCTION_ARGS)
554
554
elog(ERROR, "trigf: not called by trigger manager");
555
555
556
556
/* tuple to return to executor */
557
- if (TRIGGER_FIRED_BY_UPDATE(trigdata-> tg_event))
558
- rettuple = trigdata-> tg_newtuple;
557
+ if (TRIGGER_FIRED_BY_UPDATE(trigdata-> tg_event))
558
+ rettuple = trigdata-> tg_newtuple;
559
559
else
560
- rettuple = trigdata-> tg_trigtuple;
560
+ rettuple = trigdata-> tg_trigtuple;
561
561
562
562
/* check for null values */
563
- if (!TRIGGER_FIRED_BY_DELETE(trigdata-> tg_event)
564
- && TRIGGER_FIRED_BEFORE(trigdata-> tg_event))
563
+ if (!TRIGGER_FIRED_BY_DELETE(trigdata-> tg_event)
564
+ && TRIGGER_FIRED_BEFORE(trigdata-> tg_event))
565
565
checknull = true;
566
566
567
- if (TRIGGER_FIRED_BEFORE(trigdata-> tg_event))
567
+ if (TRIGGER_FIRED_BEFORE(trigdata-> tg_event))
568
568
when = "before";
569
569
else
570
570
when = "after ";
571
571
572
- tupdesc = trigdata-> tg_relation-> rd_att;
572
+ tupdesc = trigdata-> tg_relation-> rd_att;
573
573
574
574
/* connect to SPI manager */
575
575
if ((ret = SPI_connect()) < 0)
@@ -582,8 +582,8 @@ trigf(PG_FUNCTION_ARGS)
582
582
elog(NOTICE, "trigf (fired %s): SPI_exec returned %d", when, ret);
583
583
584
584
/* count(*) returns int8, so be careful to convert */
585
- i = DatumGetInt64(SPI_getbinval(SPI_tuptable-> vals[0],
586
- SPI_tuptable-> tupdesc,
585
+ i = DatumGetInt64(SPI_getbinval(SPI_tuptable-> vals[0],
586
+ SPI_tuptable-> tupdesc,
587
587
1,
588
588
&isnull));
589
589