Re: ResultSetMetaData.getTableName() == null - Mailing list pgsql-jdbc

From Oliver Jowett
Subject Re: ResultSetMetaData.getTableName() == null
Date
Msg-id 45137742.9050600@opencloud.com
Whole thread Raw
In response to Re: ResultSetMetaData.getTableName() == null  (Philip Yarra <philip@utiba.com>)
Responses Re: ResultSetMetaData.getTableName() == null  (Philip Yarra <philip@utiba.com>)
List 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

pgsql-jdbc by date:

Previous
From: Philip Yarra
Date:
Subject: Re: ResultSetMetaData.getTableName() == null
Next
From: Philip Yarra
Date:
Subject: Re: ResultSetMetaData.getTableName() == null