Re: difficulty extracting variable-sized field on triggered row

From: "Glen W(dot) Mabey" <Glen(dot)Mabey(at)swri(dot)org>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: Re: difficulty extracting variable-sized field on triggered row
Date: 2007-12-04 16:11:04
Message-ID: 20071204161104.GD14370@bams.ccf.swri.edu
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Tue, Dec 04, 2007 at 09:53:37AM -0600, Tom Lane wrote:
> "Glen W. Mabey" <Glen(dot)Mabey(at)swri(dot)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

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Ivan Sergio Borgonovo 2007-12-04 16:29:02 Re: stored procedures and dynamic queries
Previous Message Richard Huxton 2007-12-04 16:05:10 Re: WAL shipping question