Re: Wrong column names in ResultSetMetaData - Mailing list pgsql-jdbc

From Mike Martin
Subject Re: Wrong column names in ResultSetMetaData
Date
Msg-id cemoh4$2ouc$1@news.hub.org
Whole thread Raw
In response to Re: Wrong column names in ResultSetMetaData  ("Mike Martin" <mmartin@vieo.com>)
List 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



pgsql-jdbc by date:

Previous
From: Oliver Jowett
Date:
Subject: Re: Wrong column names in ResultSetMetaData
Next
From: "Mike Martin"
Date:
Subject: Re: Wrong column names in ResultSetMetaData