]> granicus.if.org Git - postgresql/commitdiff
Fix erroneous parsing of tsquery input "... & !(subexpression) | ..."
authorTom Lane <tgl@sss.pgh.pa.us>
Sun, 19 Dec 2010 17:48:41 +0000 (12:48 -0500)
committerTom Lane <tgl@sss.pgh.pa.us>
Sun, 19 Dec 2010 17:48:41 +0000 (12:48 -0500)
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
contrib/ltree/ltxtquery_io.c
src/backend/utils/adt/tsquery.c

index 438db2ca95dbd3ba1846d452864e6a900aec06c4..939010661160dc1f000928032d2876900e525d3a 100644 (file)
@@ -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]);
index b158c4b4416f16d9593f153c17b5a9558c30b7d9..d9163babf74807dbe72cd0b04b15d5d5e40b62eb 100644 (file)
@@ -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);
index c419e86ced83738c05bbc2572dd424afcc03be40..f5c1650a10ef1e71cdbff5c923e3abf614559f31 100644 (file)
@@ -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]);