Skip site navigation (1) Skip section navigation (2)

[PATCH] problem with DatabaseMetaData and mixed case table names

From: Giuseppe Sacco <giuseppe(at)eppesuigoccas(dot)homedns(dot)org>
To: pgsql-jdbc(at)postgresql(dot)org
Subject: [PATCH] problem with DatabaseMetaData and mixed case table names
Date: 2005-08-08 16:20:43
Message-ID: 1123518043.6487.4.camel@localhost (view raw, whole thread or download thread mbox)
Lists: pgsql-jdbc
Hi pgsql developers,
today I found a problem using the latest version of the driver, from
CVS. This is an example that shows the problem:

Connection c = ...;
Statement s = c.createStatement();

s.execute("create table MyTable ( PK numeric(10), primary key(pk))");

DatabaseMetaData md = c.getMetaData();
ResultSet rs = md.getPrimaryKeys(null,null, "MyTable")

while (
	System.out.println("table: \"" + rs.getString("TABLE_NAME") + 
	"\", column: \"" + rs.getString("COLUMN_NAME") + "\".");


The resultset is empty, while it should contain a line for the
"PK" field.

If I lowercase the table name in «getPrimaryKeys» call than everything
My question is: how do I know that postgresql changed my table name?

The solution I propose is, since it seems that postgresql always store
relation names in lowercase letters, to change the jdbc implementation
of all methods like «getPrimaryKeys» in order to pass lowercase relation
names to the backend.

The proposed patch change «escapeQuotes» method that is used for table
names, column names, schema names, type names, table name patters,
column name patterns, schema name patters and type name patterns.

The changed method return a lowercase string, that is thereafter used
in sql statements with '=' and 'like' operators.

Is this the right way to solve the problem?


Attachment: pgsql-lowercase.diff
Description: text/x-patch (388 bytes)


pgsql-jdbc by date

Next:From: Kris JurkaDate: 2005-08-08 21:55:30
Subject: Re: [PATCH] problem with DatabaseMetaData and mixed case
Previous:From: JiangyiDate: 2005-08-08 11:59:25
Subject: get question mark with Chinese/Japanese character ?

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group