Re: Wrong column names in ResultSetMetaData

From: "Mike Martin" <mmartin(at)vieo(dot)com>
To: pgsql-jdbc(at)postgresql(dot)org
Subject: Re: Wrong column names in ResultSetMetaData
Date: 2004-08-03 01:08:53
Message-ID: cemoh4$2ouc$1@news.hub.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

Kris wrote:
> > RSMD.getColumnLabel() returns the column alias, or maybe something
> > like the column's comment (can you COMMENT ON columns?) later.
>
> This is my major beef with the argument, what do you do for
> getColumnLabel? Returning the column's comment (which you can do) isn't
> the right thing either. I've got comments running to paragraph length
> describing some of the more obscure columns in my databases. No other
> driver in Mike's list showed an implementation of this different from
> getColumnName, so what's the point? The spec authors must have had some
> existing implementation to inspire this feature. The argument that
> getColumnLabel and getColumnName should do the exact same thing just seems
> wrong to me.

If I'm not mistaken the spec authors were heavily influenced by
ODBC. The two specs have far too much alignment for it to have
been otherwise.

Have a look at the FieldIdentifiers table at:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqlcolattribute.asp

SQLColAttribute is the ODBC function that retrieves result set
metadata.

SQL_DESC_NAME
The column alias, if it applies. If the column alias does not
apply, the column name is returned. In either case,
SQL_DESC_UNNAMED is set to SQL_NAMED. If there is no column
name or a column alias, an empty string is returned and
SQL_DESC_UNNAMED is set to SQL_UNNAMED.

This information is returned from the SQL_DESC_NAME record field
of the IRD.

SQL_DESC_LABEL
The column label or title. For example, a column named EmpName
might be labeled Employee Name or might be labeled with an alias.

If a column does not have a label, the column name is returned.
If the column is unlabeled and unnamed, an empty string is
returned.

Note the close alignment of all the Fields to RSMD concepts. Note
also that they have explicit fields for SQL_DESC_BASE_COLUMN_NAME
and SQL_DESC_BASE_TABLE_NAME which JDBC evidently chose not to
inherit. I think that's what the new V3 info would have corresponded
to.

Bottom line is, I think PG does not have a concept that corresponds
directly to getColumnLabel(). By ODBC rules a label should default
to the column's alias or name.

Mike

In response to

Browse pgsql-jdbc by date

  From Date Subject
Next Message Kris Jurka 2004-08-03 06:00:08 Re: Wrong column names in ResultSetMetaData
Previous Message Oliver Jowett 2004-08-03 00:41:49 Re: Wrong column names in ResultSetMetaData