BUG #18479: websearch_to_tsquery inconsistent behavior for german when using parentheses - Mailing list pgsql-bugs

From PG Bug reporting form
Subject BUG #18479: websearch_to_tsquery inconsistent behavior for german when using parentheses
Date
Msg-id 18479-d9b46e2fc242c33e@postgresql.org
Whole thread Raw
Responses Re: BUG #18479: websearch_to_tsquery inconsistent behavior for german when using parentheses
List pgsql-bugs
The following bug has been logged on the website:

Bug reference:      18479
Logged by:          Manos Emmanouilidis
Email address:      esemmano@gmail.com
PostgreSQL version: 15.4
Operating system:   macOS Sonoma 14.4.1 x86
Description:

Although the docs
https://www.postgresql.org/docs/current/textsearch-controls.html say nothing
about websearch_to_tsquery supporting parentheses in queries, I noticed some
inconsistent behaviour when using multiple 'or' keywords with parentheses in
postgres 15.4

In the following tests 1-3 the behaviour matches what I expect, but in the
4th test the 'or' keyword is used verbatim when parentheses are present in
the middle of the query.

select websearch_to_tsquery('german', 'foo or baz bar');
 websearch_to_tsquery
-----------------------
 'foo' | 'baz' & 'bar'

select websearch_to_tsquery('german', 'foo or baz bar or ding dong');
          websearch_to_tsquery
-----------------------------------------
 'foo' | 'baz' & 'bar' | 'ding' & 'dong'

select websearch_to_tsquery('german', 'foo or baz bar or (ding dong)');
          websearch_to_tsquery
-----------------------------------------
 'foo' | 'baz' & 'bar' | 'ding' & 'dong'

select websearch_to_tsquery('german', 'foo or (baz bar) or (ding dong)');
              websearch_to_tsquery
------------------------------------------------
 'foo' | 'baz' & 'bar' & 'or' & 'ding' & 'dong'

I do not mean to say that this is necessarily a bug that needs fixing, but
maybe either the docs should call out that using parens leads to undefined
behaviour, or the function's logic could be updated to be consistent in the
presence of parens - either ignore them completely or always consider them,
but not both depending on the input


pgsql-bugs by date:

Previous
From: PG Bug reporting form
Date:
Subject: BUG #18478: uuid-ossp extension is not installed with PostgreSQL 17 Beta 1
Next
From: Marcin Barczyński
Date:
Subject: Re: BUG #18334: Segfault when running a query with parallel workers