Handle MAXSTRLEN consistently
Hello!
Commit 23d9ad77181 added additional length checks for tsvector, but it
is inconsistent at one place: most checks use toklen > MAXSTRLEN as
the error condition, but array_to_tsvector uses >=. This causes a
strange corner-case issue: we can convert a 2047 length lexeme to an
array, as tsvector_to_array allows it, but we can't convert it back
with array_to_tsvector as it errors out.
0001 is a fix for this specific case.
After looking into this further, I realized that the length handling
is also inconsistent at other places, even before the mentioned
commit.
0002 addresses the other preexisting places that used >= for errors instead of >
Attachments:
t253393_10001-Allow-maximum-length-lexemes-in-array_to_tsvector-ag.patchapplication/octet-stream; name=0001-Allow-maximum-length-lexemes-in-array_to_tsvector-ag.patchDownload+14-3
0002-Accept-maximum-length-lexemes-in-all-text-search-inp.patchapplication/octet-stream; name=0002-Accept-maximum-length-lexemes-in-all-text-search-inp.patchDownload+60-7
Zsolt Parragi <zsolt.parragi@percona.com> writes:
Commit 23d9ad77181 added additional length checks for tsvector, but it
is inconsistent at one place: most checks use toklen > MAXSTRLEN as
the error condition, but array_to_tsvector uses >=. This causes a
strange corner-case issue: we can convert a 2047 length lexeme to an
array, as tsvector_to_array allows it, but we can't convert it back
with array_to_tsvector as it errors out.
0001 is a fix for this specific case.
After looking into this further, I realized that the length handling
is also inconsistent at other places, even before the mentioned
commit.
Yeah. I noticed this inconsistency while preparing 23d9ad771,
but felt that fixing it was out of scope for a security patch.
There's a similar problem with inconsistent enforcement of
MAXSTRPOS. Attached is what I had staged to propose post-release.
regards, tom lane
On Wed, 12 Aug 2026, Tom Lane <tgl@sss.pgh.pa.us> wrote:
Yeah. I noticed this inconsistency while preparing 23d9ad771,
but felt that fixing it was out of scope for a security patch.
There's a similar problem with inconsistent enforcement of
MAXSTRPOS. Attached is what I had staged to propose post-release.
Yeah, I missed that MAXSTRPOS case but it is also valid, otherwise the changes look identical.
Zsolt Parragi <zsolt.parragi@percona.com> writes:
On Wed, 12 Aug 2026, Tom Lane <tgl@sss.pgh.pa.us> wrote:
Yeah. I noticed this inconsistency while preparing 23d9ad771,
but felt that fixing it was out of scope for a security patch.
There's a similar problem with inconsistent enforcement of
MAXSTRPOS. Attached is what I had staged to propose post-release.
Yeah, I missed that MAXSTRPOS case but it is also valid, otherwise the
changes look identical.
Pushed, thanks for the cross-check.
regards, tom lane