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 1D7EDD731E for ; Fri, 25 Nov 2005 09:16:12 -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 07672-04 for ; Fri, 25 Nov 2005 13:16:13 +0000 (GMT) X-Greylist: from auto-whitelisted by SQLgrey- Received: from net2.micro-automation.com (net2.micro-automation.com [64.7.141.29]) by svr1.postgresql.org (Postfix) with SMTP id DC548D6822 for ; Fri, 25 Nov 2005 09:16:07 -0400 (AST) Received: (qmail 16472 invoked from network); 25 Nov 2005 13:16:11 -0000 Received: from dcdsl.ebox.com (HELO ?192.168.1.2?) (davec@64.7.143.116) by net2.micro-automation.com with SMTP; 25 Nov 2005 13:16:11 -0000 In-Reply-To: <200511251403.15562.xinxincute@gmail.com> References: <200511211718.26679.xinxincute@gmail.com> <6022BCB2-7A1B-47A2-AC85-CDBB7CBD127C@fastcrypt.com> <43862E81.3070308@opencloud.com> <200511251403.15562.xinxincute@gmail.com> Mime-Version: 1.0 (Apple Message framework v746.2) Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed Message-Id: Cc: pgsql-jdbc@postgresql.org, Oliver Jowett , Kris Jurka Content-Transfer-Encoding: 7bit From: Dave Cramer Subject: Re: Can PostgreSQL do data type automated casting in Date: Fri, 25 Nov 2005 08:16:04 -0500 To: Tjioe Ai Xin X-Mailer: Apple Mail (2.746.2) X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, score=0.007 required=5 tests=[AWL=0.007] X-Spam-Score: 0.007 X-Spam-Level: X-Archive-Number: 200511/203 X-Sequence-Number: 14301 What we are supporting is setString will allow the backend to determine the type of the input parameter if and only if you use setString Dave On 25-Nov-05, at 2:03 AM, Tjioe Ai Xin wrote: > Dear all, > > Does it mean in the future PostgreSQL JDBC Driver will support > automated casting? > So I don't have to write my code again in order to customize for > new driver? > > Thanks in advance. > Xin Xin > > -------------------------------------------------------------------- > On Friday 25 November 2005 04:20, Oliver Jowett wrote: >> 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 >> >> ---------------------------(end of >> broadcast)--------------------------- >> TIP 9: In versions below 8.0, the planner will ignore your desire to >> choose an index scan if your joining column's datatypes do not >> match >> > > ---------------------------(end of > broadcast)--------------------------- > TIP 3: Have you checked our extensive FAQ? > > http://www.postgresql.org/docs/faq >