Handle MAXSTRLEN consistently

From: Zsolt Parragi <zsolt(dot)parragi(at)percona(dot)com>
To: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Handle MAXSTRLEN consistently
Date: 2026-08-12 15:27:47
Message-ID: CAN4CZFNYQo4zfbRR435uD0vSfuy5y7dnFOXDfKr9zYoL1JnAxA@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

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 >

Attachment Content-Type Size
0001-Allow-maximum-length-lexemes-in-array_to_tsvector-ag.patch application/octet-stream 3.4 KB
0002-Accept-maximum-length-lexemes-in-all-text-search-inp.patch application/octet-stream 9.1 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Jacob Champion 2026-08-12 15:34:14 Re: LibreSSL and OpenSSL separation in libpq to support 1.1.1 deprecation
Previous Message Daniel Gustafsson 2026-08-12 15:14:17 Re: LibreSSL and OpenSSL separation in libpq to support 1.1.1 deprecation