diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2008-04-21 00:26:47 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2008-04-21 00:26:47 +0000 |
commit | 8472bf7a73487b0535c95e299773b882f7523463 (patch) | |
tree | f8cf1ad8529e819aec4d93cdcbf848996f4e3680 /src/backend/utils/adt/numeric.c | |
parent | be939544a68f852107c912da2f35f5d36958deb2 (diff) | |
download | postgresql-8472bf7a73487b0535c95e299773b882f7523463.tar.gz postgresql-8472bf7a73487b0535c95e299773b882f7523463.zip |
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.
Diffstat (limited to 'src/backend/utils/adt/numeric.c')
-rw-r--r-- | src/backend/utils/adt/numeric.c | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/src/backend/utils/adt/numeric.c b/src/backend/utils/adt/numeric.c index 86765d5d532..c5801ade2a0 100644 --- a/src/backend/utils/adt/numeric.c +++ b/src/backend/utils/adt/numeric.c @@ -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); |