Re: websearch_to_tsquery() returns queries that don't match to_tsvector()

From: Alexander Korotkov <aekorotkov(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>, Valentin Gatien-Baron <valentin(dot)gatienbaron(at)gmail(dot)com>, Teodor Sigaev <teodor(at)postgrespro(dot)ru>, Oleg Bartunov <obartunov(at)postgrespro(dot)ru>
Subject: Re: websearch_to_tsquery() returns queries that don't match to_tsvector()
Date: 2021-05-02 18:12:11
Message-ID: CAPpHfduYuJPf8oJ-SMqK8FOsFcMtK+nBxe=NTPRamUK9DNqP=Q@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs pgsql-hackers

On Sun, May 2, 2021 at 9:04 PM Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> Alexander Korotkov <aekorotkov(at)gmail(dot)com> writes:
> > Ooops, I've included this by oversight. The next revision is attached.
> > Anything besides that?
>
> Some quick eyeball review:
>
> + /* Everything is quotes is processed as a single token */
>
> Should read "Everything in quotes ..."
>
> - /* or else gettoken_tsvector() will raise an error */
> + /* or else ƒtsvector() will raise an error */
>
> Looks like an unintentional change?

Thank you for catching this!

> @@ -846,7 +812,6 @@ parse_tsquery(char *buf,
> state.buffer = buf;
> state.buf = buf;
> state.count = 0;
> - state.in_quotes = false;
> state.state = WAITFIRSTOPERAND;
> state.polstr = NIL;
>
> This change seems wrong/unsafe too.

It seems OK, because this patch removes in_quotes field altogether.
We don't have to know whether we in quotes in the state, since we
process everything in quotes as a single token.

------
Regards,
Alexander Korotkov

Attachment Content-Type Size
0001-Make-websearch_to_tsquery-parse-text-in-quotes-as-v3.patch application/octet-stream 6.5 KB

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Alexander Korotkov 2021-05-02 18:12:44 Re: websearch_to_tsquery() returns queries that don't match to_tsvector()
Previous Message Zhihong Yu 2021-05-02 18:09:49 Re: websearch_to_tsquery() returns queries that don't match to_tsvector()

Browse pgsql-hackers by date

  From Date Subject
Next Message Alexander Korotkov 2021-05-02 18:12:44 Re: websearch_to_tsquery() returns queries that don't match to_tsvector()
Previous Message Zhihong Yu 2021-05-02 18:09:49 Re: websearch_to_tsquery() returns queries that don't match to_tsvector()