Re: UDFs - Mailing list pgsql-general

From jf
Subject Re: UDFs
Date
Msg-id Pine.LNX.4.64.0708131654040.4503@localhost.localdomain
Whole thread Raw
In response to Re: UDFs  (Martijn van Oosterhout <kleptog@svana.org>)
List pgsql-general
Yup, an uninitialized variable makes sense, That appears to have worked, I appreciate it. In regards to the checks for
NULL, I wasn't sure if it was necessary or not so I opted for the safe
route, thanks for clearing that up for me.

The output from the function is binary, does it matter if I use text or
bytea? Finally, how do I cast in SQL? when I try to pass the output to
encode() it says it can't find a function taking those types.

Thanks a lot!

On Mon, 13 Aug 2007, Martijn van Oosterhout wrote:

> Date: Mon, 13 Aug 2007 10:42:52 +0200
> From: Martijn van Oosterhout <kleptog@svana.org>
> To: jf <jf@danglingpointers.net>
> Cc: pgsql-general@postgresql.org
> Subject: Re: [GENERAL] UDFs
>
> 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,
>

pgsql-general by date:

Previous
From: "John Coulthard"
Date:
Subject: Re: Unable to connect to PostgreSQL server via PHP
Next
From: hubert depesz lubaczewski
Date:
Subject: Re: UDFs