From: | Thomas Kellerer <spam_eater(at)gmx(dot)net> |
---|---|
To: | pgsql-jdbc(at)postgresql(dot)org |
Subject: | Columns with domains from other schemas and DatabaseMetaData |
Date: | 2010-10-22 07:41:34 |
Message-ID: | i9rf7e$bac$1@dough.gmane.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-jdbc |
Hi,
I have noticed another problem with DatabaseMetaData.getColumns() and domains.
If a domain is created in a different schema than the table, psql will show the fully qualified name of the domain when doing a "\d table"
When retrieving the column definition of such a table using getColumns() the column TYPE_NAME from the obtained resultset will contain the domain name without the schema.
As an example:
CREATE SCHEMA other;
CREATE DOMAIN other.salary_domain AS numeric(12,2) NOT NULL CHECK (value > 0);
CREATE TABLE employee (id integer not null, salary other.salary_domain);
COMMIT;
From psql, the following is displayed for this table:
psql (9.0.1)
Type "help" for help.
postgres=> \d employee
Table "public.employee"
Column | Type | Modifiers
--------+---------------------+-----------
id | integer | not null
salary | other.salary_domain |
postgres=>
Unfortunately the JDBC driver does not return the fully qualified name of the domain as psql does.
Although according to the JDBC Javacods, TYPE_NAME is described as "for a UDT the type name is fully qualified".
This is the sample Java code:
Connection con = DriverManager.getConnection(...)
ResultSet rs = con.getMetaData().getColumns(null, "public", "employee", "%");
while (rs.next())
{
String col = rs.getString("COLUMN_NAME");
String type = rs.getString("TYPE_NAME");
System.out.println(col + ": " + type);
}
Will print:
id: integer
salary: salary_domain
I tried this with PostgreSQL 9.0.1 and the 9.0-801 JDBC driver.
It would nice if this could be fixed in a future version of the driver.
Thanks
Thomas
From | Date | Subject | |
---|---|---|---|
Next Message | Michael musset | 2010-10-23 03:53:04 | Re: JDBC4 with SQLXML and postgresql-8.4-702.jdbc4.jar |
Previous Message | dmp | 2010-10-22 01:25:36 | Re: Bug in DatabaseMetaData.getColumns() with columns based on domains |