View Single Post

   
  #7 (permalink)  
Old 04-09-2008, 11:13 PM
Glen W. Mabey
 
Posts: n/a
Default Re: difficulty extracting variable-sized field ontriggered row

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/i...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

---------------------------(end of broadcast)---------------------------
TIP 4: Have you searched our list archives?

http://archives.postgresql.org/

Reply With Quote