Received: from maia.hub.org (unknown [200.46.204.183]) by mail.postgresql.org (Postfix) with ESMTP id 7472B633DFD for ; Wed, 3 Jun 2009 17:41:21 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 58962-01 for ; Wed, 3 Jun 2009 17:41:20 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from leary.csoft.net (leary.csoft.net [205.205.214.5]) by mail.postgresql.org (Postfix) with ESMTP id 63580633DF5 for ; Wed, 3 Jun 2009 17:41:20 -0300 (ADT) Received: by leary.csoft.net (Postfix, from userid 1112) id 6188FA1B8; Wed, 3 Jun 2009 16:41:19 -0400 (EDT) Date: Wed, 3 Jun 2009 16:41:19 -0400 (EDT) From: Kris Jurka X-X-Sender: books@leary.csoft.net To: user2037@ymail.com cc: pgsql-jdbc@postgresql.org Subject: Re: Strings with null characters produce exceptions when selected or inserted. Attempts to select messages with null bytes produces "ERROR: insufficient data left in message". And inserting produces "ERROR: invalid byte sequence for encoding \"UTF8\": 0x00". Since a null character is a valid UTF code point why is it rejected by the JDBC driver? The attached test can work with Mysql and their JDBC driver. In-Reply-To: <626803.19538.qm@web59808.mail.ac4.yahoo.com> Message-ID: References: <626803.19538.qm@web59808.mail.ac4.yahoo.com> User-Agent: Alpine 2.00 (BSO 1167 2008-08-23) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed 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: 200906/19 X-Sequence-Number: 19683 On Wed, 3 Jun 2009, user2037@ymail.com wrote: > Strings with null characters produce exceptions when selected or > inserted. Attempts to select messages with null bytes produces "ERROR: > insufficient data left in message". And inserting produces "ERROR: > invalid byte sequence for encoding \"UTF8\": 0x00". > > Since a null character is a valid UTF code point why is it rejected by > the JDBC driver? Because the server can't handle it. The server is written in C and tracks all textual data as C strings which are null terminated. It cannot handle intermediate null bytes, so the driver is just providing that message as early as possible to you. Kris Jurka