Received: from maia.hub.org (unknown [200.46.204.243]) by mail.postgresql.org (Postfix) with ESMTP id 8D3181337B6D for ; Fri, 22 Oct 2010 04:41:57 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.243]) (amavisd-maia, port 10024) with ESMTP id 65122-05 for ; Fri, 22 Oct 2010 07:41:49 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from lo.gmane.org (lo.gmane.org [80.91.229.12]) by mail.postgresql.org (Postfix) with ESMTP id AB2221337B71 for ; Fri, 22 Oct 2010 04:41:48 -0300 (ADT) Received: from list by lo.gmane.org with local (Exim 4.69) (envelope-from ) id 1P9CG1-0007jE-Js for pgsql-jdbc@postgresql.org; Fri, 22 Oct 2010 09:41:45 +0200 Received: from 217.110.94.67 ([217.110.94.67]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 22 Oct 2010 09:41:45 +0200 Received: from spam_eater by 217.110.94.67 with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 22 Oct 2010 09:41:45 +0200 X-Injected-Via-Gmane: http://gmane.org/ To: pgsql-jdbc@postgresql.org From: Thomas Kellerer Subject: Columns with domains from other schemas and DatabaseMetaData Date: Fri, 22 Oct 2010 09:41:34 +0200 Lines: 56 Message-ID: Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Complaints-To: usenet@dough.gmane.org X-Gmane-NNTP-Posting-Host: 217.110.94.67 User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.23) Gecko/20090812 Thunderbird/2.0.0.23 Mnenhy/0.7.6.666 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-0.746 tagged_above=-10 required=5 tests=BAYES_00=-1.9, RCVD_NUMERIC_HELO=1.164, T_RP_MATCHES_RCVD=-0.01 X-Spam-Level: X-Archive-Number: 201010/137 X-Sequence-Number: 21105 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