Re: difficulty extracting variable-sized field on triggered row - Mailing list pgsql-general

From Glen W. Mabey
Subject Re: difficulty extracting variable-sized field on triggered row
Date
Msg-id 20071204161104.GD14370@bams.ccf.swri.edu
Whole thread Raw
In response to Re: difficulty extracting variable-sized field on triggered row  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: difficulty extracting variable-sized field on triggered row
Re: difficulty extracting variable-sized field on triggered row
List pgsql-general
On Tue, Dec 04, 2007 at 09:53:37AM -0600, Tom Lane wrote:
> "Glen W. Mabey" <Glen.Mabey@swri.org> writes:
> > Is there somewhere that I am not adequately checking for an error?
>
> 1. You're passing SPI_getbinval an uninitialized bool pointer.

Doh!

> 2. You're discarding its result, which you need.

Ah yes, a change I made while trying to debug things.

> 3. You're not checking for a null, and the error check you do have
>    is wrong/redundant.

The field is constrained to be NOT NULL, so I wasn't worried about
checking that, but I don't see how the error check is wrong, according
to the description of SPI_getbinval at

http://www.postgresql.org/docs/8.2/interactive/spi-spi-getbinval.html

What is then the appropriate way to check for failure of SPI_getbinval?

> 4. Use DatumGetTextP(), not DatumGetPointer nor PG_DETOAST_DATUM.

Searching for DatumGetTextP from the search text box at the top of
www.postgresql.org yields no hits, and a google search on DatumGetTextP
does not seem to turnip [sic] any direct documentation on this function.

Is there somewhere in the docs that I should have found this (and other
useful) functions?

Thank you very much,
Glen Mabey

pgsql-general by date:

Previous
From: Richard Huxton
Date:
Subject: Re: WAL shipping question
Next
From: Ivan Sergio Borgonovo
Date:
Subject: Re: stored procedures and dynamic queries