mirror of
https://github.com/postgres/postgres.git
synced 2025-06-27 23:21:58 +03:00
Allow float8, int8, and related datatypes to be passed by value on machines
where Datum is 8 bytes wide. Since this will break old-style C functions (those still using version 0 calling convention) that have arguments or results of these types, provide a configure option to disable it and retain the old pass-by-reference behavior. Likewise, provide a configure option to disable the recently-committed float4 pass-by-value change. Zoltan Boszormenyi, plus configurability stuff by me.
This commit is contained in:
@ -14,7 +14,7 @@
|
||||
* Copyright (c) 1998-2008, PostgreSQL Global Development Group
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/utils/adt/numeric.c,v 1.109 2008/04/04 18:45:36 tgl Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/utils/adt/numeric.c,v 1.110 2008/04/21 00:26:45 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -2599,10 +2599,13 @@ int2_sum(PG_FUNCTION_ARGS)
|
||||
}
|
||||
|
||||
/*
|
||||
* If we're invoked by nodeAgg, we can cheat and modify out first
|
||||
* If we're invoked by nodeAgg, we can cheat and modify our first
|
||||
* parameter in-place to avoid palloc overhead. If not, we need to return
|
||||
* the new value of the transition variable.
|
||||
* (If int8 is pass-by-value, then of course this is useless as well
|
||||
* as incorrect, so just ifdef it out.)
|
||||
*/
|
||||
#ifndef USE_FLOAT8_BYVAL /* controls int8 too */
|
||||
if (fcinfo->context && IsA(fcinfo->context, AggState))
|
||||
{
|
||||
int64 *oldsum = (int64 *) PG_GETARG_POINTER(0);
|
||||
@ -2614,6 +2617,7 @@ int2_sum(PG_FUNCTION_ARGS)
|
||||
PG_RETURN_POINTER(oldsum);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
int64 oldsum = PG_GETARG_INT64(0);
|
||||
|
||||
@ -2644,10 +2648,13 @@ int4_sum(PG_FUNCTION_ARGS)
|
||||
}
|
||||
|
||||
/*
|
||||
* If we're invoked by nodeAgg, we can cheat and modify out first
|
||||
* If we're invoked by nodeAgg, we can cheat and modify our first
|
||||
* parameter in-place to avoid palloc overhead. If not, we need to return
|
||||
* the new value of the transition variable.
|
||||
* (If int8 is pass-by-value, then of course this is useless as well
|
||||
* as incorrect, so just ifdef it out.)
|
||||
*/
|
||||
#ifndef USE_FLOAT8_BYVAL /* controls int8 too */
|
||||
if (fcinfo->context && IsA(fcinfo->context, AggState))
|
||||
{
|
||||
int64 *oldsum = (int64 *) PG_GETARG_POINTER(0);
|
||||
@ -2659,6 +2666,7 @@ int4_sum(PG_FUNCTION_ARGS)
|
||||
PG_RETURN_POINTER(oldsum);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
int64 oldsum = PG_GETARG_INT64(0);
|
||||
|
||||
|
Reference in New Issue
Block a user