Re: PQclientEncoding() returns -1, resulting in possible assertion failure in psql - Mailing list pgsql-bugs

From Bruce Momjian
Subject Re: PQclientEncoding() returns -1, resulting in possible assertion failure in psql
Date
Msg-id 20140322155505.GA17107@momjian.us
Whole thread Raw
In response to Re: PQclientEncoding() returns -1, resulting in possible assertion failure in psql  (Bruce Momjian <bruce@momjian.us>)
Responses Re: PQclientEncoding() returns -1, resulting in possible assertion failure in psql
List pgsql-bugs
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. +

pgsql-bugs by date:

Previous
From: Bruce Momjian
Date:
Subject: Re: PQclientEncoding() returns -1, resulting in possible assertion failure in psql
Next
From: Tom Lane
Date:
Subject: Re: PQclientEncoding() returns -1, resulting in possible assertion failure in psql