Re: BUG #15476: Problem on show_trgm with 4 byte UTF-8 characters
Tom Lane <tgl@sss.pgh.pa.us>
From: Tom Lane <tgl@sss.pgh.pa.us>
To: h8mastre@gmail.com
Cc: pgsql-bugs@lists.postgresql.org
Date: 2018-11-03T04:44:30Z
Lists: pgsql-bugs
=?utf-8?q?PG_Bug_reporting_form?= <noreply@postgresql.org> writes:
> On Encoding=UTF-8 database, try:
> SELECT show_trgm('123');
> → OK
> SELECT show_trgm('日本語');
> → probably OK.
> SELECT show_trgm('🔍');
> ERROR: invalid multibyte character for locale
> HINT: The server's LC_CTYPE locale is probably incompatible with the
> database encoding.
> SQL state: 22021
I failed to reproduce this on a Linux machine. It looks to me like the
problem is that Windows' MultiByteToWideChar doesn't think that UTF8
character is valid.
> Please check: t_isdigit, t_isspace, t_isalpha, and t_isprint.
> https://github.com/postgres/postgres/blob/322548a8abe225f2cfd6a48e07b99e2711d28ef7/src/backend/tsearch/ts_locale.c#L35
> char2wchar 4th parameter should take number of input bytes. However they
> pass character count.
> int clen = pg_mblen(ptr);
> ...
> char2wchar(character, 2, ptr, clen, mylocale);
Huh? pg_mblen returns the number of bytes in a multibyte character,
so this looks fine to me.
regards, tom lane
Commits
-
Make ts_locale.c's character-type functions cope with UTF-16.
- f7ba6e951a12 10.6 landed
- bf4a9562e8b9 11.1 landed
- 981dc2baa8e0 12.0 landed
- 73dbaed93b46 9.6.11 landed
- 6e6092989fbb 9.5.15 landed
- 33c697e9d4a0 9.3.25 landed
- 0ae902e39ed8 9.4.20 landed
-
Update obsolete comments
- 322548a8abe2 11.0 cited