</varlistentry>
</variablelist>
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><structfield>tg_relation</structfield></term>
<listitem>
<para>
A pointer to a structure describing the relation that the trigger fired for.
Look at <filename>utils/rel.h</filename> for details about
this structure. The most interesting things are
<literal>tg_relation->rd_att</literal> (descriptor of the relation
tuples) and <literal>tg_relation->rd_rel->relname</literal>
(relation name; the type is not <type>char*</type> but
<type>NameData</type>; use
<literal>SPI_getrelname(tg_relation)</literal> to get a <type>char*</type> if you
need a copy of the name).
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><structfield>tg_trigtuple</structfield></term>
<listitem>
<para>
A pointer to the row for which the trigger was fired. This is
the row being inserted, updated, or deleted. If this trigger
was fired for an <command>INSERT</command> or
<command>DELETE</command> then this is what you should return
from the function if you don't want to replace the row with
a different one (in the case of <command>INSERT</command>) or
skip the operation. For triggers on foreign tables, values of system
columns herein are unspecified.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><structfield>tg_newtuple</structfield></term>
<listitem>
<para>
A pointer to the new version of the row, if the trigger was
fired for an <command>UPDATE</command>, and <symbol>NULL</symbol> if
it is for an <command>INSERT</command> or a
<command>DELETE</command>. This is what you have to return
from the function if the event is an <command>UPDATE</command>
and you don't want to replace this row by a different one or
skip the operation. For triggers on foreign tables, values of system
columns herein are unspecified.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><structfield>tg_trigger</structfield></term>
<listitem>
<para>
A pointer to a structure of type <structname>Trigger</structname>,
defined in <filename>utils/reltrigger.h</filename>:
<programlisting>
typedef struct Trigger
{
Oid tgoid;
char *tgname;
Oid tgfoid;
int16 tgtype;
char tgenabled;
bool tgisinternal;
bool tgisclone;
Oid tgconstrrelid;
Oid tgconstrindid;
Oid tgconstraint;
bool tgdeferrable;
bool tginitdeferred;
int16 tgnargs;
int16 tgnattr;
int16 *tgattr;
char **tgargs;
char *tgqual;
char *tgoldtable;
char *tgnewtable;
} Trigger;
</programlisting>
where <structfield>tgname</structfield> is the trigger's name,
<structfield>tgnargs</structfield> is the number of arguments in
<structfield>tgargs</structfield>, and <structfield>tgargs</structfield> is an array of
pointers to the arguments specified in the <command>CREATE
TRIGGER</command> statement. The other members are for internal use
only.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><structfield>tg_trigslot</structfield></term>
<listitem>
<para>
The slot containing <structfield>tg_trigtuple</structfield>,
or a <symbol>NULL</symbol> pointer if there is no such tuple.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><structfield>tg_newslot</structfield></term>
<listitem>
<para>
The slot containing <structfield>tg_newtuple</structfield>,
or a <symbol>NULL</symbol>