Re: difficulty extracting variable-sized field on triggered row
От | Glen W. Mabey |
---|---|
Тема | Re: difficulty extracting variable-sized field on triggered row |
Дата | |
Msg-id | 20071204152646.GC14370@bams.ccf.swri.edu обсуждение исходный текст |
Ответ на | Re: difficulty extracting variable-sized field on triggered row ("Pavel Stehule" <pavel.stehule@gmail.com>) |
Ответы |
Re: difficulty extracting variable-sized field on
triggered row
Re: difficulty extracting variable-sized field on triggered row Re: difficulty extracting variable-sized field on triggered row |
Список | 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); } }
В списке pgsql-general по дате отправления: