Thread: DatabaseMetaData.getTables() doesn't sort its result

DatabaseMetaData.getTables() doesn't sort its result

From
Jeroen van Vianen
Date:
Hi,

Here's an easy patch for todays snapshot to sort the result of the

public ResultSet getTables(String catalog, String schemaPattern, String
tableNamePattern, String[] types) throws SQLException

method:

Compare:
(<)J:\postgresql-snapshot\src\interfaces\jdbc\org\postgresql\jdbc2\DatabaseMetaData.java
(89441 bytes)
    with:
(>)J:\postgresql-snapshot\src\interfaces\jdbc\org\postgresql\jdbc2\DatabaseMetaData.java.orig
(89415 bytes)

1669c1669
<     sql.append("' order by relkind, relname");
---
 >     sql.append("'");

This is required by the JDBC spec: It says "They are ordered by TABLE_TYPE,
TABLE_SCHEM and TABLE_NAME."

<newbie>
I was wondering while looking through the code why outer joins are not used
for certain queries, e.g. in the getTables() method to get the comments for
a particular table.
</newbie>


Cheers,


Jeroen


Re: DatabaseMetaData.getTables() doesn't sort its result

From
Bruce Momjian
Date:
Patch applied for 7.2.  Thanks.


> Hi,
>
> Here's an easy patch for todays snapshot to sort the result of the
>
> public ResultSet getTables(String catalog, String schemaPattern, String
> tableNamePattern, String[] types) throws SQLException
>
> method:
>
> Compare:
> (<)J:\postgresql-snapshot\src\interfaces\jdbc\org\postgresql\jdbc2\DatabaseMetaData.java
> (89441 bytes)
>     with:
> (>)J:\postgresql-snapshot\src\interfaces\jdbc\org\postgresql\jdbc2\DatabaseMetaData.java.orig
> (89415 bytes)
>
> 1669c1669
> <     sql.append("' order by relkind, relname");
> ---
>  >     sql.append("'");
>
> This is required by the JDBC spec: It says "They are ordered by TABLE_TYPE,
> TABLE_SCHEM and TABLE_NAME."
>
> <newbie>
> I was wondering while looking through the code why outer joins are not used
> for certain queries, e.g. in the getTables() method to get the comments for
> a particular table.
> </newbie>
>
>
> Cheers,
>
>
> Jeroen
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 6: Have you searched our list archives?
>
> http://www.postgresql.org/search.mpl
>

--
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 853-3000
  +  If your life is a hard drive,     |  830 Blythe Avenue
  +  Christ can be your backup.        |  Drexel Hill, Pennsylvania 19026
Index: src/interfaces/jdbc/org/postgresql/jdbc2/DatabaseMetaData.java
===================================================================
RCS file: /home/projects/pgsql/cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc2/DatabaseMetaData.java,v
retrieving revision 1.16
diff -c -r1.16 DatabaseMetaData.java
*** src/interfaces/jdbc/org/postgresql/jdbc2/DatabaseMetaData.java    2001/05/16 03:40:25    1.16
--- src/interfaces/jdbc/org/postgresql/jdbc2/DatabaseMetaData.java    2001/05/16 03:47:08
***************
*** 1666,1672 ****
      // Now take the pattern into account
      sql.append(") and relname like '");
      sql.append(tableNamePattern.toLowerCase());
!     sql.append("'");

      // Now run the query
      r = connection.ExecSQL(sql.toString());
--- 1666,1672 ----
      // Now take the pattern into account
      sql.append(") and relname like '");
      sql.append(tableNamePattern.toLowerCase());
!     sql.append("' order by relkind, relname");

      // Now run the query
      r = connection.ExecSQL(sql.toString());