Generate unicode_limits.h.
authorJeff Davis <jdavis@postgresql.org>
Fri, 17 Jul 2026 23:41:14 +0000 (16:41 -0700)
committerJeff Davis <jdavis@postgresql.org>
Fri, 17 Jul 2026 23:41:14 +0000 (16:41 -0700)
commit2cf212db5286baa7d7e80449300fe472d8c4ba9f
tree87a4ef6f1286c4e15e2560c1b17dac3ec292210d
parentf5dfd52553d3b041e30e9b1f1c6eb9f7af55fbdb
Generate unicode_limits.h.

To ensure we do not overflow a size_t while case mapping on a 32-bit
platform, we need to know the maximum amount a UTF8 string can expand.

Calculate that maximum while generating unicode tables as a part of
the update-unicode target, and output into a new header
unicode_limits.h. Minor refactoring along the way.

Add a StaticAssertDecl to check that a MaxAllocSize text value
expanded by that amount would still have a length that fits in
size_t. (We couldn't actually create a new text value out of that, but
we still need to avoid overflow.)

Reported-by: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: https://postgr.es/m/3213927.1783950167@sss.pgh.pa.us
src/backend/utils/adt/pg_locale_builtin.c
src/common/unicode/Makefile
src/common/unicode/generate-unicode_case_table.pl
src/common/unicode/meson.build
src/common/unicode_case.c
src/include/common/unicode_case_table.h
src/include/common/unicode_limits.h [new file with mode: 0644]