Re: C Set Returning Function (SRF)

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Gary Chambers <gwchamb(at)gwcmail(dot)com>
Cc: PostgreSQL Novices <pgsql-novice(at)postgresql(dot)org>
Subject: Re: C Set Returning Function (SRF)
Date: 2011-09-08 05:31:44
Message-ID: 13911.1315459904@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

Gary Chambers <gwchamb(at)gwcmail(dot)com> writes:
> I'm trying to write a simple set returning function that links the GNU pwgen
> code. I can't seem to pull it together to return the results reliably.
> There are several examples that demonstrate returning tuples, but I can't
> seem to find any examples of SRFs returning single (specifically textual)
> types. Will someone please offer some insight?

I think the problem is here:

> SRF_RETURN_NEXT(funcctx, CStringGetDatum(pw));

CStringGetDatum produces a datum of type cstring. You want a datum of
type text. PointerGetDatum(cstring_to_text(pw)) ought to do it.

regards, tom lane

In response to

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message Carlo Ascani 2011-09-08 07:46:01 Re: copy- what's my root directory?
Previous Message Gary Chambers 2011-09-08 02:16:33 C Set Returning Function (SRF)