aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2010-12-19 12:48:58 -0500
committerTom Lane <tgl@sss.pgh.pa.us>2010-12-19 12:48:58 -0500
commitb053c532489a3fa1e01b196c15a0f14138ee9c3a (patch)
treef9a9fb1b52798c61ac457183869d3fc74c8843ec
parent10de92f87fdf78f764e620a4be8c6f72b4fff18b (diff)
downloadpostgresql-b053c532489a3fa1e01b196c15a0f14138ee9c3a.tar.gz
postgresql-b053c532489a3fa1e01b196c15a0f14138ee9c3a.zip
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.
-rw-r--r--contrib/intarray/_int_bool.c4
-rw-r--r--contrib/ltree/ltxtquery_io.c4
-rw-r--r--contrib/tsearch2/query.c4
3 files changed, 6 insertions, 6 deletions
diff --git a/contrib/intarray/_int_bool.c b/contrib/intarray/_int_bool.c
index 8517010e5ed..64c8e00e2f3 100644
--- a/contrib/intarray/_int_bool.c
+++ b/contrib/intarray/_int_bool.c
@@ -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]);
diff --git a/contrib/ltree/ltxtquery_io.c b/contrib/ltree/ltxtquery_io.c
index ca6325adf72..44fcc954ece 100644
--- a/contrib/ltree/ltxtquery_io.c
+++ b/contrib/ltree/ltxtquery_io.c
@@ -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);
diff --git a/contrib/tsearch2/query.c b/contrib/tsearch2/query.c
index c86169874cb..8d313e16493 100644
--- a/contrib/tsearch2/query.c
+++ b/contrib/tsearch2/query.c
@@ -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);