9696cash_in (PG_FUNCTION_ARGS )
9797{
9898 char * str = PG_GETARG_CSTRING (0 );
99+ Node * escontext = fcinfo -> context ;
99100 Cash result ;
100101 Cash value = 0 ;
101102 Cash dec = 0 ;
@@ -209,7 +210,7 @@ cash_in(PG_FUNCTION_ARGS)
209210
210211 if (pg_mul_s64_overflow (value , 10 , & value ) ||
211212 pg_sub_s64_overflow (value , digit , & value ))
212- ereport ( ERROR ,
213+ ereturn ( escontext , ( Datum ) 0 ,
213214 (errcode (ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE ),
214215 errmsg ("value \"%s\" is out of range for type %s" ,
215216 str , "money" )));
@@ -234,7 +235,7 @@ cash_in(PG_FUNCTION_ARGS)
234235 {
235236 /* remember we build the value in the negative */
236237 if (pg_sub_s64_overflow (value , 1 , & value ))
237- ereport ( ERROR ,
238+ ereturn ( escontext , ( Datum ) 0 ,
238239 (errcode (ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE ),
239240 errmsg ("value \"%s\" is out of range for type %s" ,
240241 str , "money" )));
@@ -244,7 +245,7 @@ cash_in(PG_FUNCTION_ARGS)
244245 for (; dec < fpoint ; dec ++ )
245246 {
246247 if (pg_mul_s64_overflow (value , 10 , & value ))
247- ereport ( ERROR ,
248+ ereturn ( escontext , ( Datum ) 0 ,
248249 (errcode (ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE ),
249250 errmsg ("value \"%s\" is out of range for type %s" ,
250251 str , "money" )));
@@ -271,7 +272,7 @@ cash_in(PG_FUNCTION_ARGS)
271272 else if (strncmp (s , csymbol , strlen (csymbol )) == 0 )
272273 s += strlen (csymbol );
273274 else
274- ereport ( ERROR ,
275+ ereturn ( escontext , ( Datum ) 0 ,
275276 (errcode (ERRCODE_INVALID_TEXT_REPRESENTATION ),
276277 errmsg ("invalid input syntax for type %s: \"%s\"" ,
277278 "money" , str )));
@@ -284,7 +285,7 @@ cash_in(PG_FUNCTION_ARGS)
284285 if (sgn > 0 )
285286 {
286287 if (value == PG_INT64_MIN )
287- ereport ( ERROR ,
288+ ereturn ( escontext , ( Datum ) 0 ,
288289 (errcode (ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE ),
289290 errmsg ("value \"%s\" is out of range for type %s" ,
290291 str , "money" )));
0 commit comments