Received: from localhost (maia-1.hub.org [200.46.204.191]) by postgresql.org (Postfix) with ESMTP id D942C9FA176 for ; Fri, 5 Jan 2007 03:16:55 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.191]) (amavisd-new, port 10024) with ESMTP id 73873-09 for ; Fri, 5 Jan 2007 03:16:50 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey-1.7.4 Received: from www01.kensystem.com (www01.kensystem.com [72.19.170.120]) by postgresql.org (Postfix) with ESMTP id 0BAAD9F946C for ; Fri, 5 Jan 2007 03:16:49 -0400 (AST) Received: from 192.168.0.3 by www01.kensystem.com (SMTPD); id s20070105071646.48; Fri, 05 Jan 2007 07:16:46 Message-ID: <459DFB5E.9030701@kensystem.com> Date: Fri, 05 Jan 2007 00:16:46 -0700 From: Ken Johanson User-Agent: Thunderbird 1.5.0.9 (Windows/20061207) MIME-Version: 1.0 To: Tom Lane CC: pgsql-jdbc@postgresql.org, Kris Jurka Subject: Re: Support for DatabaseMetadata: getCatalogName, getTableName, References: <4594B16C.5010609@kensystem.com> <3936D281-E235-4FB3-889E-08981ABB0954@fastcrypt.com> <459D3487.6080202@kensystem.com> <459D3F3E.5040006@kensystem.com> <459D6CEC.9040505@kensystem.com> <459D7D66.6010202@kensystem.com> <10251.1167974932@sss.pgh.pa.us> In-Reply-To: <10251.1167974932@sss.pgh.pa.us> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200701/38 X-Sequence-Number: 16403 Tom Lane wrote: >>> The previous discussion I cited was referring to getColumnName and how >>> it really should be referring to the alias of a result, not the column >>> itself. That is for "SELECT a AS b FROM c AS d" should return "b" for >>> getColumnName(1). If we accept that as true then it follows that >>> getTableName(1) should return "d", not "c". > >> Understood now, thanks. I agree/vote this is the best spec >> interpretation/behavior (for its lack of a 'getTableLabel'). > > Urm ... I might agree with that, except for its signal lack of usefulness. > What is the point of knowing the table alias? The > underlying-table-and-column names have some possible usefulness for > issuing updates against the underlying tables, Agreed. but what the heck are you > going to do with "d" here? you can (as you know) have multiple table aliases on the same table, where for example 'd' might represent a relation value to c. For example a manager 'd' over a employee 'c': select c.firstName, d.firstName from contacts as c, contacts as d where c.bossId=d.pk and d.role=... With the table name alias I can tell which rows are bosses or subordinates (without needing to know/maintain column ordinality, or otherwise just by doing a `select * from..`). The real world use I have is similar to above except that I add in another table for one to many relations (multiple bosses or trainers, etc), and don't really use the bossId field -- it exemplifies the idea here though. For low level and efficient data retrieval this this is the very simplest and most elegant SELECT methodology I've come across - just select * from [joined tables], and a diver can build hierarchal hashtables, or instead a flat one with (albeit stringbuffer-built) keys (tbl.get("boss.firstName")) If the application understands the query > (which it itself issued, don't forget) well enough to understand what > "d" conveys, why wouldn't "b" be at least as useful? Yes, but one isn't in the spec as you stated. 'd' seems the more useful to me. And if it defaults to the real name in absence of an alias, that seems logical and all-serving also.