diff options
author | Andrew Dunstan | 2022-12-28 14:53:00 +0000 |
---|---|---|
committer | Andrew Dunstan | 2022-12-28 15:00:12 +0000 |
commit | 3b76622e04d8656fb44e7c932cb243e2d92fe40e (patch) | |
tree | 6840be0512c688b2e92d43b6138fee7465d7030f /contrib/intarray/_int_bool.c | |
parent | 24b55cd949a11b712927acf2557683976ee149ac (diff) |
Convert contrib/intarray's bqarr_in() to report errors softly
Reviewed by Tom Lane and Amul Sul
Discussion: https://postgr.es/m/[email protected]
Diffstat (limited to 'contrib/intarray/_int_bool.c')
-rw-r--r-- | contrib/intarray/_int_bool.c | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/contrib/intarray/_int_bool.c b/contrib/intarray/_int_bool.c index 3ed88af76d7..8fc6ad87fc7 100644 --- a/contrib/intarray/_int_bool.c +++ b/contrib/intarray/_int_bool.c @@ -35,6 +35,7 @@ typedef struct char *buf; int32 state; int32 count; + struct Node *escontext; /* reverse polish notation in list (for temporary usage) */ NODE *str; /* number in str */ @@ -179,7 +180,7 @@ makepol(WORKSTATE *state) else { if (lenstack == STACKDEPTH) - ereport(ERROR, + ereturn(state->escontext, ERR, (errcode(ERRCODE_STATEMENT_TOO_COMPLEX), errmsg("statement too complex"))); stack[lenstack] = val; @@ -206,10 +207,9 @@ makepol(WORKSTATE *state) break; case ERR: default: - ereport(ERROR, + ereturn(state->escontext, ERR, (errcode(ERRCODE_SYNTAX_ERROR), errmsg("syntax error"))); - return ERR; } } @@ -483,6 +483,7 @@ bqarr_in(PG_FUNCTION_ARGS) ITEM *ptr; NODE *tmp; int32 pos = 0; + struct Node *escontext = fcinfo->context; #ifdef BS_DEBUG StringInfoData pbuf; @@ -493,16 +494,18 @@ bqarr_in(PG_FUNCTION_ARGS) state.count = 0; state.num = 0; state.str = NULL; + state.escontext = escontext; /* make polish notation (postfix, but in reverse order) */ - makepol(&state); + if (makepol(&state) == ERR) + PG_RETURN_NULL(); if (!state.num) - ereport(ERROR, + ereturn(escontext, (Datum) 0, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("empty query"))); if (state.num > QUERYTYPEMAXITEMS) - ereport(ERROR, + ereturn(escontext, (Datum) 0, (errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED), errmsg("number of query items (%d) exceeds the maximum allowed (%d)", state.num, (int) QUERYTYPEMAXITEMS))); |