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 D8E93D1B16B for ; Thu, 29 Jul 2004 00:20:50 -0300 (ADT) 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 93138-06 for ; Thu, 29 Jul 2004 03:20:48 +0000 (GMT) Received: from mail63.csoft.net (leary3.csoft.net [63.111.22.74]) by svr1.postgresql.org (Postfix) with SMTP id F3D83D1B34B for ; Thu, 29 Jul 2004 00:20:46 -0300 (ADT) Received: (qmail 24063 invoked by uid 1112); 29 Jul 2004 03:20:46 -0000 Date: Wed, 28 Jul 2004 22:20:46 -0500 (EST) From: Kris Jurka X-X-Sender: books@leary.csoft.net To: Mike Martin Cc: pgsql-jdbc@postgresql.org Subject: Re: Wrong column names in ResultSetMetaData In-Reply-To: Message-ID: References: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII 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: 200407/316 X-Sequence-Number: 10700 On Wed, 28 Jul 2004, Mike Martin wrote: > I wrote: > > [new driver returns a column alias as the label, not name] > > I'm almost certain this is wrong from a JDBC standpoint. > > rsmd.getColumnName() is supposed to return the given name of > the *result* column, which SQL has rules to define. > rsmd.getColumnLabel() is "for use in printouts and displays" > and will often equate to the column name unless the DBMS has > some "prettier" column title for display purposes. > > For programmatic purposes the column name concept is pretty > well defined by the docs on ResultSet. They're supposed to > behave such that: > > String colname = rsmd.getColumnName(col); > return rs.getXXX(colname); > > is equivalent to: > > return rs.getXXX(col); > I am not sure I see where it states that. Your logic makes some sense, but I don't see anywhere it says the above explicity. The problem is how to return both pieces of information (the alias and the underlying column name) within the JDBC API. Certainly the alias makes more sense as the label when you have to pick between the two of them. Would you expect the results of getTableName() to return the underlying table or the table's alias in the query? To be consistent with your argument you'd have to claim the alias name which is useless here. Further code doesn't make a whole lot of sense doing: rs.getString(rsmd.getColumnName(1)); Why wouldn't it just do: rs.getString(1); Kris Jurka