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

Lines changed: 2 additions & 2 deletions
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

Lines changed: 2 additions & 2 deletions
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

Lines changed: 2 additions & 2 deletions
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)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy