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.
REL8_2_STABLE
Tom Lane 15 years ago
parent 10de92f87f
commit b053c53248
  1. 2
      contrib/intarray/_int_bool.c
  2. 2
      contrib/ltree/ltxtquery_io.c
  3. 2
      contrib/tsearch2/query.c

@ -189,7 +189,7 @@ makepol(WORKSTATE * state)
case OPEN:
if (makepol(state) == ERR)
return ERR;
if (lenstack && (stack[lenstack - 1] == (int4) '&' ||
while (lenstack && (stack[lenstack - 1] == (int4) '&' ||
stack[lenstack - 1] == (int4) '!'))
{
lenstack--;

@ -234,7 +234,7 @@ makepol(QPRS_STATE * state)
case OPEN:
if (makepol(state) == ERR)
return ERR;
if (lenstack && (stack[lenstack - 1] == (int4) '&' ||
while (lenstack && (stack[lenstack - 1] == (int4) '&' ||
stack[lenstack - 1] == (int4) '!'))
{
lenstack--;

@ -396,7 +396,7 @@ 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) '&' ||
while (lenstack && (stack[lenstack - 1] == (int4) '&' ||
stack[lenstack - 1] == (int4) '!'))
{
lenstack--;

Loading…
Cancel
Save