mirror of
https://github.com/postgres/postgres.git
synced 2025-07-30 11:03:19 +03:00
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.
This commit is contained in:
@ -228,11 +228,7 @@ int8um(int64 *val)
|
|||||||
if (!PointerIsValid(val))
|
if (!PointerIsValid(val))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
#if NOT_USED
|
|
||||||
*result = temp - (*val);
|
|
||||||
#else
|
|
||||||
result = int8mi(&temp, val);
|
result = int8mi(&temp, val);
|
||||||
#endif
|
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
} /* int8um() */
|
} /* int8um() */
|
||||||
@ -293,39 +289,27 @@ int8div(int64 *val1, int64 *val2)
|
|||||||
int64 *
|
int64 *
|
||||||
int8larger(int64 *val1, int64 *val2)
|
int8larger(int64 *val1, int64 *val2)
|
||||||
{
|
{
|
||||||
#if NOT_USED
|
|
||||||
int64 *result = palloc(sizeof(int64));
|
int64 *result = palloc(sizeof(int64));
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if ((!PointerIsValid(val1)) || (!PointerIsValid(val2)))
|
if ((!PointerIsValid(val1)) || (!PointerIsValid(val2)))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
#if NOT_USED
|
|
||||||
*result = ((*val1 > *val2) ? *val1 : *val2);
|
*result = ((*val1 > *val2) ? *val1 : *val2);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
#endif
|
|
||||||
return (*val1 > *val2) ? val1 : val2;
|
|
||||||
} /* int8larger() */
|
} /* int8larger() */
|
||||||
|
|
||||||
int64 *
|
int64 *
|
||||||
int8smaller(int64 *val1, int64 *val2)
|
int8smaller(int64 *val1, int64 *val2)
|
||||||
{
|
{
|
||||||
#if NOT_USED
|
|
||||||
int64 *result = palloc(sizeof(int64));
|
int64 *result = palloc(sizeof(int64));
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if ((!PointerIsValid(val1)) || (!PointerIsValid(val2)))
|
if ((!PointerIsValid(val1)) || (!PointerIsValid(val2)))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
#if NOT_USED
|
|
||||||
*result = ((*val1 < *val2) ? *val1 : *val2);
|
*result = ((*val1 < *val2) ? *val1 : *val2);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
#endif
|
|
||||||
return (*val1 < *val2) ? val1 : val2;
|
|
||||||
} /* int8smaller() */
|
} /* int8smaller() */
|
||||||
|
|
||||||
|
|
||||||
@ -458,7 +442,6 @@ int84(int64 *val)
|
|||||||
elog(ERROR, "Invalid (null) int64, can't convert int8 to int4", NULL);
|
elog(ERROR, "Invalid (null) int64, can't convert int8 to int4", NULL);
|
||||||
|
|
||||||
#if NOT_USED
|
#if NOT_USED
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Hmm. This conditional always tests true on my i686/linux box. It's
|
* 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
|
* 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))
|
if ((*val < INT_MIN) || (*val > INT_MAX))
|
||||||
#endif
|
#endif
|
||||||
if ((*val < (-pow(2, 31) + 1)) || (*val > (pow(2, 31) - 1)))
|
if ((*val < (-pow(2, 31) + 1)) || (*val > (pow(2, 31) - 1)))
|
||||||
elog(ERROR, "int8 conversion to int4 is out of range", NULL);
|
elog(ERROR, "int8 conversion to int4 is out of range", NULL);
|
||||||
|
|
||||||
result = *val;
|
result = *val;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user