From: | "Glen W(dot) Mabey" <Glen(dot)Mabey(at)swri(dot)org> |
---|---|
To: | Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com> |
Cc: | "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: difficulty extracting variable-sized field on triggered row |
Date: | 2007-12-04 15:26:46 |
Message-ID: | 20071204152646.GC14370@bams.ccf.swri.edu |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On Tue, Dec 04, 2007 at 09:10:21AM -0600, Pavel Stehule wrote:
> use macro DatumGetPointer(datum)
When I do that, I get the following compiler warning:
warning: assignment from incompatible pointer type
which is what originally motivated me to look for another means, which
led me to use PG_DETOAST_DATUM.
Using DatumGetPointer also seg faults ...
Is there somewhere that I am not adequately checking for an error?
Thanks,
Glen
TriggerData *trigdata;
Datum relative_filename_datum;
text *relative_filename_t;
int file_name_colnumber, ret;
bool *isnull;
if( CALLED_AS_TRIGGER( fcinfo ) ) {
elog(INFO, "unlink_file was called as a trigger." );
trigdata = (TriggerData *) fcinfo->context;
if( ( ret = SPI_connect() ) != SPI_OK_CONNECT ) {
elog(INFO, "SPI_connect returned %d", ret);
}
file_name_colnumber = SPI_fnumber( trigdata->tg_relation->rd_att, "file_name" );
if( file_name_colnumber == SPI_ERROR_NOATTRIBUTE ) {
elog(INFO, "SPI_fnumber returned SPI_ERROR_NOATTRIBUTE" );
}
SPI_getbinval( trigdata->tg_trigtuple, trigdata->tg_relation->rd_att, file_name_colnumber, isnull );
if( SPI_result == SPI_ERROR_NOATTRIBUTE ) {
elog(INFO, "SPI_fnumber returned SPI_ERROR_NOATTRIBUTE" );
}
relative_filename_t = PG_DETOAST_DATUM( relative_filename_datum );
if( ( ret = SPI_finish() ) != SPI_OK_FINISH ) {
elog(INFO, "SPI_finish returned %d", ret);
}
}
From | Date | Subject | |
---|---|---|---|
Next Message | Wim Chalmet | 2007-12-04 15:27:44 | Vacuum output redirect |
Previous Message | Pavel Stehule | 2007-12-04 15:10:21 | Re: difficulty extracting variable-sized field on triggered row |