X-Original-To: pgsql-jdbc-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 5D986DBC22 for ; Thu, 24 Nov 2005 17:20:10 -0400 (AST) 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 01769-09 for ; Thu, 24 Nov 2005 21:20:11 +0000 (GMT) X-Greylist: from auto-whitelisted by SQLgrey- Received: from yass.opencloud.co.nz (yass.opencloud.co.nz [131.203.101.226]) by svr1.postgresql.org (Postfix) with ESMTP id 7C661DBC72 for ; Thu, 24 Nov 2005 17:20:06 -0400 (AST) Received: from 203-79-104-60.cable.paradise.net.nz ([203.79.104.60] helo=[192.168.0.20]) by yass.opencloud.co.nz with asmtp (TLS-1.0:DHE_RSA_AES_128_CBC_SHA:16) (Exim 4.34) id 1EfOVh-000109-PI; Fri, 25 Nov 2005 10:20:05 +1300 Message-ID: <43862E81.3070308@opencloud.com> Date: Fri, 25 Nov 2005 10:20:01 +1300 From: Oliver Jowett User-Agent: Mozilla Thunderbird 1.0.7 (X11/20051009) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Dave Cramer CC: Kris Jurka , pgsql-jdbc@postgresql.org Subject: Re: Can PostgreSQL do data type automated casting in References: <200511211718.26679.xinxincute@gmail.com> <1132616246.4154.10.camel@archimedes> <6F909ADC-23ED-40CF-A2B5-41DE61606A26@fastcrypt.com> <438548DB.8070407@opencloud.com> <73985A37-FA66-4E31-95C1-045F5AE31726@fastcrypt.com> <438626EF.2080408@opencloud.com> <6022BCB2-7A1B-47A2-AC85-CDBB7CBD127C@fastcrypt.com> In-Reply-To: <6022BCB2-7A1B-47A2-AC85-CDBB7CBD127C@fastcrypt.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, score=0 required=5 tests=[none] X-Spam-Score: 0 X-Spam-Level: X-Archive-Number: 200511/197 X-Sequence-Number: 14295 Dave Cramer wrote: > You're on fairly shaky ground using "allowed by the spec" as > justification. Why's that? Are we no longer trying to write a spec-compliant driver? > I'm thinking there are far more instances where people > expect Oid unspecified to work than > instances where they are going to change the type of the IN parameter > in the same statement. Sure, but I'd rather not have an option that makes the driver break unexpectedly. Given that we can have both unspecified string types AND a fix for the changing-type problem, why do you *not* want to do that? If you want a more "real world" example, how about something like this: >> ArrayList toInsert = new ArrayList(); >> toInsert.add(new Integer(42)); >> toInsert.add(new Date()); >> toInsert.add("test string"); >> // ... >> PreparedStatement ps = conn.prepareStatement("INSERT INTO sometexttable(sometextcolumn) VALUES (CAST (? AS TEXT))"); >> for (Iterator i = toInsert.iterator(); i.hasNext(); ) { >> ps.setObject(1, i.next()); >> ps.executeUpdate(); >> } Test cases are not meant to be real-world examples, they're test code. Use your imagination! > Given that the default behaviour adheres to the spec, I'm not too > worried about the case below failing under these specific > circumstances. I presume it passes with the 8.0,8.1 behaviour. It does. The code I have committed to CVS HEAD deals with the changing-parameter-type case correctly even with stringtype=unspecified, anyway. Can you please try it out and see if you have any problems with it? Otherwise, as far as I'm concerned I'm done with this -- if people don't want to change their (arguably broken) apps, they have an escape hatch they can enable explicitly or via compatible=7.4.. IMO we don't need to do anything more. -O