Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1WE3Dy-0002i2-LS for pgsql-bugs@arkaria.postgresql.org; Thu, 13 Feb 2014 20:49:34 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1WE3Dy-0004F4-2e for pgsql-bugs@arkaria.postgresql.org; Thu, 13 Feb 2014 20:49:34 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1WE3Dx-0004Eu-GB; Thu, 13 Feb 2014 20:49:33 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1WE3De-0000sw-8N; Thu, 13 Feb 2014 20:49:33 +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 s1DKn8pe020128; Thu, 13 Feb 2014 15:49:08 -0500 From: Tom Lane To: digoal@126.com cc: pgsql-bugs@postgresql.org, pgsql-hackers@postgresql.org Subject: Re: BUG #9210: PostgreSQL string store bug? not enforce check with correct characterSET/encoding In-reply-to: <20140213140759.2710.49877@wrigleys.postgresql.org> References: <20140213140759.2710.49877@wrigleys.postgresql.org> Comments: In-reply-to digoal@126.com message dated "Thu, 13 Feb 2014 14:07:59 +0000" Date: Thu, 13 Feb 2014 15:49:08 -0500 Message-ID: <20127.1392324548@sss.pgh.pa.us> X-Pg-Spam-Score: -2.6 (--) 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 digoal@126.com writes: > select t, t::bytea from convert_from('\xeec1', 'sql_ascii') as g(t); > [ fails to check that string is valid in database encoding ] Hm, yeah. Normal input to the database goes through pg_any_to_server(), which will apply a validation step if the source encoding is SQL_ASCII and the destination encoding is something else. However, pg_convert and some other places call pg_do_encoding_conversion() directly, and that function will just quietly do nothing if either encoding is SQL_ASCII. The minimum-refactoring solution to this would be to tweak pg_do_encoding_conversion() so that if the src_encoding is SQL_ASCII but the dest_encoding isn't, it does pg_verify_mbstr() rather than nothing. I'm not sure if this would break anything we need to have work, though. Thoughts? Do we want to back-patch such a change? 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