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 0D42D5291E for ; Tue, 9 Aug 2005 19:37:47 -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 16910-10 for ; Tue, 9 Aug 2005 22:37:38 +0000 (GMT) Received: from nproxy.gmail.com (nproxy.gmail.com [64.233.182.195]) by svr1.postgresql.org (Postfix) with ESMTP id B14DA5288C for ; Tue, 9 Aug 2005 19:37:36 -0300 (ADT) Received: by nproxy.gmail.com with SMTP id b2so2153nfe for ; Tue, 09 Aug 2005 15:37:39 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=t8QsKyKt8eB4j34PaCv5TcGKwzuYGMnrMOjsbVGTiOgPDphvJlRSQ4iNLMYnwSkmnfOsmDRtT3B4Axs/dV7mEhFJZUens6ERG8k/qOUi2UhAmh8gbnlpSe8gPjoykkK88D74Q6NQOy14MY6V8fyJ53VZ1ohS6swyS/MBRKfuDzM= Received: by 10.48.250.16 with SMTP id x16mr2799nfh; Tue, 09 Aug 2005 15:37:38 -0700 (PDT) Received: by 10.48.249.2 with HTTP; Tue, 9 Aug 2005 15:37:38 -0700 (PDT) Message-ID: <224f3234050809153725fb91c@mail.gmail.com> Date: Wed, 10 Aug 2005 00:37:38 +0200 From: Thomas Dudziak To: pgsql-jdbc@postgresql.org Subject: Re: Missing functionality in ResultSetMetaData ? In-Reply-To: Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline References: <224f323405080913385a38ece0@mail.gmail.com> <224f323405080914194be16ac3@mail.gmail.com> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.024 tagged_above=0 required=5 tests=RCVD_BY_IP X-Spam-Level: X-Archive-Number: 200508/53 X-Sequence-Number: 13622 On 8/10/05, Kris Jurka wrote: >=20 >=20 > On Tue, 9 Aug 2005, Thomas Dudziak wrote: >=20 > > Ok, thanks, I see. However, from what I read in the thread the > > question in the mail that you referenced, as to why > > PGResultSetMetadata does not extend ResultSetMetadata, and as a result > > the getTableName method is mapped onto getBaseTableName, is still > > valid IMO. Especially if the information seems to be readily > > available. Would you consider this change for an upcoming release ? > > >=20 > No the question about extension means that given a PGResultSetMetaData > object you cannot call the standard ResultSetMetaData methods. This is > solely a convenience issue. If you wanted to call both getColumnName and > getBaseColumnName you'd need to maintain two references (one to the > ResultSetMetaData object and another to the PGResultSetMetaData object). > If PGResultSetMetaData extended ResultSetMetaData you'd only need a > reference to the pg version. We have a separate pg specific method > because we believe that function is useful, but does not match the spec > for getTableName. Have you read the entire thread? >=20 > http://archives.postgresql.org/pgsql-jdbc/2004-08/threads.php#00008 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. And Sun didn't define this properly in the JDBC spec (at least not in the API and the 3.0 spec, but this might be some useful input for the 4.0 spec ?). 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 ? 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. IMO the whole intention of the meta data is to be able to determine the database structure by 'reflection' (which incidentially is what I'm doing in my app). As I said, a good reason to ask in the JSR expert group for clarification in the next JDBC standard (if not already done, I havn't checked the current draft). regards, Tom