From: | Alessandro Di Bella <aldibella(at)gmail(dot)com> |
---|---|
To: | pgsql-jdbc(at)postgresql(dot)org |
Subject: | Bug in implementation of java.sql.DatabaseMetaData |
Date: | 2010-09-02 15:04:36 |
Message-ID: | AANLkTiki00kRRo3dkpM4sK3D-F7aPnrtHTmegSG0HUWt@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-jdbc |
Hi,
accordingly to the JDBC specification (
http://download.oracle.com/javase/1.4.2/docs/api/java/sql/DatabaseMetaData.html#getColumns(java.lang.String,%20java.lang.String,%20java.lang.String,%20java.lang.String)
), when calling
public ResultSet java.sql.DatabaseMetaDatagetColumns(String
catalog,String schemaPattern,String tableNamePattern, String
columnNamePattern) throws SQLException
the column TYPE_NAME String should contain the data source dependent
type name that for a user defined type (UDT), the type name is fully
qualified.
However, the JDBC driver ignores the schema the type is defined into
and just return the simple name.
Thus, is impossible to handle multiple types with the same name in
different schema.
I found that the core problem is in
org.postgresql.jdbc2.TypeInfoCache.getPGType(String) where the sql
should be something like:
SELECT pg_namespace.nspname || '.' || pg_type.typname FROM
pg_catalog.pg_type JOIN pg_catalog.pg_namespace ON pg_namespace.oid =
pg_type.typnamespace WHERE pg_type.oid = ?;
Unfortunately that method is used everywhere and I wasn't too sure on
how to change so I changed the
org.postgresql.jdbc2.AbstractJdbc2DatabaseMetaData instead.
The attached patch refers to a checkout of the REL8_4_STABLE.
Can you please integrate my change or fix the problem as you see fit?
Thanks
Alessandro
Attachment | Content-Type | Size |
---|---|---|
patch.diff | text/x-patch | 1.8 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | Kyran O Reilly | 2010-09-02 15:41:20 | Re: Can't connect to posgresql through the jdbc driver |
Previous Message | Oliver Jowett | 2010-09-01 08:26:41 | Re: JDBC: "transaction aborted" |