BUG #18479: websearch_to_tsquery inconsistent behavior for german when using parentheses
The Post Office <noreply@postgresql.org>
From: PG Bug reporting form <noreply@postgresql.org>
To: pgsql-bugs@lists.postgresql.org
Cc: esemmano@gmail.com
Date: 2024-05-24T07:02:28Z
Lists: 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
Commits
-
Fix parsing of ignored operators in websearch_to_tsquery().
- df95c1ec0e98 15.8 landed
- 56a8296212b6 17.0 landed
- 086ecd12bc1c 16.4 landed
- c7de5a654567 13.16 landed
- 5e63a6f43415 12.20 landed
- 5912bf77c526 14.13 landed