96
96
cash_in (PG_FUNCTION_ARGS )
97
97
{
98
98
char * str = PG_GETARG_CSTRING (0 );
99
+ Node * escontext = fcinfo -> context ;
99
100
Cash result ;
100
101
Cash value = 0 ;
101
102
Cash dec = 0 ;
@@ -209,7 +210,7 @@ cash_in(PG_FUNCTION_ARGS)
209
210
210
211
if (pg_mul_s64_overflow (value , 10 , & value ) ||
211
212
pg_sub_s64_overflow (value , digit , & value ))
212
- ereport ( ERROR ,
213
+ ereturn ( escontext , ( Datum ) 0 ,
213
214
(errcode (ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE ),
214
215
errmsg ("value \"%s\" is out of range for type %s" ,
215
216
str , "money" )));
@@ -234,7 +235,7 @@ cash_in(PG_FUNCTION_ARGS)
234
235
{
235
236
/* remember we build the value in the negative */
236
237
if (pg_sub_s64_overflow (value , 1 , & value ))
237
- ereport ( ERROR ,
238
+ ereturn ( escontext , ( Datum ) 0 ,
238
239
(errcode (ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE ),
239
240
errmsg ("value \"%s\" is out of range for type %s" ,
240
241
str , "money" )));
@@ -244,7 +245,7 @@ cash_in(PG_FUNCTION_ARGS)
244
245
for (; dec < fpoint ; dec ++ )
245
246
{
246
247
if (pg_mul_s64_overflow (value , 10 , & value ))
247
- ereport ( ERROR ,
248
+ ereturn ( escontext , ( Datum ) 0 ,
248
249
(errcode (ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE ),
249
250
errmsg ("value \"%s\" is out of range for type %s" ,
250
251
str , "money" )));
@@ -271,7 +272,7 @@ cash_in(PG_FUNCTION_ARGS)
271
272
else if (strncmp (s , csymbol , strlen (csymbol )) == 0 )
272
273
s += strlen (csymbol );
273
274
else
274
- ereport ( ERROR ,
275
+ ereturn ( escontext , ( Datum ) 0 ,
275
276
(errcode (ERRCODE_INVALID_TEXT_REPRESENTATION ),
276
277
errmsg ("invalid input syntax for type %s: \"%s\"" ,
277
278
"money" , str )));
@@ -284,7 +285,7 @@ cash_in(PG_FUNCTION_ARGS)
284
285
if (sgn > 0 )
285
286
{
286
287
if (value == PG_INT64_MIN )
287
- ereport ( ERROR ,
288
+ ereturn ( escontext , ( Datum ) 0 ,
288
289
(errcode (ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE ),
289
290
errmsg ("value \"%s\" is out of range for type %s" ,
290
291
str , "money" )));
0 commit comments