Received: from localhost (unknown [200.46.204.183]) by postgresql.org (Postfix) with ESMTP id 2987464FCD8 for ; Fri, 19 Sep 2008 10:37:13 -0300 (ADT) Received: from postgresql.org ([200.46.204.86]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 37689-09 for ; Fri, 19 Sep 2008 10:37:06 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from rv-out-0506.google.com (rv-out-0506.google.com [209.85.198.233]) by postgresql.org (Postfix) with ESMTP id 530E364FCC2 for ; Fri, 19 Sep 2008 10:37:06 -0300 (ADT) Received: by rv-out-0506.google.com with SMTP id b25so385826rvf.43 for ; Fri, 19 Sep 2008 06:37:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to :subject:in-reply-to:mime-version:content-type :content-transfer-encoding:content-disposition:references; bh=+rFjEcRsppJwbE68LWAsWGKrP9fLNJiZkXIjkveulTE=; b=iotSzgCiU0GscvdDtZO8sov+3d7zWHYkGdeu4gQBosbP1vbwp/D0VXsY8aiy6nm5cS 7pd5ZmQkjtCRkH6cigml4T/+69W7+zOLsUGk3ZnsMKI6y12vDO4foBwQlfy+tVqFcrSS 4089oADKQ37J3USaujW/etf4mveADdQomXvQ4= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:in-reply-to:mime-version :content-type:content-transfer-encoding:content-disposition :references; b=DJXyMRnp7ckiK90FXdnk2nAop0G2bTlVCENB+8xr5+PZcEEj/OYmLhd/n512Vo+aH+ jj4MgxDgy5qbGN3Abw+NtDP+HeeU/KsKRy8ZBEp+bVrfr+uNJdvGUuh7yKBB3q7tZeat 91uLL+IteJgSB8Pd9+1KDrFhofTlLllC0J+04= Received: by 10.141.212.5 with SMTP id o5mr53147rvq.20.1221831423598; Fri, 19 Sep 2008 06:37:03 -0700 (PDT) Received: by 10.140.131.10 with HTTP; Fri, 19 Sep 2008 06:37:03 -0700 (PDT) Message-ID: <57a815bf0809190637h49abd565x108ce52bc92a9d0a@mail.gmail.com> Date: Fri, 19 Sep 2008 23:37:03 +1000 From: "Mikel Lindsaar" To: "Tore Halset" , pgsql-admin@postgresql.org Subject: Re: unable to restore 8.2.5 In-Reply-To: <35E76852-E52D-4BE7-9931-7B1AE6805248@pvv.ntnu.no> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <35E76852-E52D-4BE7-9931-7B1AE6805248@pvv.ntnu.no> X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests=none X-Spam-Level: X-Archive-Number: 200809/214 X-Sequence-Number: 30307 On Fri, Sep 19, 2008 at 6:29 PM, Tore Halset wrote: > Looks like I have managed to insert an illegal character into the main > system that does not conform to UTF-8. Anything I can and should do to work > around this issue? I have had the same problem previously and after a lot of help from Tom Lane basically came up to the following... You need to basically dump your table out (or a subset containing the row ID and column that would have the bad data) in plain text and then parse it with a script to detect invalid UTF-8 sequences, then find what rows the bad data is in and go and fix it. It is either that or you drop the data inserting some other character. But this has obvious drawbacks. I wrote a short ruby script that goes through a dumped file line by line and puts each line through Iconv to parse it from UTF-8 to UTF-8, if it fails it dumps the offending line to a log file. A ruby script that would just print the offending row would go something like this: require 'iconv' File.read(ARGV[0]).each do |line| begin Iconv.iconv('UTF-8', 'UTF-8', line) rescue puts "Failed: #{line}" end end Save that in a file (find_invalid_utf8.rb) then run it with: $ ruby find_invalid_utf8.rb my_dumped_table.csv It's not pretty, and just dumps the raw output to the screen, but it might do for you. -- http://lindsaar.net/ Rails, RSpec and Life blog....