From: Mike Martin <mmartin@vieo.com>
To: pgsql-jdbc@postgresql.org
Subject: Re: Wrong column names in ResultSetMetaData
Date: Mon, 2 Aug 2004 19:32:09 -0500
Message-ID: <cemmc3$2ke7$1@news.hub.org> (raw)
References: <ce9dna$pne$1@news.hub.org>
<ce9jk0$15mb$1@news.hub.org>
<41086EF8.7010101@opencloud.com>
<celqa5$i2c$1@news.hub.org>
<Pine.BSO.4.56.0408021308010.29090@leary.csoft.net>
<cembfp$1tpn$1@news.hub.org>
<Pine.BSO.4.56.0408021705100.21355@leary.csoft.net>
<410ED4E6.8020806@opencloud.com>
Oliver wrote:
> RSMD.getColumnName() returns the column alias
> RSMD.getColumnLabel() returns the column alias, or maybe something
> like the column's comment (can you COMMENT ON columns?) later.
> PGResultSetMetadata.getSourceColumnName() returns the underlying
> table column name. The driver's updateable resultset code can use this
> when constructing update SQL.
I like that, not just because I think it jives with the spec
but because a new method can explicitly document that the
source column name is not available if the result column has
multiple sources.
> On a related note, if I execute this query:
>
> SELECT * FROM footable f
>
> should RSMD.getTableName() return "footable" or "f"? By analogy to
> RSMD.getColumnName() it should return "f", but it seems more useful to
> return "footable".
According to SQL "f" is the right answer. One way convince yourself
is to observe the difference between:
SELECT f.col FROM footable f
SELECT footable.col FROM footable f
The former works as you might expect. The latter fails on some
DBMS's and I'm pretty sure it's invalid SQL. Interestingly, on
PG the latter is evaluated as though it were:
SELECT f2.col FROM footable f1 CROSS JOIN footable f2
which for a footable of N rows returns N*N rows!
Mike
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: mmartin@vieo.com
Subject: Re: Wrong column names in ResultSetMetaData
In-Reply-To: <cemmc3$2ke7$1@news.hub.org>
References: <ce9dna$pne$1@news.hub.org> <ce9jk0$15mb$1@news.hub.org> <41086EF8.7010101@opencloud.com> <celqa5$i2c$1@news.hub.org> <Pine.BSO.4.56.0408021308010.29090@leary.csoft.net> <cembfp$1tpn$1@news.hub.org> <Pine.BSO.4.56.0408021705100.21355@leary.csoft.net> <410ED4E6.8020806@opencloud.com> <cemmc3$2ke7$1@news.hub.org>
* 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