Thread: tg_relation doesn't seem to have the attribute names!

tg_relation doesn't seem to have the attribute names!

From
Graeme Hinchliffe
Date:
Hiya,

    I am using the following line to retrieve the attribute name of the 1st
column for a table on which a trigger has been fired.

idfield=SPI_fname(trigdata->tg_relation->rd_att,0);

The trigger that calls this function runs after for insert, update and
delete.

Insert works fine with no issues, Delete however doesn't, and I have
tracked down that the above line is returning a NULL.  This code did
work for 7.3.x but isn't for 7.4.3

Is there something I have overlooked, I have read the docs and
apparently trigdata->tg_relation->rd_att should contain the relation of
the table.

please help.

thanks

--
-----
Graeme Hinchliffe (BSc)
Core Internet Systems Designer
Zen Internet (http://www.zen.co.uk/)

Direct: 0845 058 9074
Main  : 0845 058 9000
Fax   : 0845 058 9005



Re: tg_relation doesn't seem to have the attribute names!

From
Tom Lane
Date:
Graeme Hinchliffe <graeme.hinchliffe@zeninternet.co.uk> writes:
>     I am using the following line to retrieve the attribute name of the 1st
> column for a table on which a trigger has been fired.

> idfield=SPI_fname(trigdata->tg_relation->rd_att,0);

SPI_fname thinks that column numbers start with 1, not 0.

> This code did work for 7.3.x but isn't for 7.4.3

I rather doubt it, as a quick look at the sources shows that SPI_fname
has always returned null for bogus column number (including 0).

            regards, tom lane