On Sat, Mar 22, 2014 at 11:17:23AM -0400, Bruce Momjian wrote:
> OK, hearing nothing, I dug into this, and I think the solution is
> simpler than we thought. Basically, the Assert is checking for the
> encoding value to be in a valid range, but the main code is also
> checking for an invalid encoding and returning PG_SQL_ASCII:
>
> pg_encoding_mblen(int encoding, const char *mbstr)
> {
> Assert(PG_VALID_ENCODING(encoding));
>
> return ((encoding >= 0 &&
> encoding < sizeof(pg_wchar_table) / sizeof(pg_wchar_tbl)) ?
> ((*pg_wchar_table[encoding].mblen) ((const unsigned char *) mbstr)) :
> ((*pg_wchar_table[PG_SQL_ASCII].mblen) ((const unsigned char *) mbstr)));
> }
Also, what is the difference between _PG_LAST_ENCODING_, which is the
last encoding enum, and the pg_wchar_tbl length calculation? Are they
the same? If so, we should just use _PG_LAST_ENCODING_.
--
Bruce Momjian <bruce@momjian.us> http://momjian.us
EnterpriseDB http://enterprisedb.com
+ Everyone has their own god. +