Subject: small cleanup patches for collation code

From: Jeff Davis <[email-masked]>
Date: Fri, 17 Apr 2026 12:30:37 -0700

Two patches attached.

0001 fixes a style issue. Backport because it eliminates a warning in
the 'update-unicode' target.

0002 looks like a bug, but is not a real issue because there are no
callers that pass srclen==-1, aside from a test (which fails to fail).
So it's just cleanup, but it seems worth backporting.

Regards,
	Jeff Davis

From 4673d8c7a31b24970e6371c4f2fb3a5e099409dc Mon Sep 17 00:00:00 2001
From: Jeff Davis <[email-masked]>
Date: Thu, 16 Apr 2026 16:30:06 -0700
Subject: [PATCH v1 1/2] style: define parameterless functions as foo(void).

Avoids warning in 'update-unicode' build target. Similar to
11171fe1fc.

Backpatch-through: 17
---
 src/common/unicode/case_test.c     | 2 +-
 src/common/unicode/category_test.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/common/unicode/case_test.c b/src/common/unicode/case_test.c
index fb159c1c27c..e34f700d9c4 100644
--- a/src/common/unicode/case_test.c
+++ b/src/common/unicode/case_test.c
@@ -329,7 +329,7 @@ tfunc_fold(char *dst, size_t dstsize, const char *src,
 }
 
 static void
-test_convert_case()
+test_convert_case(void)
 {
 	/* test string with no case changes */
 	test_convert(tfunc_lower, "√∞", "√∞");
diff --git a/src/common/unicode/category_test.c b/src/common/unicode/category_test.c
index 2b422001209..ffb9d42d704 100644
--- a/src/common/unicode/category_test.c
+++ b/src/common/unicode/category_test.c
@@ -54,7 +54,7 @@ parse_unicode_version(const char *version)
  * White_Space, and Hex_Digit.
  */
 static void
-icu_test()
+icu_test(void)
 {
 	int			successful = 0;
 	int			pg_skipped_codepoints = 0;
-- 
2.43.0

From b104c64e5572b04622c11883d2a82e579d134944 Mon Sep 17 00:00:00 2001
From: Jeff Davis <[email-masked]>
Date: Thu, 16 Apr 2026 16:20:02 -0700
Subject: [PATCH v1 2/2] Fix callers of unicode_strtitle() using srclen == -1.

Currently, only called that way in tests, which failed to fail.

Backpatch-through: 18
---
 src/backend/utils/adt/pg_locale_builtin.c | 2 +-
 src/common/unicode/case_test.c            | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/backend/utils/adt/pg_locale_builtin.c b/src/backend/utils/adt/pg_locale_builtin.c
index b5aeb7a337a..794aa37df76 100644
--- a/src/backend/utils/adt/pg_locale_builtin.c
+++ b/src/backend/utils/adt/pg_locale_builtin.c
@@ -97,7 +97,7 @@ strtitle_builtin(char *dest, size_t destsize, const char *src, ssize_t srclen,
 {
 	struct WordBoundaryState wbstate = {
 		.str = src,
-		.len = srclen,
+		.len = (srclen < 0) ? strlen(src) : srclen,
 		.offset = 0,
 		.posix = !locale->builtin.casemap_full,
 		.init = false,
diff --git a/src/common/unicode/case_test.c b/src/common/unicode/case_test.c
index e34f700d9c4..099530c1ead 100644
--- a/src/common/unicode/case_test.c
+++ b/src/common/unicode/case_test.c
@@ -304,7 +304,7 @@ tfunc_title(char *dst, size_t dstsize, const char *src,
 {
 	struct WordBoundaryState wbstate = {
 		.str = src,
-		.len = srclen,
+		.len = (srclen < 0) ? strlen(src) : srclen,
 		.offset = 0,
 		.init = false,
 		.prev_alnum = false,
-- 
2.43.0

---

From: Peter Eisentraut <[email-masked]>
Date: Sat, 25 Apr 2026 08:12:07 +0200

> the 'update-unicode' target.

These warning options were only added in PG19, so backpatching is not 
necessary.

> So it's just cleanup, but it seems worth backporting.

That looks right.