From: Ken Johanson <pg-user@kensystem.com>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: pgsql-jdbc@postgresql.org
Cc: Kris Jurka <books@ejurka.com>
Subject: Re: Support for DatabaseMetadata: getCatalogName, getTableName,
Date: Fri, 05 Jan 2007 00:16:46 -0700
Message-ID: <459DFB5E.9030701@kensystem.com> (raw)
In-Reply-To: <10251.1167974932@sss.pgh.pa.us>
References: <4594B16C.5010609@kensystem.com>
<3936D281-E235-4FB3-889E-08981ABB0954@fastcrypt.com>
<Pine.BSO.4.64.0701041139350.18398@leary2.csoft.net>
<459D3487.6080202@kensystem.com>
<Pine.BSO.4.64.0701041225110.24201@leary2.csoft.net>
<459D3F3E.5040006@kensystem.com>
<Pine.BSO.4.64.0701041324480.24201@leary2.csoft.net>
<459D6CEC.9040505@kensystem.com>
<Pine.BSO.4.64.0701041609540.20842@leary2.csoft.net>
<459D7D66.6010202@kensystem.com>
<10251.1167974932@sss.pgh.pa.us>
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.
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-jdbc@postgresql.org
Cc: pg-user@kensystem.com, tgl@sss.pgh.pa.us, books@ejurka.com
Subject: Re: Support for DatabaseMetadata: getCatalogName, getTableName,
In-Reply-To: <459DFB5E.9030701@kensystem.com>
References: <4594B16C.5010609@kensystem.com> <3936D281-E235-4FB3-889E-08981ABB0954@fastcrypt.com> <Pine.BSO.4.64.0701041139350.18398@leary2.csoft.net> <459D3487.6080202@kensystem.com> <Pine.BSO.4.64.0701041225110.24201@leary2.csoft.net> <459D3F3E.5040006@kensystem.com> <Pine.BSO.4.64.0701041324480.24201@leary2.csoft.net> <459D6CEC.9040505@kensystem.com> <Pine.BSO.4.64.0701041609540.20842@leary2.csoft.net> <459D7D66.6010202@kensystem.com> <10251.1167974932@sss.pgh.pa.us> <459DFB5E.9030701@kensystem.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox