Search Postgresql Archives

Re: difficulty extracting variable-sized field on triggered row

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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);
        }

    }

---------------------------(end of broadcast)---------------------------
TIP 3: Have you checked our extensive FAQ?

               http://www.postgresql.org/docs/faq

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux