pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: ms@instytut.com.pl
Cc: pgsql-bugs@postgresql.org
Subject: Re: BUG #5793: tsquery error
Date: Sat, 18 Dec 2010 23:51:06 -0500
Message-ID: <16079.1292734266@sss.pgh.pa.us> (raw)
In-Reply-To: <201012180013.oBI0DPfc074511@wwwmaster.postgresql.org>
References: <201012180013.oBI0DPfc074511@wwwmaster.postgresql.org>

"" <ms@instytut.com.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

inline patch 1: src/backend/utils/adt/tsquery.c (+2/-2 lines) download inline-1.patchdiff --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

view thread (2+ messages)

Message-ID: <16079.1292734266@sss.pgh.pa.us>
Permalink:  ../16079.1292734266@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/16079.1292734266@sss.pgh.pa.us

 ·  · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-bugs@postgresql.org
  Cc: tgl@sss.pgh.pa.us, ms@instytut.com.pl
  Subject: Re: BUG #5793: tsquery error
  In-Reply-To: <16079.1292734266@sss.pgh.pa.us>
  References: <201012180013.oBI0DPfc074511@wwwmaster.postgresql.org> <16079.1292734266@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox