Re: Rethinking the implementation of ts_headline()
Tom Lane <tgl@sss.pgh.pa.us>
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Alexander Lakhin <exclusion@gmail.com>
Cc: Alvaro Herrera <alvherre@alvh.no-ip.org>,
pgsql-hackers@lists.postgresql.org, sebastian.patino-lang@posteo.net
Date: 2023-04-06T19:55:58Z
Lists: pgsql-hackers
Alexander Lakhin <exclusion@gmail.com> writes:
> I've found that starting from commit 5a617d75 this query:
> SELECT ts_headline('english', 'To be, or not to be', to_tsquery('english', 'or'));
> invokes a valgrind-detected error:
> ==00:00:00:03.950 3241424== Invalid read of size 1
On my machine, I also see PG-reported errors such as "unrecognized
operator: 0". It's a live bug all right. We need to be more careful
about empty tsqueries.
> But the less-verbose call:
> SELECT ts_headline('', '');
> discovers a different error even on 5a617d75~1:
> ==00:00:00:04.113 3139158== Conditional jump or move depends on uninitialised value(s)
> ==00:00:00:04.113 3139158== at 0x77B44F: mark_fragment (wparser_def.c:2100)
Yeah, this one seems to be ancient sloppiness. I don't think it has
any bad effect beyond annoying valgrind, but I fixed it anyway.
Thanks for the report!
regards, tom lane
Commits
-
Fix ts_headline() edge cases for empty query and empty search text.
- 029dea882a7a 16.0 landed
- f976a77787eb 15.3 landed
- bc428b12ac3a 11.20 landed
- b7d6c51d4693 13.11 landed
- a1fb4bd8562e 12.15 landed
- 34ad3aedb0ce 14.8 landed
-
Fix ts_headline() to handle ORs and phrase queries more honestly.
- 5a617d75d3b3 16.0 landed
-
Fix default text search parser's ts_headline code for phrase queries.
- c9b0c678d30a 13.0 cited