Re: Returning null from Userdefined C function

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Andrew Selle <aselle(at)upl(dot)cs(dot)wisc(dot)edu>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Returning null from Userdefined C function
Date: 2000-08-12 00:17:45
Message-ID: 18124.966039465@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Andrew Selle <aselle(at)upl(dot)cs(dot)wisc(dot)edu> writes:
> Obviously, there must be some way to create a NULL text * return
> variable,

You would think that, but you'd be wrong :-( --- at least for current
releases; this problem has been fixed for 7.1 by creating a new API
for user-defined functions.

With the old API, for the case of single-argument functions, you can
fake it via an ugly kluge: declare a second argument "bool *isNull"
(at the C level only, not in the SQL definition) and set *isNull to
TRUE if you want to return a NULL. This does not work if the function
doesn't have exactly one SQL argument, however.

regards, tom lane

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2000-08-12 00:35:03 Re: problem with float8 input format
Previous Message Louis-David Mitterrand 2000-08-11 21:18:23 Re: Off topic 'C' question