X-Original-To: pgsql-jdbc-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id D2C4D32BB9A for ; Wed, 13 Oct 2004 22:06:55 +0100 (BST) 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 38281-02 for ; Wed, 13 Oct 2004 21:06:52 +0000 (GMT) Received: from yass.opencloud.co.nz (yass.opencloud.co.nz [203.79.85.162]) by svr1.postgresql.org (Postfix) with ESMTP id C7AFD32A5E8 for ; Wed, 13 Oct 2004 22:06:53 +0100 (BST) Received: from 203-79-104-60.cable.paradise.net.nz ([203.79.104.60] helo=opencloud.com) by yass.opencloud.co.nz with asmtp (Exim 3.35 #1 (Debian)) id 1CHqKh-00079J-00; Thu, 14 Oct 2004 10:06:51 +1300 Message-ID: <416D98E8.5090600@opencloud.com> Date: Thu, 14 Oct 2004 10:06:48 +1300 From: Oliver Jowett User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.6b) Gecko/20031205 Thunderbird/0.4 X-Accept-Language: en-us, en MIME-Version: 1.0 To: "Tornroth, Phill" Cc: pgsql-jdbc@postgresql.org Subject: Re: FW: Question about the postgres resultset implementation References: In-Reply-To: Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200410/125 X-Sequence-Number: 11230 Tornroth, Phill wrote: > I did some tinkering of my own and found that one of the problems with > making the driver less cumbersome is the fact that findColumn() is currently > case insensitive. I don't know if this is required by the jdbc spec, but it > seems all the field names come back lower case (in the fields[] array), and > so I could replace the implementation without understanding how to prevent > the case of the field names from changing (changing from the case they were > sent in as). They come back lower-case because that's how they are in the actual schema. Unless you quote identifiers, they get smashed to lowercase by the backend: >> test=> create table t1(lowercase integer, UPPERCASE integer, "QUOTEDUPPERCASE" integer); >> CREATE TABLE >> test=> select * from t1; >> lowercase | uppercase | QUOTEDUPPERCASE >> -----------+-----------+----------------- >> (0 rows) > At any rate, if case insensitivity could be thrown out then a very fast > implementation could be worked out. As is, the following code was a marked > improvement: That change is slightly buggy as you *can* get uppercase characters in a field name. We can't entirely discard case-insensitivy as JDBC requires that column names are found case-insensitively. This actually makes the use of column names somewhat unreliable if you ever have two columns with names that only differ by case. From the JDBC javadoc: >> Column names used as input to getter methods are case insensitive. When >> a getter method is called with a column name and several columns have >> the same name, the value of the first matching column will be returned. >> The column name option is designed to be used when column names are used >> in the SQL query that generated the result set. For columns that are NOT >> explicitly named in the query, it is best to use column numbers. If >> column names are used, there is no way for the programmer to guarantee >> that they actually refer to the intended columns. (I am assuming that "findColumn" is considered a getter method.. the javadoc is vague as ever) Nevertheless, we could certainly use a hashmap to speed up field lookups. This should be pretty trivial to implement, expect a patch shortly. (hah, in fact I see that Kris got there first..) -O