Received: from localhost (maia-3.hub.org [200.46.204.184]) by postgresql.org (Postfix) with ESMTP id 6955E9F9D83 for ; Mon, 27 Aug 2007 02:31:24 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.184]) (amavisd-maia, port 10024) with ESMTP id 84214-05 for ; Mon, 27 Aug 2007 02:31:19 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.5 Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by postgresql.org (Postfix) with ESMTP id 934D09F93E5 for ; Mon, 27 Aug 2007 02:31:21 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.1/8.14.1) with ESMTP id l7R5VGHl013836; Mon, 27 Aug 2007 01:31:17 -0400 (EDT) To: Kris Jurka cc: David Goodenough , pgsql-jdbc@postgresql.org Subject: Re: Support for ResultSetMetaData.getTableName In-reply-to: References: <200708211506.22384.david.goodenough@btconnect.com> Comments: In-reply-to Kris Jurka message dated "Mon, 27 Aug 2007 00:58:46 -0400" Date: Mon, 27 Aug 2007 01:31:16 -0400 Message-ID: <13835.1188192676@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200708/93 X-Sequence-Number: 17406 Kris Jurka writes: > The discussion was focused on the ability of the server to return the > alias of a table as well as the base table name. Because getColumnName > will return "b" for "SELECT a AS b FROM c AS d" we have decided that > getTableName should return "d" instead of "c". [ itch... ] Just looking at this again, I wonder whether that's going in the wrong direction. What is the point of getTableName, if not to find out a table name that is usable in other queries? I also notice that the spec provides getSchemaName, which is sensible if one supposes that the point of all this is to find out the actual table name, and is completely nonsensical if the point is to find out the inherently not-schema-qualified table alias. I suggest that the following mapping might be more sensible: getColumnName returns "a" getTableName returns "c" getSchemaName returns name of c's schema getColumnLabel returns "b" where the first three fail if the SELECT column isn't a simple column reference, but getColumnLabel always works. I'm not sure what the use-case is for finding out "d". regards, tom lane