Re: returning CHAR from C function - Mailing list pgsql-general

From Joe Conway
Subject Re: returning CHAR from C function
Date
Msg-id 3DE94DE2.6020903@joeconway.com
Whole thread Raw
In response to returning CHAR from C function  (elein <elein@sbcglobal.net>)
Responses Re: returning CHAR from C function  (Joe Conway <mail@joeconway.com>)
List pgsql-general
elein wrote:
> create function retchar(text)
> returns char
> as '$libdir/retchar.so'
> language 'c';
>

I get similar results.

It looks like the cause is that in the create function statement above the
"returns char" is interpreted as returning type 1042 (==bpchar), instead of
type 18 (==char), which is what you need (and intended). I'm not sure what the
proper way to define a function returning type char is, but I did this:

regression=# update pg_proc set prorettype = 18 where proname = 'retchar';
UPDATE 1
regression=# select retchar('abc');
  retchar
---------
  a
(1 row)

then the function works fine :-)

Joe



pgsql-general by date:

Previous
From: elein
Date:
Subject: returning CHAR from C function
Next
From: Joe Conway
Date:
Subject: Re: returning CHAR from C function