mirror of
https://github.com/postgres/postgres.git
synced 2025-06-13 07:41:39 +03:00
Improve performance of float overflow checks in btree_gist
The current code could do unnecessary calls to isinf() (two for the
argument values all the time while one could be sufficient in some
cases). zero_is_valid was never used but the result value was still
checked on 0 in the first position of the check.
This is similar to 607f8ce
. btree_gist has just copy-pasted the code
doing those checks from the backend float4/8 code, as of the macro
CHECKFLOATVAL(), to do the work.
Author: Haiying Tang
Discussion: https://postgr.es/m/OS0PR01MB611358E3A7BC3C2F874AC36BFBF39@OS0PR01MB6113.jpnprd01.prod.outlook.com
This commit is contained in:
@ -89,23 +89,6 @@ typedef struct
|
||||
|
||||
#define GET_FLOAT_DISTANCE(t, arg1, arg2) Abs( ((float8) *((const t *) (arg1))) - ((float8) *((const t *) (arg2))) )
|
||||
|
||||
/*
|
||||
* check to see if a float4/8 val has underflowed or overflowed
|
||||
* borrowed from src/backend/utils/adt/float.c
|
||||
*/
|
||||
#define CHECKFLOATVAL(val, inf_is_valid, zero_is_valid) \
|
||||
do { \
|
||||
if (isinf(val) && !(inf_is_valid)) \
|
||||
ereport(ERROR, \
|
||||
(errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE), \
|
||||
errmsg("value out of range: overflow"))); \
|
||||
\
|
||||
if ((val) == 0.0 && !(zero_is_valid)) \
|
||||
ereport(ERROR, \
|
||||
(errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE), \
|
||||
errmsg("value out of range: underflow"))); \
|
||||
} while(0)
|
||||
|
||||
|
||||
extern Interval *abs_interval(Interval *a);
|
||||
|
||||
|
Reference in New Issue
Block a user