Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1VpivJ-0006OA-8o for pgsql-bugs@arkaria.postgresql.org; Sun, 08 Dec 2013 18:17:45 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1VpivI-0001TW-Ke for pgsql-bugs@arkaria.postgresql.org; Sun, 08 Dec 2013 18:17:44 +0000 Received: from makus.postgresql.org ([2001:4800:7903:4::125]) by malur.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1VpivH-0001SR-Gt for pgsql-bugs@postgresql.org; Sun, 08 Dec 2013 18:17:43 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1VpivF-00044c-0S for pgsql-bugs@postgresql.org; Sun, 08 Dec 2013 18:17:42 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id rB8IHcNC014466; Sun, 8 Dec 2013 13:17:38 -0500 From: Tom Lane To: Peter Geoghegan cc: pgsql-bugs@postgresql.org Subject: Re: PQclientEncoding() returns -1, resulting in possible assertion failure in psql In-reply-to: References: Comments: In-reply-to Peter Geoghegan message dated "Sun, 08 Dec 2013 01:21:46 -0800" Date: Sun, 08 Dec 2013 13:17:38 -0500 Message-ID: <14465.1386526658@sss.pgh.pa.us> X-Pg-Spam-Score: -2.0 (--) 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 Peter Geoghegan writes: > It's possible to get psql to abort() in an assertion failure from > legitimate input. If the server is shutdown, and PQclientEncoding() > returns -1, that value can be passed to a site that expects a valid > encoding. > If the call to PQclientEncoding() from processSQLNamePattern() (plus > probably from other places) gets an encoding of -1, (called when we > "\df+ somefunc" after the server is gone - you may have to do it > twice), that can be passed down to PQmblen(), which will in turn pass > that value to pg_encoding_mblen(), which doesn't expect it. A simple fix might be to return SQL_ASCII not -1. I don't think the -1 behavior is documented or relied on anywhere, is it? Otherwise, we could check for live connection somewhere much earlier in the processing of \d and friends. But it might be difficult to find a single choke point for doing that, rendering the reliability of the fix somewhat suspect. regards, tom lane -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs