Received: from maia.hub.org (unknown [200.46.204.183]) by mail.postgresql.org (Postfix) with ESMTP id 2653D634FC8 for ; Tue, 12 May 2009 07:10:08 -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 40260-05 for ; Tue, 12 May 2009 07:10:06 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from mk-filter-1-a-1.mail.uk.tiscali.com (mk-filter-1-a-1.mail.uk.tiscali.com [212.74.100.52]) by mail.postgresql.org (Postfix) with ESMTP id A9FB1632FAF for ; Tue, 12 May 2009 07:10:06 -0300 (ADT) X-Trace: 197648673/mk-filter-1.mail.uk.tiscali.com/B2C/$b2c-THROTTLED-DYNAMIC/b2c-CUSTOMER-DYNAMIC-IP/80.225.59.140/None/john.lister@kickstone.com X-SBRS: None X-RemoteIP: 80.225.59.140 X-IP-MAIL-FROM: john.lister@kickstone.com X-SMTP-AUTH: X-MUA: Thunderbird 2.0.0.21 (Windows/20090302) X-IP-BHB: Once X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AroBAE/oCEpQ4TuM/2dsb2JhbAAIzCGEAgU X-IronPort-AV: E=Sophos;i="4.41,181,1241391600"; d="scan'208";a="197648673" Received: from 80-225-59-140.dynamic.dial.as9105.com (HELO [192.168.6.11]) ([80.225.59.140]) by smtp.tiscali.co.uk with ESMTP; 12 May 2009 11:10:02 +0100 Message-ID: <4A094AB9.9090807@kickstone.com> Date: Tue, 12 May 2009 11:08:57 +0100 From: John Lister User-Agent: Thunderbird 2.0.0.21 (Windows/20090302) MIME-Version: 1.0 To: Luca Ferrari , pgsql-jdbc@postgresql.org Subject: Re: ResultSet internal data type handling References: <200905120939.07478.fluca1978@infinito.it> <4A092D2E.3070905@kickstone.com> <200905121148.24365.fluca1978@infinito.it> In-Reply-To: <200905121148.24365.fluca1978@infinito.it> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit 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: 200905/60 X-Sequence-Number: 19610 >> I believe the original wire protocol only supported text values hence >> the driver converts all data into a string before sending it to the >> server... Because of this the server will generally convert any value >> into the appropriate type (if this conversion is possible) which saves >> the driver from doing so. This simplifies the driver at the expense of >> extra network traffic and errors thrown by the server as opposed to the >> driver. The original authors can probably expand on this >> > > It is not clear to me: the driver is receiving always strings from the server, > and therefore must do the conversion by itself. The fact is that such > conversion is not checked against the table definition. I would expect an > SQLException if I try to read an integer as a string or viceversa. Instead the > conversion can work and the driver says nothing about. > For outgoing values, the current driver delays doing any work with the query until it is actually executed. This has a number of consequences and benefits which have been discussed before - see threads about preparedstatements, etc. The double edged sword of this is that by delaying execution the driver knows the types of the parameters being passed in which can help planning, the downside is that it doesn't know the types required so can't generate errors. While it is true that if the query is fairly simple and done against a table then it could make the check before submitting the query. But what does it do for queries like this: SELECT ? The parameter can be of any type. Generally the argument is that you cannot know the param types from the query itself. However for incoming values/conversions, as oliver mentioned the JDBC spec requires a driver do some conversions automatically (int -> string). JOHN