Re: UDFs - Mailing list pgsql-general

From Martijn van Oosterhout
Subject Re: UDFs
Date
Msg-id 20070813084252.GB7252@svana.org
Whole thread Raw
In response to UDFs  (jf <jf@danglingpointers.net>)
Responses Re: UDFs  (jf <jf@danglingpointers.net>)
List pgsql-general
On Mon, Aug 13, 2007 at 03:17:36PM +0000, jf wrote:
> Hi.
>
> Trying to implement some simple digest routines via UDFs and for whatever
> reason I get: ERROR:  invalid memory alloc request size 4294967293 on
> PG_RETURN_TEXT_P(); any ideas what the issue is exactly?

A few points about your code:
- The tests against NULL are useless: palloc never returns NULL and
the argument to the function won't be NULL either (it's decalred
STRICT).
- Your palloc should be for more, the header may be more than one byte
VAR_HEADER_LEN or some such would be more appropriate)
- Finally, what is probably the actual problem, at no point did you
assign a length to the hash variable, ie VARLEN(hash)=foo.

Hope this helps,
--
Martijn van Oosterhout   <kleptog@svana.org>   http://svana.org/kleptog/
> From each according to his ability. To each according to his ability to litigate.

Attachment

pgsql-general by date:

Previous
From: "Pavel Stehule"
Date:
Subject: Re: UDFs
Next
From: "John Coulthard"
Date:
Subject: Re: Unable to connect to PostgreSQL server via PHP