Trigger function, C, lookup of attribute type

From: Paul <Paul(at)abelian(dot)netcom(dot)co(dot)uk>
To: pgsql-general(at)postgresql(dot)org
Subject: Trigger function, C, lookup of attribute type
Date: 2015-12-15 10:42:14
Message-ID: 566FEE86.9020202@abelian.netcom.co.uk
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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
--

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Edson Richter 2015-12-15 10:59:51 Re: Overhead changing varchar(2000) to text
Previous Message Daniel Westermann 2015-12-15 09:58:40 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