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 7F8E75289C for ; Tue, 9 Aug 2005 20:01:24 -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 00331-04 for ; Tue, 9 Aug 2005 23:01:20 +0000 (GMT) Received: from mail63.csoft.net (leary3.csoft.net [63.111.22.74]) by svr1.postgresql.org (Postfix) with SMTP id CB99752824 for ; Tue, 9 Aug 2005 20:01:19 -0300 (ADT) Received: (qmail 4798 invoked by uid 1112); 9 Aug 2005 23:01:22 -0000 Date: Tue, 9 Aug 2005 18:01:22 -0500 (EST) From: Kris Jurka X-X-Sender: books@leary.csoft.net To: Thomas Dudziak Cc: pgsql-jdbc@postgresql.org Subject: Re: Missing functionality in ResultSetMetaData ? In-Reply-To: <224f3234050809153725fb91c@mail.gmail.com> Message-ID: References: <224f323405080913385a38ece0@mail.gmail.com> <224f323405080914194be16ac3@mail.gmail.com> <224f3234050809153725fb91c@mail.gmail.com> 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.009 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200508/56 X-Sequence-Number: 13625 On Wed, 10 Aug 2005, Thomas Dudziak wrote: > Nope, I only browsed over the one you posted earlier (regarding > PGResultSetMetaData). I take it that the issue with > getColumnName/getBaseColumnName is the same as with > getTableName/getBaseTableName ? Let me state what I understand of this > issue: it is only possible to return the base (real ?) table name, not > the alias. The issue actually started with column names. The pg server currently can return aliases for columns, but not for tables. The original complaint was that RSMD.getColumnName better match up with something if we call ResultSet.findColumn with it. After much discussion it was agreed that getColumnName means the name of the query's result column not the base table's column. Now, to be consistent getTableName must mean the query's table as well. > However if this is the case, then I don't think your argument given in > http://archives.postgresql.org/pgsql-jdbc/2004-08/msg00021.php is > valid, because from what I understand of the ResultSetMetaData, the > getTableName method returns the name of the column's table, ie. IMO > the name of the table where the column is defined in. > So in your example this cannot be 'f' but must be 'footable'. I mean, > what would I do with 'f' anyway ? This isn't completely useless, consider a self join: "SELECT a.c, b.c FROM tab a, tab b". getBaseTableName cannot distinguish this, but if getTableName did return the alias it could. This isn't a real strong use case though... > IMO it should be possible to build > structurally valid select statements from the ResultSetMetaData > information which is not the case when returning the aliases. > I think this is actually supported by the few places in the JDBC 3 > spec that deal with ResultSetMetaData, eg. 13.2.3: > > "The method PreparedStatement.getMetaData retrieves a > ResultSetMetaData object containing a description of the columns that will be > returned by a prepared statement when is it executed. The ResultSetMetaData > object contains a record for each column being returned. Methods in the > ResultSetMetaData interface provide information about the number of columns > being returned and the characteristics of each column." > > Here they specifically speak about the column' characteristics (ie. > definition) not the query. That's not entirely clear. That's how you read it, but it is just as easily read as "the query result's columns". The spec is awfully vague in this area. Kris Jurka