X-Original-To: pgsql-general-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 92CED3A538A; Tue, 30 Nov 2004 06:49:33 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 77094-02; Tue, 30 Nov 2004 06:49:28 +0000 (GMT) Received: from omta16.mta.everyone.net (sitemail2.everyone.net [216.200.145.36]) by svr1.postgresql.org (Postfix) with ESMTP id 8D0373A5389; Tue, 30 Nov 2004 06:49:28 +0000 (GMT) Received: from pmta02.mta.everyone.net (unknown [216.200.145.26]) by omta16.mta.everyone.net (Postfix) with ESMTP id 609843FC5C; Mon, 29 Nov 2004 22:49:27 -0800 (PST) X-Eon-Sig: AQG5s3xBrBf3e4KYeAIAAAAD,0a91875605bcfbf100900cf8ff95bf1a Received: from [192.168.1.5] (68.6.40.210 [68.6.40.210]) by pmta02.mta.everyone.net (EON-AUTHRELAY) with ESMTP id ECD4807B; Mon, 29 Nov 2004 22:49:27 -0800 User-Agent: Microsoft-Entourage/11.1.0.040913 Date: Mon, 29 Nov 2004 22:49:23 -0800 Subject: Re: [JDBC] Invalid Character Data Problem From: Hunter Hillegas To: Kris Jurka Cc: PostgreSQL , Postgre JDBC List Message-ID: In-Reply-To: Mime-version: 1.0 Content-type: text/plain; charset="US-ASCII" Content-transfer-encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=2.2 tagged_above=0.0 required=5.0 tests=RCVD_IN_BL_SPAMCOP_NET X-Spam-Level: ** X-Archive-Number: 200411/1476 X-Sequence-Number: 69556 I got this going with a dump/reload. Beware however, 8.0b5 and the JDBC driver don't seem to work with UNICODE encoding for the database. You have to use b4 or HEAD. Hunter > From: Kris Jurka > Date: Tue, 30 Nov 2004 01:34:46 -0500 (EST) > To: Hunter Hillegas > Cc: PostgreSQL , Postgre JDBC List > > Subject: Re: [JDBC] Invalid Character Data Problem > > > > On Fri, 26 Nov 2004, Hunter Hillegas wrote: > >> When I SELECT from a certain table, I see this JDBC exception: >> >> "Invalid character data was found. This is most likely caused by stored >> data containing characters that are invalid for the character set the >> database was created in. The most common example of this is storing 8bit >> data in a SQL_ASCII database." >> >> The database is indeed of type SQL_ASCII. The table stores mailing list data >> and has about 400,000 rows. >> >> Looking at the data via psql, I see that some of the rows have strange >> characters in them, such as question marks where I would not expect them, >> etc... >> >> What are my options? Is there a way to identify the 'bad' records, or the >> ones causing trouble? >> > > To really solve this problem you need to have a correctly encoded > database. This will involve a dump and restore process and possibly > recoding your data. This is straightforward if you know what > encoding your data is, although it will cause some downtime. > > To detect the bad data you can try various SELECTs with the JDBC driver > and see what errors out. The function below will determine if a > particular field has data with the high bit set which is something the > database really doesn't know what to do with. > > SELECT pkcolumn, hashighbit(columna), hashighbit(columnb) FROM mytable; > > Kris Jurka > > CREATE OR REPLACE FUNCTION hashighbit(text) RETURNS boolean AS ' > DECLARE > i int; > BEGIN > i := LENGTH($1); > WHILE i > 0 LOOP > IF ascii(substring($1, i, 1)) >= 128 THEN > RETURN true; > END IF; > i := i-1; > END LOOP; > RETURN false; > END; > ' LANGUAGE 'plpgsql'; > > > ---------------------------(end of broadcast)--------------------------- > TIP 6: Have you searched our list archives? > > http://archives.postgresql.org