getColumns() is not table name case insensitive - Mailing list pgsql-jdbc

From Michał Niklas
Subject getColumns() is not table name case insensitive
Date
Msg-id 3E5363D5.9030409@heuthes.pl
Whole thread Raw
Responses Re: getColumns() is not table name case insensitive
List pgsql-jdbc
Hello,

I'm working with PostgreSQL from both Delphi and Java.
In Java I use JDBC driver.
In Delphi I use PgLib or Zeos components.
Zeos components can be found at:
http://sourceforge.net/projects/zeoslib

My program can show tables and columns.
I use metainformation to get it.
Unfortunatelly getColumns() works fine only
if name of table is identical in case
with table name in PostgreSQL system tables.

If in my db is table 'test' I can do:
a) SELECT fld FROM test
b) SELECT fld FROM Test
c) SELECT fld FROM TEST
etc
But getColumns() works only with "test".

In Zeos there are functions that get meta information
about table columns just like JDBC getColumns().
They use lower() SQL function and Lowercase()
Pascal function.
Example from ZDirPgSql.pas:

   Sql := 'SELECT pg_attribute.attnum AS index, attname AS field,'
...
     +' AND atthasdef=''f'' AND
lower(relname)='''+LowerCase(TableName)+'''';
   if FieldName <> '' then
     Sql := Sql + ' AND lower(attname) LIKE '''+LowerCase(FieldName)+'''';

In JDBC AbstractJdbc1DatabaseMetaData.java
where getColumns() is implemented
I have found no lower() function:
if (tableNamePattern != null && !"".equals(tableNamePattern)) {
sql += " AND c.relname LIKE '"+escapeQuotes(tableNamePattern)+"' ";
}
if (columnNamePattern != null && !"".equals(columnNamePattern)) {
sql += " AND a.attname LIKE '"+escapeQuotes(columnNamePattern)+"' ";
...

I think both relname and attname should be compared
without case sensitivity.

Best regards,
Michal Niklas
http://republika.pl/michalniklas/mn.html


pgsql-jdbc by date:

Previous
From: "Roger Hand"
Date:
Subject: Re: case problem with moveToInsertRow() - 7.4dev drivers OK, 7.3 drivers not
Next
From: "Mykola Dudar"
Date:
Subject: exception in decodeUTF8