aboutsummaryrefslogtreecommitdiff
path: root/src/backend/utils/adt/int8.c
diff options
context:
space:
mode:
authorThomas G. Lockhart <lockhart@fourpalms.org>1999-04-15 13:34:45 +0000
committerThomas G. Lockhart <lockhart@fourpalms.org>1999-04-15 13:34:45 +0000
commit1d1cf38c0d02908e3c6520dab94c878947ca8152 (patch)
tree875a5de76044ca5732992d3820b2710c35972640 /src/backend/utils/adt/int8.c
parent84746009c2e5686217679ccaae6ed2a18164d37c (diff)
downloadpostgresql-1d1cf38c0d02908e3c6520dab94c878947ca8152.tar.gz
postgresql-1d1cf38c0d02908e3c6520dab94c878947ca8152.zip
Fix max(int8) result by making sure int8larger() copies its result
rather than reusing the input storage. Also made the same fix to int8smaller(), though there wasn't a symptom, and went through and verified that other pass-by-reference data types do the same thing. Not an issue for the by-value types.
Diffstat (limited to 'src/backend/utils/adt/int8.c')
-rw-r--r--src/backend/utils/adt/int8.c21
1 files changed, 2 insertions, 19 deletions
diff --git a/src/backend/utils/adt/int8.c b/src/backend/utils/adt/int8.c
index e3506b2d91e..11363ba6459 100644
--- a/src/backend/utils/adt/int8.c
+++ b/src/backend/utils/adt/int8.c
@@ -228,11 +228,7 @@ int8um(int64 *val)
if (!PointerIsValid(val))
return NULL;
-#if NOT_USED
- *result = temp - (*val);
-#else
result = int8mi(&temp, val);
-#endif
return result;
} /* int8um() */
@@ -293,39 +289,27 @@ int8div(int64 *val1, int64 *val2)
int64 *
int8larger(int64 *val1, int64 *val2)
{
-#if NOT_USED
int64 *result = palloc(sizeof(int64));
-#endif
-
if ((!PointerIsValid(val1)) || (!PointerIsValid(val2)))
return NULL;
-#if NOT_USED
*result = ((*val1 > *val2) ? *val1 : *val2);
return result;
-#endif
- return (*val1 > *val2) ? val1 : val2;
} /* int8larger() */
int64 *
int8smaller(int64 *val1, int64 *val2)
{
-#if NOT_USED
int64 *result = palloc(sizeof(int64));
-#endif
-
if ((!PointerIsValid(val1)) || (!PointerIsValid(val2)))
return NULL;
-#if NOT_USED
*result = ((*val1 < *val2) ? *val1 : *val2);
return result;
-#endif
- return (*val1 < *val2) ? val1 : val2;
} /* int8smaller() */
@@ -458,7 +442,6 @@ int84(int64 *val)
elog(ERROR, "Invalid (null) int64, can't convert int8 to int4", NULL);
#if NOT_USED
-
/*
* Hmm. This conditional always tests true on my i686/linux box. It's
* a gcc compiler bug, or I'm missing something obvious, which is more
@@ -466,8 +449,8 @@ int84(int64 *val)
*/
if ((*val < INT_MIN) || (*val > INT_MAX))
#endif
- if ((*val < (-pow(2, 31) + 1)) || (*val > (pow(2, 31) - 1)))
- elog(ERROR, "int8 conversion to int4 is out of range", NULL);
+ if ((*val < (-pow(2, 31) + 1)) || (*val > (pow(2, 31) - 1)))
+ elog(ERROR, "int8 conversion to int4 is out of range", NULL);
result = *val;