Обсуждение: Returning a char from a C-language function
I have a small problem when trying to make a C-language function to return one character. The code is very simple and that's what's making it so strange.
Datum val_ibool(PG_FUNCTION_ARGS)
{
iBool *input = (iBool *) PG_GETARG_POINTER(0);
PG_RETURN_CHAR(input->value);
}
input is a structure containing a character as value. I also tried this, but it didn't work:
Datum val_ibool(PG_FUNCTION_ARGS)
{
char test = 'a';
PG_RETURN_CHAR(test);
}
On the other side I have this:
CREATE FUNCTION val(ibool)
RETURNS char
AS '/home/ivan/Desktop/diplomski/trunk/C/modbms', 'val_ibool'
LANGUAGE C STRICT;
Any advice?
Hotmail: Trusted email with powerful SPAM protection. Sign up now.
Datum val_ibool(PG_FUNCTION_ARGS)
{
iBool *input = (iBool *) PG_GETARG_POINTER(0);
PG_RETURN_CHAR(input->value);
}
input is a structure containing a character as value. I also tried this, but it didn't work:
Datum val_ibool(PG_FUNCTION_ARGS)
{
char test = 'a';
PG_RETURN_CHAR(test);
}
On the other side I have this:
CREATE FUNCTION val(ibool)
RETURNS char
AS '/home/ivan/Desktop/diplomski/trunk/C/modbms', 'val_ibool'
LANGUAGE C STRICT;
Any advice?
Hotmail: Trusted email with powerful SPAM protection. Sign up now.
"I. B." <i.bre@live.com> writes: > I have a small problem when trying to make a C-language function to return one character. The code is very simple and that'swhat's making it so strange. > CREATE FUNCTION val(ibool) > RETURNS char You need to write "char", with the quotes. Without the quotes the type name is taken as CHARACTER(1), ie what's internally called BpChar. Totally different animal. regards, tom lane