summaryrefslogtreecommitdiff
path: root/src/backend/utils/adt/int8.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/backend/utils/adt/int8.c')
-rw-r--r--src/backend/utils/adt/int8.c75
1 files changed, 14 insertions, 61 deletions
diff --git a/src/backend/utils/adt/int8.c b/src/backend/utils/adt/int8.c
index 9dd5889f34c..bdea490202a 100644
--- a/src/backend/utils/adt/int8.c
+++ b/src/backend/utils/adt/int8.c
@@ -718,76 +718,29 @@ int8lcm(PG_FUNCTION_ARGS)
Datum
int8inc(PG_FUNCTION_ARGS)
{
- /*
- * When int8 is pass-by-reference, we provide this special case to avoid
- * palloc overhead for COUNT(): when called as an aggregate, we know that
- * the argument is modifiable local storage, so just update it in-place.
- * (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 (AggCheckCallContext(fcinfo, NULL))
- {
- int64 *arg = (int64 *) PG_GETARG_POINTER(0);
-
- if (unlikely(pg_add_s64_overflow(*arg, 1, arg)))
- ereport(ERROR,
- (errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE),
- errmsg("bigint out of range")));
-
- PG_RETURN_POINTER(arg);
- }
- else
-#endif
- {
- /* Not called as an aggregate, so just do it the dumb way */
- int64 arg = PG_GETARG_INT64(0);
- int64 result;
+ int64 arg = PG_GETARG_INT64(0);
+ int64 result;
- if (unlikely(pg_add_s64_overflow(arg, 1, &result)))
- ereport(ERROR,
- (errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE),
- errmsg("bigint out of range")));
+ if (unlikely(pg_add_s64_overflow(arg, 1, &result)))
+ ereport(ERROR,
+ (errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE),
+ errmsg("bigint out of range")));
- PG_RETURN_INT64(result);
- }
+ PG_RETURN_INT64(result);
}
Datum
int8dec(PG_FUNCTION_ARGS)
{
- /*
- * When int8 is pass-by-reference, we provide this special case to avoid
- * palloc overhead for COUNT(): when called as an aggregate, we know that
- * the argument is modifiable local storage, so just update it in-place.
- * (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 (AggCheckCallContext(fcinfo, NULL))
- {
- int64 *arg = (int64 *) PG_GETARG_POINTER(0);
-
- if (unlikely(pg_sub_s64_overflow(*arg, 1, arg)))
- ereport(ERROR,
- (errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE),
- errmsg("bigint out of range")));
- PG_RETURN_POINTER(arg);
- }
- else
-#endif
- {
- /* Not called as an aggregate, so just do it the dumb way */
- int64 arg = PG_GETARG_INT64(0);
- int64 result;
+ int64 arg = PG_GETARG_INT64(0);
+ int64 result;
- if (unlikely(pg_sub_s64_overflow(arg, 1, &result)))
- ereport(ERROR,
- (errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE),
- errmsg("bigint out of range")));
+ if (unlikely(pg_sub_s64_overflow(arg, 1, &result)))
+ ereport(ERROR,
+ (errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE),
+ errmsg("bigint out of range")));
- PG_RETURN_INT64(result);
- }
+ PG_RETURN_INT64(result);
}