Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1WROGO-0008Fq-BO for pgsql-bugs@arkaria.postgresql.org; Sat, 22 Mar 2014 15:55:12 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1WROGN-0003rP-QG for pgsql-bugs@arkaria.postgresql.org; Sat, 22 Mar 2014 15:55:11 +0000 Received: from makus.postgresql.org ([2001:4800:7903:4::125]) by malur.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1WROGL-0003ob-Tr for pgsql-bugs@postgresql.org; Sat, 22 Mar 2014 15:55:10 +0000 Received: from momjian.us ([72.94.173.45]) by makus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1WROGJ-0008Ly-19; Sat, 22 Mar 2014 15:55:09 +0000 Received: from bruce by momjian.us with local (Exim 4.72) (envelope-from ) id 1WROGH-0004VH-NT; Sat, 22 Mar 2014 11:55:05 -0400 Date: Sat, 22 Mar 2014 11:55:05 -0400 From: Bruce Momjian To: Tatsuo Ishii Cc: tgl@sss.pgh.pa.us, pg@heroku.com, pgsql-bugs@postgresql.org Subject: Re: PQclientEncoding() returns -1, resulting in possible assertion failure in psql Message-ID: <20140322155505.GA17107@momjian.us> References: <14465.1386526658@sss.pgh.pa.us> <15210.1386529004@sss.pgh.pa.us> <20131209.081735.1321847791044178990.t-ishii@sraoss.co.jp> <20140322015325.GA21843@momjian.us> <20140322151723.GB21843@momjian.us> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20140322151723.GB21843@momjian.us> User-Agent: Mutt/1.5.20 (2009-06-14) X-Pg-Spam-Score: -1.9 (-) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org 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 http://momjian.us EnterpriseDB http://enterprisedb.com + Everyone has their own god. + -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs