On 2019-Dec-07, Tom Lane wrote: > 0001:
> It is a very bad idea that this is truncating text without regard to > multibyte character boundaries. Hmm. So it turns out that we recently made stringinfo.c exported to frontends in libpgcommon. Clipping strings at a given character size means we need some facility like pg_encoding_mbcliplen. However, 1) pgcommon does not have wchar.c (libpq does have it), and 2) mbcliplen is not in wchar.c anyway. I see four possible ways forward, with nuances. In order of preference: 1. change enough of the build system so that pg_encoding_mbcliplen is available. (Offhand I see no reason why we couldn't move the function from mbutils.c to wchar.c, but I haven't tried.) 2. in frontend, ignore the specified length; always copy the whole string. 3. don't allow length clipping in frontend. (We have no use for it in the near future.) 3a. Throw a run-time error if it's requested. 3b. throw a compile-time error if requested 4. don't provide this new function #if FRONTEND -- Álvaro Herrera https://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services