!1905 issue修复: ignore hint在类型转换的场景下,插入错误值

Merge pull request !1905 from zhangzhixian/master
This commit is contained in:
opengauss-bot
2022-06-29 08:49:02 +00:00
committed by Gitee
2 changed files with 16 additions and 16 deletions

View File

@ -359,7 +359,7 @@ Datum float4in(PG_FUNCTION_ARGS)
if (fcinfo->can_ignore) {
if (isinf((float4)val) && !isinf(val)) {
ereport(WARNING, (errmsg("value out of range: overflow")));
PG_RETURN_FLOAT4(num < 0 ? FLT_MIN : FLT_MAX);
PG_RETURN_FLOAT4(val < 0 ? -FLT_MAX : FLT_MAX);
}
if (((float4)val) == 0.0 && val != 0) {
ereport(WARNING, (errmsg("value out of range: underflow")));
@ -1189,7 +1189,7 @@ Datum dtof(PG_FUNCTION_ARGS)
if (fcinfo->can_ignore) {
if (isinf((float4)num) && !isinf(num)) {
ereport(WARNING, (errmsg("value out of range: overflow")));
PG_RETURN_FLOAT4(num < 0 ? FLT_MIN : FLT_MAX);
PG_RETURN_FLOAT4(num < 0 ? -FLT_MAX : FLT_MAX);
}
if (((float4)num) == 0.0 && num != 0) {
ereport(WARNING, (errmsg("value out of range: underflow")));
@ -1257,7 +1257,7 @@ Datum dtoi2(PG_FUNCTION_ARGS)
if (num < (float8)PG_INT16_MIN || num >= -((float8)PG_INT16_MIN) || isnan(num)) {
if (fcinfo->can_ignore && !isnan(num)) {
ereport(WARNING, (errmsg("smallint out of range")));
PG_RETURN_INT16(num < (float8)PG_INT16_MIN ? SHRT_MAX : SHRT_MIN);
PG_RETURN_INT16(num < (float8)PG_INT16_MIN ? SHRT_MIN : SHRT_MAX);
}
ereport(ERROR, (errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE), errmsg("smallint out of range")));
}

View File

@ -492,8 +492,8 @@ select * from t_smallint;
--------
100
-100
-32768
32767
-32768
100
-100
(6 rows)
@ -579,14 +579,14 @@ CONTEXT: referenced column: num
insert /*+ ignore_error */ into t_float4 values(123.123::float8);
insert /*+ ignore_error */ into t_float4 values(-123.123::float8);
select * from t_float4;
num
-------------
123.123
-123.123
3.40282e+38
1.17549e-38
123.123
-123.123
num
--------------
123.123
-123.123
3.40282e+38
-3.40282e+38
123.123
-123.123
(6 rows)
-- test for numeric to float4
@ -602,10 +602,10 @@ CONTEXT: referenced column: num
WARNING: value out of range: overflow
CONTEXT: referenced column: num
select * from t_float4;
num
-------------
3.40282e+38
3.40282e+38
num
--------------
3.40282e+38
-3.40282e+38
(2 rows)
-- test for char(n) converting