Skip site navigation (1) Skip section navigation (2)

BUG #3630: Memory Allocation Error

From: "" <zhuge(at)Rinaix(dot)cn>
To: pgsql-bugs(at)postgresql(dot)org
Subject: BUG #3630: Memory Allocation Error
Date: 2007-09-24 04:28:14
Message-ID: 200709240428.l8O4SEWk056202@wwwmaster.postgresql.org (view raw or flat)
Thread:
Lists: pgsql-bugs
The following bug has been logged online:

Bug reference:      3630
Logged by:          
Email address:      zhuge(at)Rinaix(dot)cn
PostgreSQL version: 8.1.9
Operating system:   Linux
Description:        Memory Allocation Error
Details: 

I wrote and compiled and linked a C function, add_float, which returns float
in C like following:

PG_FUNCTION_INFO_V1(add_float);

Datum
add_float(PG_FUNCTION_ARGS)
{
	float   arg = PG_GETARG_FLOAT8(0);

	PG_RETURN_FLOAT8(arg + 10);
}

After having loaded it into database, executed the SQL command, "select
ad_float(2.90)", but one error occured. The error message is "Error: invalid
memory alloc request size 4294967290" . 

However I changed the above function as following:

PG_FUNCTION_INFO_V1(add_integer);
Datum
add_integer(PG_FUNCTION_ARGS)
{
	int32   arg = PG_GETARG_INT32(0);

	PG_RETURN_INT32(arg + 10);
}

and executed the SQL command, "select add_integer(5)", and the result is:
add_integer
----------
        15

In another word, the function can NOT return float BUT return integer. Why?
Please help me.

Thank you very much.

pgsql-bugs by date

Next:From: Heikki LinnakangasDate: 2007-09-24 09:14:21
Subject: Re: BUG #3627: Triple FK with ON DELETE SET NULL makes DELETE fail
Previous:From: zhuge xiaoDate: 2007-09-24 04:22:02
Subject: Memory Allocation Error

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group