From: | Michał Niklas <michal(dot)niklas(at)heuthes(dot)pl> |
---|---|
To: | pgsql-jdbc(at)postgresql(dot)org |
Subject: | getColumns() is not table name case insensitive |
Date: | 2003-02-19 11:00:37 |
Message-ID: | 3E5363D5.9030409@heuthes.pl |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | 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
From | Date | Subject | |
---|---|---|---|
Next Message | Felipe Schnack | 2003-02-19 12:24:24 | ANY subquery and PreparedStatements |
Previous Message | Rainer Klute | 2003-02-19 08:04:39 | Re: JSP AccessControlException error |