@@ -35,6 +35,7 @@ typedef struct
35
35
char * buf ;
36
36
int32 state ;
37
37
int32 count ;
38
+ struct Node * escontext ;
38
39
/* reverse polish notation in list (for temporary usage) */
39
40
NODE * str ;
40
41
/* number in str */
@@ -179,7 +180,7 @@ makepol(WORKSTATE *state)
179
180
else
180
181
{
181
182
if (lenstack == STACKDEPTH )
182
- ereport ( ERROR ,
183
+ ereturn ( state -> escontext , ERR ,
183
184
(errcode (ERRCODE_STATEMENT_TOO_COMPLEX ),
184
185
errmsg ("statement too complex" )));
185
186
stack [lenstack ] = val ;
@@ -206,10 +207,9 @@ makepol(WORKSTATE *state)
206
207
break ;
207
208
case ERR :
208
209
default :
209
- ereport ( ERROR ,
210
+ ereturn ( state -> escontext , ERR ,
210
211
(errcode (ERRCODE_SYNTAX_ERROR ),
211
212
errmsg ("syntax error" )));
212
- return ERR ;
213
213
}
214
214
}
215
215
@@ -483,6 +483,7 @@ bqarr_in(PG_FUNCTION_ARGS)
483
483
ITEM * ptr ;
484
484
NODE * tmp ;
485
485
int32 pos = 0 ;
486
+ struct Node * escontext = fcinfo -> context ;
486
487
487
488
#ifdef BS_DEBUG
488
489
StringInfoData pbuf ;
@@ -493,16 +494,18 @@ bqarr_in(PG_FUNCTION_ARGS)
493
494
state .count = 0 ;
494
495
state .num = 0 ;
495
496
state .str = NULL ;
497
+ state .escontext = escontext ;
496
498
497
499
/* make polish notation (postfix, but in reverse order) */
498
- makepol (& state );
500
+ if (makepol (& state ) == ERR )
501
+ PG_RETURN_NULL ();
499
502
if (!state .num )
500
- ereport ( ERROR ,
503
+ ereturn ( escontext , ( Datum ) 0 ,
501
504
(errcode (ERRCODE_INVALID_PARAMETER_VALUE ),
502
505
errmsg ("empty query" )));
503
506
504
507
if (state .num > QUERYTYPEMAXITEMS )
505
- ereport ( ERROR ,
508
+ ereturn ( escontext , ( Datum ) 0 ,
506
509
(errcode (ERRCODE_PROGRAM_LIMIT_EXCEEDED ),
507
510
errmsg ("number of query items (%d) exceeds the maximum allowed (%d)" ,
508
511
state .num , (int ) QUERYTYPEMAXITEMS )));
0 commit comments