1
0
mirror of https://github.com/postgres/postgres.git synced 2025-06-26 12:21:12 +03:00

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.
This commit is contained in:
Tom Lane
2010-12-19 12:48:53 -05:00
parent b16a18491f
commit d9b99b4b60
3 changed files with 6 additions and 6 deletions

View File

@ -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--;

View File

@ -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--;

View File

@ -360,7 +360,7 @@ makepol(TSQueryParserState state,
case PT_OPEN:
makepol(state, pushval, opaque);
if (lenstack && (opstack[lenstack - 1] == OP_AND ||
while (lenstack && (opstack[lenstack - 1] == OP_AND ||
opstack[lenstack - 1] == OP_NOT))
{
lenstack--;