@@ -1027,10 +1027,14 @@ bytea_int2(PG_FUNCTION_ARGS)
10271027
10281028 /* Check that the byte array is not too long */
10291029 if (len > sizeof (result ))
1030- ereport (ERROR ,
1030+ {
1031+ errsave (fcinfo -> context ,
10311032 errcode (ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE ),
10321033 errmsg ("smallint out of range" ));
10331034
1035+ PG_RETURN_NULL ();
1036+ }
1037+
10341038 /* Convert it to an integer; most significant bytes come first */
10351039 result = 0 ;
10361040 for (int i = 0 ; i < len ; i ++ )
@@ -1052,10 +1056,14 @@ bytea_int4(PG_FUNCTION_ARGS)
10521056
10531057 /* Check that the byte array is not too long */
10541058 if (len > sizeof (result ))
1055- ereport (ERROR ,
1059+ {
1060+ errsave (fcinfo -> context ,
10561061 errcode (ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE ),
10571062 errmsg ("integer out of range" ));
10581063
1064+ PG_RETURN_NULL ();
1065+ }
1066+
10591067 /* Convert it to an integer; most significant bytes come first */
10601068 result = 0 ;
10611069 for (int i = 0 ; i < len ; i ++ )
@@ -1077,10 +1085,14 @@ bytea_int8(PG_FUNCTION_ARGS)
10771085
10781086 /* Check that the byte array is not too long */
10791087 if (len > sizeof (result ))
1080- ereport (ERROR ,
1088+ {
1089+ errsave (fcinfo -> context ,
10811090 errcode (ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE ),
10821091 errmsg ("bigint out of range" ));
10831092
1093+ PG_RETURN_NULL ();
1094+ }
1095+
10841096 /* Convert it to an integer; most significant bytes come first */
10851097 result = 0 ;
10861098 for (int i = 0 ; i < len ; i ++ )
0 commit comments