@ -1212,15 +1212,8 @@ dtoi4(PG_FUNCTION_ARGS)
*/
*/
num = rint ( num ) ;
num = rint ( num ) ;
/*
/* Range check */
* Range check . We must be careful here that the boundary values are
if ( unlikely ( isnan ( num ) | | ! FLOAT8_FITS_IN_INT32 ( num ) ) )
* expressed exactly in the float domain . We expect PG_INT32_MIN to be an
* exact power of 2 , so it will be represented exactly ; but PG_INT32_MAX
* isn ' t , and might get rounded off , so avoid using it .
*/
if ( unlikely ( num < ( float8 ) PG_INT32_MIN | |
num > = - ( ( float8 ) PG_INT32_MIN ) | |
isnan ( num ) ) )
ereport ( ERROR ,
ereport ( ERROR ,
( errcode ( ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE ) ,
( errcode ( ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE ) ,
errmsg ( " integer out of range " ) ) ) ;
errmsg ( " integer out of range " ) ) ) ;
@ -1244,15 +1237,8 @@ dtoi2(PG_FUNCTION_ARGS)
*/
*/
num = rint ( num ) ;
num = rint ( num ) ;
/*
/* Range check */
* Range check . We must be careful here that the boundary values are
if ( unlikely ( isnan ( num ) | | ! FLOAT8_FITS_IN_INT16 ( num ) ) )
* expressed exactly in the float domain . We expect PG_INT16_MIN to be an
* exact power of 2 , so it will be represented exactly ; but PG_INT16_MAX
* isn ' t , and might get rounded off , so avoid using it .
*/
if ( unlikely ( num < ( float8 ) PG_INT16_MIN | |
num > = - ( ( float8 ) PG_INT16_MIN ) | |
isnan ( num ) ) )
ereport ( ERROR ,
ereport ( ERROR ,
( errcode ( ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE ) ,
( errcode ( ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE ) ,
errmsg ( " smallint out of range " ) ) ) ;
errmsg ( " smallint out of range " ) ) ) ;
@ -1300,15 +1286,8 @@ ftoi4(PG_FUNCTION_ARGS)
*/
*/
num = rint ( num ) ;
num = rint ( num ) ;
/*
/* Range check */
* Range check . We must be careful here that the boundary values are
if ( unlikely ( isnan ( num ) | | ! FLOAT4_FITS_IN_INT32 ( num ) ) )
* expressed exactly in the float domain . We expect PG_INT32_MIN to be an
* exact power of 2 , so it will be represented exactly ; but PG_INT32_MAX
* isn ' t , and might get rounded off , so avoid using it .
*/
if ( unlikely ( num < ( float4 ) PG_INT32_MIN | |
num > = - ( ( float4 ) PG_INT32_MIN ) | |
isnan ( num ) ) )
ereport ( ERROR ,
ereport ( ERROR ,
( errcode ( ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE ) ,
( errcode ( ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE ) ,
errmsg ( " integer out of range " ) ) ) ;
errmsg ( " integer out of range " ) ) ) ;
@ -1332,15 +1311,8 @@ ftoi2(PG_FUNCTION_ARGS)
*/
*/
num = rint ( num ) ;
num = rint ( num ) ;
/*
/* Range check */
* Range check . We must be careful here that the boundary values are
if ( unlikely ( isnan ( num ) | | ! FLOAT4_FITS_IN_INT16 ( num ) ) )
* expressed exactly in the float domain . We expect PG_INT16_MIN to be an
* exact power of 2 , so it will be represented exactly ; but PG_INT16_MAX
* isn ' t , and might get rounded off , so avoid using it .
*/
if ( unlikely ( num < ( float4 ) PG_INT16_MIN | |
num > = - ( ( float4 ) PG_INT16_MIN ) | |
isnan ( num ) ) )
ereport ( ERROR ,
ereport ( ERROR ,
( errcode ( ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE ) ,
( errcode ( ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE ) ,
errmsg ( " smallint out of range " ) ) ) ;
errmsg ( " smallint out of range " ) ) ) ;