A bug fix for JDBC's getTables() in Postgresql 7.1

From: Panu Outinen <panu(at)vertex(dot)fi>
To: pgsql-jdbc(at)postgresql(dot)org
Subject: A bug fix for JDBC's getTables() in Postgresql 7.1
Date: 2001-05-03 15:32:28
Message-ID: 5.0.2.1.0.20010503181640.04b845e0@vertex.fi
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-jdbc

Hi !!

I was trying to get a very nice FREE graphical db tool called DbVisualizer
(http://www.ideit.com/products/dbvis/) to work with Postgresql and I found
out the following bug: if database has views then getTables() gets the null
pointer exception ('order by relname' makes the listing tree in
DbVisualizer a lot useful !!)

This patch should propably be applied to the the jdbc1's
DatabaseMetaData.java, too.

[/tmp/postgresql-7.1/src/interfaces/jdbc/org/postgresql/jdbc2]$
<ql/jdbc2]$ diff -u DatabaseMetaData.java.org DatabaseMetaData.java

--- DatabaseMetaData.java.org Wed May 02 22:52:25 2001
+++ DatabaseMetaData.java Wed May 02 23:07:19 2001
@@ -1666,7 +1666,7 @@
// Now take the pattern into account
sql.append(") and relname like '");
sql.append(tableNamePattern.toLowerCase());
- sql.append("'");
+ sql.append("' order by relname");

// Now run the query
r = connection.ExecSQL(sql.toString());
@@ -1697,6 +1697,9 @@
case 'S':
relKind = "SEQUENCE";
break;
+ case 'v':
+ relKind = "VIEW";
+ break;
default:
relKind = null;
}
@@ -1704,7 +1707,7 @@
tuple[0] = null; // Catalog name
tuple[1] = null; // Schema name
tuple[2] = r.getBytes(1); // Table name
- tuple[3] = relKind.getBytes(); // Table type
+ tuple[3] = (relKind==null) ? null : relKind.getBytes(); // Table type
tuple[4] = remarks; // Remarks
v.addElement(tuple);
}

-----
http://www.ideit.com/products/dbvis/

...

DbVisualizer
Version: 2.0
Released: 2001-04-20

The #1 requested feature to ease editing table data is now supported!
The #2 requested feature to print graphs is now supported!
Read the complete change log for all new features and enhancements!

DbVisualizer is a cross platform database visualization and edit tool
relying 100% on the JDBC, Java Database Connectivity API's. DbVisualizer
enables simultaneous connections to many different databases through JDBC
drivers available from a variety of vendors. Just point and click to browse
the structure of the database, characteristics of tables, etc. No matter if
it's an enterprise database from Oracle or an open source product like
InstantDB!

And best of all -> it's FREE!
-----

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2001-05-03 15:32:45 Re: A problem with pg_dump?
Previous Message Alessio Bragadini 2001-05-03 15:19:59 Re: A problem with pg_dump?

Browse pgsql-jdbc by date

  From Date Subject
Next Message Seth Milder 2001-05-03 15:39:13 accessing arrays
Previous Message Marko Kreen 2001-05-03 13:54:05 Re: JDBC driver in pgsql 7.1 build problem