X-Original-To: pgsql-jdbc-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by postgresql.org (Postfix) with ESMTP id E881511F6602 for ; Tue, 18 Apr 2006 12:22:12 -0300 (ADT) X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Score: 1.332 X-Spam-Level: * X-Spam-Status: No, score=1.332 required=5 tests=[RCVD_IN_BL_SPAMCOP_NET=1.332, UPPERCASE_25_50=0] Received: from postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id Zsa34v8SyB01 for ; Tue, 18 Apr 2006 12:21:46 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey- Received: from nproxy.gmail.com (nproxy.gmail.com [64.233.182.190]) by postgresql.org (Postfix) with ESMTP id 8687211F6C6B for ; Tue, 18 Apr 2006 12:21:46 -0300 (ADT) Received: by nproxy.gmail.com with SMTP id p77so626017nfc for ; Tue, 18 Apr 2006 08:21:45 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:user-agent:x-accept-language:mime-version:to:subject:x-enigmail-version:content-type:sender; b=Sl8k8/f3NijxfKV2VmUasruPJZim8Hitqfif3UIcXkeQg+7Cyj95GXWIEk7M3xc3ZOa7ddsJ30arCyk/Tp9n2FUXiwm4dBKpI31m5n4fwTArhHADebqtXf4Gd/hh1QrGbv8MICF8ZjFZQnq6XirPazvIzlEhNsZbj9TxV5zPdDw= Received: by 10.49.54.8 with SMTP id g8mr739059nfk; Tue, 18 Apr 2006 08:21:44 -0700 (PDT) Received: from ?192.168.0.128? ( [80.65.224.34]) by mx.gmail.com with ESMTP id c1sm1226474nfe.2006.04.18.08.21.43; Tue, 18 Apr 2006 08:21:44 -0700 (PDT) Message-ID: <444503FB.30204@free.fr> Date: Tue, 18 Apr 2006 17:21:31 +0200 From: "Xavier Poinsard" User-Agent: Mozilla Thunderbird 1.0.7 (X11/20051013) X-Accept-Language: fr, en MIME-Version: 1.0 To: pgsql-jdbc@postgresql.org Subject: Patch adding empty missing columns for getTables X-Enigmail-Version: 0.92.1.0 Content-Type: multipart/mixed; boundary="------------050702040605030105090703" X-Archive-Number: 200604/129 X-Sequence-Number: 15063 This is a multi-part message in MIME format. --------------050702040605030105090703 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Hi, The attached patch add empty columns to the resultset returned by AbstractJdbc2MetaData.getTables(). According to JAVA 1.5 javadoc, it should return 10 columns and we are currently returning only 5. Maybe someone familiar with the system tables could modify the query to return the expected values. With this patch, at least (and it is allowed) null columns are returned and we don't get array indices exceptions. Xavier Poinsard. --------------050702040605030105090703 Content-Type: text/plain; name="getTables.diff" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="getTables.diff" Index: jdbc2/AbstractJdbc2DatabaseMetaData.java =================================================================== RCS file: /usr/local/cvsroot/pgjdbc/pgjdbc/org/postgresql/jdbc2/AbstractJdbc2DatabaseMetaData.java,v retrieving revision 1.30 diff -u -r1.30 AbstractJdbc2DatabaseMetaData.java --- jdbc2/AbstractJdbc2DatabaseMetaData.java 27 Mar 2006 12:07:57 -0000 1.30 +++ jdbc2/AbstractJdbc2DatabaseMetaData.java 18 Apr 2006 15:10:46 -0000 @@ -1853,6 +1853,14 @@ * "VIEW", "SYSTEM TABLE", "GLOBAL TEMPORARY", "LOCAL * TEMPORARY", "ALIAS", "SYNONYM". *
  • REMARKS String => explanatory comment on the table + *
  • TYPE_CAT String => the types catalog (may be null) + *
  • TYPE_SCHEM String => the types schema (may be null) + *
  • TYPE_NAME String => type name (may be null) + *
  • SELF_REFERENCING_COL_NAME String => name of the designated + * "identifier" column of a typed table (may be null) + *
  • REF_GENERATION String => specifies how values in + * SELF_REFERENCING_COL_NAME are created. Values are + * "SYSTEM", "USER", "DERIVED". (may be null) * * *

    The valid values for the types parameter are: @@ -1907,7 +1915,9 @@ " END " + " ELSE NULL " + " END " + - " AS TABLE_TYPE, d.description AS REMARKS " + + " AS TABLE_TYPE, d.description AS REMARKS, " + + " NULL AS TYPE_CAT, NULL AS TYPE_SCHEM, NULL AS TYPE_NAME," + + " NULL AS SELF_REFERENCING_COL_NAME, NULL AS REF_GENERATION " + " FROM pg_catalog.pg_namespace n, pg_catalog.pg_class c " + " LEFT JOIN pg_catalog.pg_description d ON (c.oid = d.objoid AND d.objsubid = 0) " + " LEFT JOIN pg_catalog.pg_class dc ON (d.classoid=dc.oid AND dc.relname='pg_class') " + @@ -1958,7 +1968,9 @@ orderby = " ORDER BY TABLE_TYPE,TABLE_NAME "; if (connection.haveMinimumServerVersion("7.2")) { - select = "SELECT NULL AS TABLE_CAT, NULL AS TABLE_SCHEM, c.relname AS TABLE_NAME, " + tableType + " AS TABLE_TYPE, d.description AS REMARKS " + + select = "SELECT NULL AS TABLE_CAT, NULL AS TABLE_SCHEM, c.relname AS TABLE_NAME, " + tableType + " AS TABLE_TYPE, d.description AS REMARKS , " + + " NULL AS TYPE_CAT, NULL AS TYPE_SCHEM, NULL AS TYPE_NAME," + + " NULL AS SELF_REFERENCING_COL_NAME, NULL AS REF_GENERATION " + " FROM pg_class c " + " LEFT JOIN pg_description d ON (c.oid=d.objoid AND d.objsubid = 0) " + " LEFT JOIN pg_class dc ON (d.classoid = dc.oid AND dc.relname='pg_class') " + @@ -1966,14 +1978,18 @@ } else if (connection.haveMinimumServerVersion("7.1")) { - select = "SELECT NULL AS TABLE_CAT, NULL AS TABLE_SCHEM, c.relname AS TABLE_NAME, " + tableType + " AS TABLE_TYPE, d.description AS REMARKS " + + select = "SELECT NULL AS TABLE_CAT, NULL AS TABLE_SCHEM, c.relname AS TABLE_NAME, " + tableType + " AS TABLE_TYPE, d.description AS REMARKS , " + + " NULL AS TYPE_CAT, NULL AS TYPE_SCHEM, NULL AS TYPE_NAME," + + " NULL AS SELF_REFERENCING_COL_NAME, NULL AS REF_GENERATION " + " FROM pg_class c " + " LEFT JOIN pg_description d ON (c.oid=d.objoid) " + " WHERE true "; } else { - select = "SELECT NULL AS TABLE_CAT, NULL AS TABLE_SCHEM, c.relname AS TABLE_NAME, " + tableType + " AS TABLE_TYPE, NULL AS REMARKS " + + select = "SELECT NULL AS TABLE_CAT, NULL AS TABLE_SCHEM, c.relname AS TABLE_NAME, " + tableType + " AS TABLE_TYPE, NULL AS REMARKS , " + + " NULL AS TYPE_CAT, NULL AS TYPE_SCHEM, NULL AS TYPE_NAME," + + " NULL AS SELF_REFERENCING_COL_NAME, NULL AS REF_GENERATION " + " FROM pg_class c " + " WHERE true "; } Index: test/jdbc2/DatabaseMetaDataTest.java =================================================================== RCS file: /usr/local/cvsroot/pgjdbc/pgjdbc/org/postgresql/test/jdbc2/DatabaseMetaDataTest.java,v retrieving revision 1.36 diff -u -r1.36 DatabaseMetaDataTest.java --- test/jdbc2/DatabaseMetaDataTest.java 3 Feb 2006 21:10:15 -0000 1.36 +++ test/jdbc2/DatabaseMetaDataTest.java 18 Apr 2006 15:10:46 -0000 @@ -69,6 +69,8 @@ assertEquals( "testmetadata", tableName ); String tableType = rs.getString("TABLE_TYPE"); assertEquals( "TABLE", tableType ); + // at least 10 columns + assertTrue("getTables() doesn't return enough columns",rs.getMetaData().getColumnCount()>=10); //There should only be one row returned assertTrue( "getTables() returned too many rows", rs.next() == false); rs.close(); --------------050702040605030105090703--