Re: Refactor: allow pg_strncoll(), etc., to accept -1 length for NUL-terminated cstrings.
Jeff Davis <pgsql@j-davis.com>
From: Jeff Davis <pgsql@j-davis.com>
To: Andres Freund <andres@anarazel.de>
Cc: pgsql-hackers@postgresql.org
Date: 2026-05-05T20:23:12Z
Lists: pgsql-hackers
Attachments
- v1-0001-Don-t-accept-length-of-1-in-pg_locale.h-APIs.patch (text/x-patch)
On Fri, 2026-05-01 at 12:40 -0400, Andres Freund wrote: > Hi, > > On 2024-08-22 11:00:54 -0700, Jeff Davis wrote: > > Like ICU, allow -1 length to mean that the input string is NUL- > > terminated for pg_strncoll(), pg_strnxfrm(), and > > pg_strnxfrm_prefix(). > > > > This simplifies the API and code a bit. > > I don't really like this. Agreed. I did this to match up with the ICU API a bit better, but if it's interfering with useful tools, then the special cases aren't worth it. Patch attached. It causes a bit of churn, so one disadvantage is that it will complicate future backports in this area. Regards, Jeff Davis