Re: BUG #5793: tsquery error

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "" <ms(at)instytut(dot)com(dot)pl>
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #5793: tsquery error
Date: 2010-12-19 04:51:06
Message-ID: 16079.1292734266@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

"" <ms(at)instytut(dot)com(dot)pl> writes:
> The expression 'a & !(c) | a & b' is interpreted as '( a | !c ) & a & b'.
> select 'a & !(c) | a & b'::tsquery;

> Subsequent "rewrites" of the same expression give inconsistent results:

> select '(a & !(c | d)) | (a & b)'::tsquery; -> 'a & !(c | d) | a & b'
> (correct)
> select 'a & !(c | d) | a & b'::tsquery; -> '(a | !(c | d)) & a & b' (not
> correct)

Hmm. The immediate problem seems to be fixed by

diff --git a/src/backend/utils/adt/tsquery.c b/src/backend/utils/adt/tsquery.c
index db9236a474157a7851e2a80516e865c050543634..ba09b3b2ce7fcc0815edf4a4622663291d6f0b8f 100644
*** a/src/backend/utils/adt/tsquery.c
--- b/src/backend/utils/adt/tsquery.c
*************** makepol(TSQueryParserState state,
*** 371,378 ****
case PT_OPEN:
makepol(state, pushval, opaque);

! if (lenstack && (opstack[lenstack - 1] == OP_AND ||
! opstack[lenstack - 1] == OP_NOT))
{
lenstack--;
pushOperator(state, opstack[lenstack]);
--- 371,378 ----
case PT_OPEN:
makepol(state, pushval, opaque);

! while (lenstack && (opstack[lenstack - 1] == OP_AND ||
! opstack[lenstack - 1] == OP_NOT))
{
lenstack--;
pushOperator(state, opstack[lenstack]);

but I can't say that I've got much confidence in the rest of that
function. It's an utter kluge.

regards, tom lane

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Greg Sabino Mullane 2010-12-19 12:42:31 Re: [Fwd: DBD::Pg on HP-UX 11.31 64bit]
Previous Message Kevin Grittner 2010-12-18 20:49:10 Re: BUG #5791: Tables are not viewing through pgadmin