Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit abc1026

Browse files
committed
Fix erroneous parsing of tsquery input "... & !(subexpression) | ..."
After parsing a parenthesized subexpression, we must pop all pending ANDs and NOTs off the stack, just like the case for a simple operand. Per bug #5793. Also fix clones of this routine in contrib/intarray and contrib/ltree, where input of types query_int and ltxtquery had the same problem. Back-patch to all supported versions.
1 parent dcb09b5 commit abc1026

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

contrib/intarray/_int_bool.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -196,8 +196,8 @@ makepol(WORKSTATE *state)
196196
case OPEN:
197197
if (makepol(state) == ERR)
198198
return ERR;
199-
if (lenstack && (stack[lenstack - 1] == (int4) '&' ||
200-
stack[lenstack - 1] == (int4) '!'))
199+
while (lenstack && (stack[lenstack - 1] == (int4) '&' ||
200+
stack[lenstack - 1] == (int4) '!'))
201201
{
202202
lenstack--;
203203
pushquery(state, OPR, stack[lenstack]);

contrib/ltree/ltxtquery_io.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -241,8 +241,8 @@ makepol(QPRS_STATE *state)
241241
case OPEN:
242242
if (makepol(state) == ERR)
243243
return ERR;
244-
if (lenstack && (stack[lenstack - 1] == (int4) '&' ||
245-
stack[lenstack - 1] == (int4) '!'))
244+
while (lenstack && (stack[lenstack - 1] == (int4) '&' ||
245+
stack[lenstack - 1] == (int4) '!'))
246246
{
247247
lenstack--;
248248
pushquery(state, OPR, stack[lenstack], 0, 0, 0);

src/backend/utils/adt/tsquery.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -371,8 +371,8 @@ makepol(TSQueryParserState state,
371371
case PT_OPEN:
372372
makepol(state, pushval, opaque);
373373

374-
if (lenstack && (opstack[lenstack - 1] == OP_AND ||
375-
opstack[lenstack - 1] == OP_NOT))
374+
while (lenstack && (opstack[lenstack - 1] == OP_AND ||
375+
opstack[lenstack - 1] == OP_NOT))
376376
{
377377
lenstack--;
378378
pushOperator(state, opstack[lenstack]);

0 commit comments

Comments
 (0)