getColumns() is not table name case insensitive

Поиск
Список
Период
Сортировка
От Michał Niklas
Тема getColumns() is not table name case insensitive
Дата
Msg-id 3E5363D5.9030409@heuthes.pl
обсуждение исходный текст
Ответы Re: getColumns() is not table name case insensitive
Список 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 по дате отправления:

Предыдущее
От: "Roger Hand"
Дата:
Сообщение: Re: case problem with moveToInsertRow() - 7.4dev drivers OK, 7.3 drivers not
Следующее
От: "Mykola Dudar"
Дата:
Сообщение: exception in decodeUTF8