Trigger function, C, lookup of attribute type - Mailing list pgsql-general

From Paul
Subject Trigger function, C, lookup of attribute type
Date
Msg-id 566FEE86.9020202@abelian.netcom.co.uk
Whole thread Raw
Responses Re: Trigger function, C, lookup of attribute type  (Paul <Paul@abelian.netcom.co.uk>)
Re: Trigger function, C, lookup of attribute type  (Jim Nasby <Jim.Nasby@BlueTreble.com>)
List pgsql-general
I'm writing a trigger procedure in C to catch updates to a
table and write them to a log file.

The function must walk along trigdata->tg_trigtuple
pulling out the attributes, comparing them with those in
trigdata->tg_newtuple and writing the diffs to a flat ASCII
file.

I've got a loop over the attributes, and I can get the values
if I know the type, eg

  Datum d = heap_getattr( trigdata->tg_trigtuple, ...
  int32_t val = DatumGetInt32( d);

but I'm struggling to find how the function can determine the
attribute types.   I'm only using the built-in scalar types.

Do I have to query the system catalogs?  Or maybe there's a
function that works from a TupleDesc?

--
Paul Nicholson
--


pgsql-general by date:

Previous
From: Daniel Westermann
Date:
Subject: Re: pg_dump executed on a hosts against another host fails with pg_dump: [archiver (db)] query was: SET search_path = pg_catalog, sys, dbo
Next
From: Edson Richter
Date:
Subject: Re: Overhead changing varchar(2000) to text