detecting NULL column in SPI function - Mailing list pgsql-general

From Louis-David Mitterrand
Subject detecting NULL column in SPI function
Date
Msg-id 20000928170531.A17373@styx
Whole thread Raw
Responses Re: detecting NULL column in SPI function
List pgsql-general
Hello,

In a SPI function I have this code snippet:

    double startprice = *DatumGetFloat64(SPI_getbinval(
                    auction_tt->vals[i], auction_tt->tupdesc,
                    SPI_fnumber(auction_tt->tupdesc, "startprice"), &isnull));

To extract a value from the startprice column. It only works if
"startprice" is not NULL, otherwise the backend crashes.

In the provided example SPI functions I couldn't determine a good way of
testing for NULL on columns. Should I first try to return the Datum,
test it for NULL, then run DatumGetFloat64() on it? Isn't there a
simpler way?

Thanks in advance for your help, cheers,

--
Louis-David Mitterrand - ldm@apartia.org - http://www.apartia.org

 Hand, n.:
         A singular instrument worn at the end of a human arm and
         commonly thrust into somebody's pocket.
                         -- Ambrose Bierce, "The Devil's Dictionary"

pgsql-general by date:

Previous
From: "Daryl Chance"
Date:
Subject: Talking with other Dbases.
Next
From: "Mitch Vincent"
Date:
Subject: Re: Talking with other Dbases.