Re: ResultSetMetaData.getTableName() == null

From: Oliver Jowett <oliver(at)opencloud(dot)com>
To: Philip Yarra <philip(at)utiba(dot)com>
Cc: Alex Stienstra <alex(dot)stienstra(at)zonnet(dot)nl>, pgsql-jdbc(at)postgresql(dot)org
Subject: Re: ResultSetMetaData.getTableName() == null
Date: 2006-09-22 05:40:18
Message-ID: 45137742.9050600@opencloud.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

Philip Yarra wrote:

> so is there
> some reason why getTableName couldn't be re-written as:
>
> public String getTableName(int column) throws SQLException
> {
> return getBaseTableName(column);
> }
>

We came to the conclusion in the original discussion that getTableName()
should return the aliased name of the table in the query, or the actual
table name if not aliased.

getBaseTableName() always returns the real underlying table name, even
if it was actually aliased to something else in the query. This reflects
the information that the server gives us (see the RowDescription message
in
http://www.postgresql.org/docs/8.1/static/protocol-message-formats.html
-- getBaseTableName() returns a name based on the table object ID in
that message)

So your suggested implementation would return incorrect information
whenever there were aliases involved.

We have no way of telling if aliasing has been done or not based on the
data returned by the server, so we can't even do it only when no aliases
are used.

-O

In response to

Responses

Browse pgsql-jdbc by date

  From Date Subject
Next Message Philip Yarra 2006-09-22 06:04:36 Re: ResultSetMetaData.getTableName() == null
Previous Message Philip Yarra 2006-09-22 05:19:59 Re: ResultSetMetaData.getTableName() == null