]> git.ipfire.org Git - thirdparty/postgresql.git/commitdiff
Fix erroneous parsing of tsquery input "... & !(subexpression) | ..."
authorTom Lane <tgl@sss.pgh.pa.us>
Sun, 19 Dec 2010 17:48:58 +0000 (12:48 -0500)
committerTom Lane <tgl@sss.pgh.pa.us>
Sun, 19 Dec 2010 17:48:58 +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
contrib/tsearch2/query.c

index 8517010e5ed28a364afe785598f1a1917842a8c5..64c8e00e2f3a5f9028a78c329c6024e35d38fe55 100644 (file)
@@ -189,8 +189,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 ca6325adf72b1f59f486bfa4cf33b0f66f306149..44fcc954ece20525d6cd91801451a174fe482c76 100644 (file)
@@ -234,8 +234,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 c86169874cbfd77dbde43dcccba81e011110e031..8d313e1649367e15c687c7a4f790ae3db410df9c 100644 (file)
@@ -396,8 +396,8 @@ makepol(QPRS_STATE * state, void (*pushval) (QPRS_STATE *, int, char *, int, int
                        case OPEN:
                                if (makepol(state, pushval) == 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);