Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1WFu92-0007kD-Ra for pgsql-hackers@arkaria.postgresql.org; Tue, 18 Feb 2014 23:32:09 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1WFu92-0004Jw-B5 for pgsql-hackers@arkaria.postgresql.org; Tue, 18 Feb 2014 23:32:08 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1WFu90-0004Ji-Tl; Tue, 18 Feb 2014 23:32:06 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1WFu8y-0005yq-8s; Tue, 18 Feb 2014 23:32:06 +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 s1INVucY014274; Tue, 18 Feb 2014 18:31:56 -0500 From: Tom Lane To: pgsql-bugs@postgresql.org, pgsql-hackers@postgresql.org cc: digoal@126.com Subject: Re: [BUGS] BUG #9210: PostgreSQL string store bug? not enforce check with correct characterSET/encoding In-reply-to: <12131.1392760137@sss.pgh.pa.us> References: <20140213140759.2710.49877@wrigleys.postgresql.org> <20127.1392324548@sss.pgh.pa.us> <12131.1392760137@sss.pgh.pa.us> Comments: In-reply-to Tom Lane message dated "Tue, 18 Feb 2014 16:48:57 -0500" Date: Tue, 18 Feb 2014 18:31:56 -0500 Message-ID: <14273.1392766316@sss.pgh.pa.us> X-Pg-Spam-Score: -2.5 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-hackers Precedence: bulk Sender: pgsql-hackers-owner@postgresql.org I wrote: > I looked through all the callers of pg_do_encoding_conversion(), and > AFAICS this change is a good idea. There are a whole bunch of places > that use pg_do_encoding_conversion() to convert from the database encoding > to encoding X (most usually UTF8), and right now if you do that in a > SQL_ASCII database you have no assurance whatever that what is produced > is actually valid in encoding X. I think we need to close that loophole. BTW, a second look confirms that all but one or two of the callers of pg_do_encoding_conversion() are in fact converting either to or from the database encoding. That probably means they ought to be using pg_any_to_server or pg_server_to_any instead, so that they can take advantage of the pre-cached default conversion in the not-unlikely situation that the other encoding is the current client_encoding. This would imply that we ought to put a validate-if-source-is-SQL_ASCII step into pg_server_to_any() as well, since that function currently short-circuits calling pg_do_encoding_conversion() in that case. regards, tom lane -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers