C-language stored function and float4 type

From: whiplash <whiplash(at)bss(dot)org(dot)ua>
To: "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: C-language stored function and float4 type
Date: 2013-10-05 21:45:22
Message-ID: 52508872.7020301@bss.org.ua
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hello! I have C-language stored function like this:

#include <postgres.h>
#include <fmgr.h>

#ifdef PG_MODULE_MAGIC
PG_MODULE_MAGIC;
#endif

PG_FUNCTION_INFO_V1(testfunc);

Datum testfunc(PG_FUNCTION_ARGS)
{
float4 x = PG_GETARG_FLOAT4(0);
float4 y = PG_GETARG_FLOAT4(1);

PG_RETURN_FLOAT4(x + y);
}

CREATE FUNCTION testfunc ( x real, y real )
RETURNS real AS
'testfunc'
LANGUAGE C STRICT;

If i use this function (SELECT testfunc ( 0.1, 0.2 )) I get result with
type "double precision". I tried used float4 but the result was the
same. What is wrong?

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Patrick Dung 2013-10-06 15:20:14 Re: Major upgrade of PostgreSQL and MySQL
Previous Message Bruce Momjian 2013-10-05 14:20:46 Re: Major upgrade of PostgreSQL and MySQL