Received: from maia.hub.org (maia-5.hub.org [200.46.204.29]) by mail.postgresql.org (Postfix) with ESMTP id 87E261337B4E for ; Wed, 24 Nov 2010 02:31:22 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.29]) (amavisd-maia, port 10024) with ESMTP id 19829-04 for ; Wed, 24 Nov 2010 06:31:15 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from mail63.csoft.net (mail63.csoft.net [205.205.214.4]) by mail.postgresql.org (Postfix) with ESMTP id 1CBDA1336B42 for ; Wed, 24 Nov 2010 02:31:15 -0400 (AST) Received: from mail63.csoft.net (localhost [127.0.0.1]) by mail63.csoft.net (Postfix) with ESMTP id 24B312842A; Wed, 24 Nov 2010 01:31:14 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=csoft.net; h=date:from:to :cc:subject:in-reply-to:message-id:references:mime-version :content-type; s=sel1; bh=wbJcl1RWJvDB9K2a3CkFq8o1j2U=; b=rSysuJ xFQ1wJLAXdb1JIt9g7OkLTC6C9oDdiMl8EcLtVN3hXeYpy0V/FmmOjK5ty0kho66 qkX4XYRNfm8iVba3EdPcI+ILSujv5GJBm0JE07+5pCLs6B0dRAz9n9yUJCMoDXky s9Q3hqAiHYmDCKwtSY7+J0/3c+0XD25A0FbgU= Received: from leary.csoft.net (leary.csoft.net [205.205.214.5]) by mail63.csoft.net (Postfix) with ESMTP id DA35B28417; Wed, 24 Nov 2010 01:31:13 -0500 (EST) Received: by leary.csoft.net (Postfix, from userid 1112) id 9C413AB10; Wed, 24 Nov 2010 01:31:13 -0500 (EST) Date: Wed, 24 Nov 2010 01:31:13 -0500 (EST) From: Kris Jurka X-X-Sender: books@leary.csoft.net To: Thomas Kellerer cc: pgsql-jdbc@postgresql.org Subject: Re: bit datatype and getObject() In-Reply-To: Message-ID: References: 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=-1.91 tagged_above=-10 required=5 tests=BAYES_00=-1.9, T_RP_MATCHES_RCVD=-0.01 X-Spam-Level: X-Archive-Number: 201011/78 X-Sequence-Number: 21199 On Tue, 23 Nov 2010, Thomas Kellerer wrote: > the JDBC driver seems to map columns defined as "bit" to Boolean regardless > of the definition of the column. So even a bit(5) is returned as boolean > value which I think is not correct. > > Consider the following > > CREATE TABLE bit_test (some_bits bit(5)); > INSERT INTO bit_test VALUES ('01010'); > > When I run a select in psql it will return 01010 as the column's value. > > When running a select from within Java and using getObject() on that column a > java.lang.Boolean is returned. > > This might be correct for a bit(1) but not for columns defined with a bigger > width. > > I'm not sure what the JDBC specs requires here, but this mapping somehow is > confusing. Yeah, losing data is not good. Previously the discussion on list was to use java.util.BitSet, but it never resulted in a patch. I'm not sure if we can retain backwards compatibility for single bit length bitstrings. So we'd have to determine whether we can maintain compatibility and if not, is it still worth it to use BitSet. Kris Jurka