Received: from makus.postgresql.org (makus.postgresql.org [98.129.198.125]) by mail.postgresql.org (Postfix) with ESMTP id C1C1662698A for ; Mon, 16 Apr 2012 05:52:21 -0300 (ADT) Received: from mail-pz0-f46.google.com ([209.85.210.46]) by makus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1SJhfY-0000Z0-LG for pgsql-admin@postgresql.org; Mon, 16 Apr 2012 08:52:21 +0000 Received: by dadz9 with SMTP id z9so7636056dad.33 for ; Mon, 16 Apr 2012 01:52:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:subject:references :in-reply-to:content-type:content-transfer-encoding; bh=EAdWL3+26jIop5zPTkPbJDGVjuSO7kpWx6W1DZyQJMg=; b=bj1Y81tO4PpO/rRHPkLFwn1OJoM/ah+O/MF85JN1JI70umAOOPY98iC+rmCk2rb4jo q2dRLCYT++tMQTT5EToa47beSFlIEQayy3oypeRGq9ndtX5gtU3aFSbY0VPnHN5S7xWa 1qJkLXO6LxVG++a4ra/OV+qa6MbukvV+75u6Vq9QGa6zO2/4ds5tjAtfvwR/BSd76dL7 A4boqAgZy826K1Usm1qOreKQlsTP0WPlyXXiK6KPkQFgEY7jYlCby0MwmSznJymWYbB/ tiGITJubiPyF1MOSbDw6TSbQyiaCArUlkMs2ucQs/1zJMkaSlbkL8tt6fopgATzqnpvF 18Pg== Received: by 10.68.221.136 with SMTP id qe8mr26795840pbc.108.1334566327731; Mon, 16 Apr 2012 01:52:07 -0700 (PDT) Received: from [192.168.1.47] ([116.226.37.234]) by mx.google.com with ESMTPS id oh2sm10551788pbb.45.2012.04.16.01.52.04 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 16 Apr 2012 01:52:06 -0700 (PDT) Message-ID: <4F8BDDB2.9020801@gmail.com> Date: Mon, 16 Apr 2012 16:52:02 +0800 From: Rural Hunter User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:11.0) Gecko/20120327 Thunderbird/11.0.1 MIME-Version: 1.0 To: "pgsql-admin@postgresql.org" Subject: Re: invalid byte sequence for encoding "UTF8": 0xf481 - how could this happen? References: <4F88DB40.9070609@gmail.com> In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Pg-Spam-Score: -2.6 (--) X-Archive-Number: 201204/81 X-Sequence-Number: 39417 =>SELECT convert_to(content, 'UTF8') FROM tmp_article; This works. My pg is at latest 9.1.3 on ubuntu 10.04 server. We have millions of data in the db but this is the only one we met the problem. The bad data is inserted in recent days and we upgraded to 9.1.3 right after it was released. 于 2012/4/16 16:31, Albe Laurenz 写道: > Rural Hunter wrote: >> My db is in utf-8, I have a row in my table say tmp_article and I > wanted >> to generate ts_vector from the article content: >> select to_tsvector(content) from tmp_article; >> But I got this error: >> ERROR: invalid byte sequence for encoding "UTF8": 0xf481 >> >> I am wondering how this could happen. I think if there was invalid > UTF8 >> bytes in the content, it shouldn't have been able to inserted into the >> tmp_article table as I sometimes see similar errors when inserting >> records to tmp_article. Am I right? > You are right in theory. A lot depends on your PostgreSQL version, > because > the efforts to prevent invalid strings from entering the database have > led to changes over the versions. Older versions are more permissive. > > To test the theory that the contents of the table are bad, you can > test if the same happens if you > > SELECT convert_to(content, 'UTF8') FROM tmp_article; > > Yours, > Laurenz Albe >