From 15884d494e620218d1618c491bf6e09860a863f2 Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Sun, 19 Dec 2010 12:48:48 -0500 Subject: 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. --- src/backend/utils/adt/tsquery.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/backend/utils/adt/tsquery.c') diff --git a/src/backend/utils/adt/tsquery.c b/src/backend/utils/adt/tsquery.c index 7ca84678337..b8d8128de39 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]); -- cgit v1.2.3