postgres.git / summary / log / commit / refs

commit    aebddf00d2a11ed05a9eaadf3823a2e39bfaede1
Author:   Tom Lane <tgl@sss.pgh.pa.us>
Date:     Sun Dec 19 17:48:41 2010 +0000
First released in: 9.1.0, 8.2.20, 8.3.14, 8.4.7, 9.0.3

    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.


contrib/intarray/_int_bool.c | 4 ++-- contrib/ltree/ltxtquery_io.c | 4 ++-- src/backend/utils/adt/tsquery.c | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/contrib/intarray/_int_bool.c b/contrib/intarray/_int_bool.c index 438db2ca95d..93901066116 100644 --- a/contrib/intarray/_int_bool.c +++ b/contrib/intarray/_int_bool.c @@ -196,8 +196,8 @@ makepol(WORKSTATE *state) case OPEN: if (makepol(state) == ERR) return ERR; - if (lenstack && (stack[lenstack - 1] == (int4) '&' || - stack[lenstack - 1] == (int4) '!')) + while (lenstack && (stack[lenstack - 1] == (int4) '&' || + stack[lenstack - 1] == (int4) '!')) { lenstack--; pushquery(state, OPR, stack[lenstack]); diff --git a/contrib/ltree/ltxtquery_io.c b/contrib/ltree/ltxtquery_io.c index b158c4b4416..d9163babf74 100644 --- a/contrib/ltree/ltxtquery_io.c +++ b/contrib/ltree/ltxtquery_io.c @@ -241,8 +241,8 @@ makepol(QPRS_STATE *state) case OPEN: if (makepol(state) == ERR) return ERR; - if (lenstack && (stack[lenstack - 1] == (int4) '&' || - stack[lenstack - 1] == (int4) '!')) + while (lenstack && (stack[lenstack - 1] == (int4) '&' || + stack[lenstack - 1] == (int4) '!')) { lenstack--; pushquery(state, OPR, stack[lenstack], 0, 0, 0); diff --git a/src/backend/utils/adt/tsquery.c b/src/backend/utils/adt/tsquery.c index c419e86ced8..f5c1650a10e 100644 --- a/src/backend/utils/adt/tsquery.c +++ b/src/backend/utils/adt/tsquery.c @@ -371,8 +371,8 @@ makepol(TSQueryParserState state, case PT_OPEN: makepol(state, pushval, opaque); - if (lenstack && (opstack[lenstack - 1] == OP_AND || - opstack[lenstack - 1] == OP_NOT)) + while (lenstack && (opstack[lenstack - 1] == OP_AND || + opstack[lenstack - 1] == OP_NOT)) { lenstack--; pushOperator(state, opstack[lenstack]); [parent: 8b4d3d44dc7d]