Re: PQclientEncoding() returns -1, resulting in possible assertion failure in psql

From: Bruce Momjian <bruce(at)momjian(dot)us>
To: Tatsuo Ishii <ishii(at)postgresql(dot)org>
Cc: tgl(at)sss(dot)pgh(dot)pa(dot)us, pg(at)heroku(dot)com, pgsql-bugs(at)postgresql(dot)org
Subject: Re: PQclientEncoding() returns -1, resulting in possible assertion failure in psql
Date: 2014-03-22 15:55:05
Message-ID: 20140322155505.GA17107@momjian.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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(at)momjian(dot)us> http://momjian.us
EnterpriseDB http://enterprisedb.com

+ Everyone has their own god. +

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Tom Lane 2014-03-22 15:55:56 Re: PQclientEncoding() returns -1, resulting in possible assertion failure in psql
Previous Message Bruce Momjian 2014-03-22 15:17:23 Re: PQclientEncoding() returns -1, resulting in possible assertion failure in psql