aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBarry Lind <barry@xythos.com>2002-11-11 07:11:12 +0000
committerBarry Lind <barry@xythos.com>2002-11-11 07:11:12 +0000
commit5ec61f4d2b129d6630d1c72058b3d381cbf21cbc (patch)
tree4b3dd6e1601e273b5602ce421c6e9d800fa3a567 /src
parentad18b10181d4b70efc61cb9c5cf519e1fc11551b (diff)
downloadpostgresql-5ec61f4d2b129d6630d1c72058b3d381cbf21cbc.tar.gz
postgresql-5ec61f4d2b129d6630d1c72058b3d381cbf21cbc.zip
Fixes bug where join to pg_description was incorrect. Also modifies the
regression test to test for this case. Patch submitted by Kris Jurka. Modified Files: jdbc/org/postgresql/jdbc1/AbstractJdbc1DatabaseMetaData.java jdbc/org/postgresql/test/jdbc2/DatabaseMetaDataTest.java
Diffstat (limited to 'src')
-rw-r--r--src/interfaces/jdbc/org/postgresql/jdbc1/AbstractJdbc1DatabaseMetaData.java4
-rw-r--r--src/interfaces/jdbc/org/postgresql/test/jdbc2/DatabaseMetaDataTest.java11
2 files changed, 11 insertions, 4 deletions
diff --git a/src/interfaces/jdbc/org/postgresql/jdbc1/AbstractJdbc1DatabaseMetaData.java b/src/interfaces/jdbc/org/postgresql/jdbc1/AbstractJdbc1DatabaseMetaData.java
index 2fd1a2bd8e5..2cae56e6620 100644
--- a/src/interfaces/jdbc/org/postgresql/jdbc1/AbstractJdbc1DatabaseMetaData.java
+++ b/src/interfaces/jdbc/org/postgresql/jdbc1/AbstractJdbc1DatabaseMetaData.java
@@ -1988,7 +1988,7 @@ public abstract class AbstractJdbc1DatabaseMetaData
" END "+
" AS TABLE_TYPE, d.description AS REMARKS "+
" FROM pg_catalog.pg_namespace n, pg_catalog.pg_class c "+
- " LEFT JOIN pg_catalog.pg_description d ON (c.oid = d.objoid) "+
+ " 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') "+
" LEFT JOIN pg_catalog.pg_namespace dn ON (dn.oid=dc.relnamespace AND dn.nspname='pg_catalog') "+
" WHERE c.relnamespace = n.oid ";
@@ -2038,7 +2038,7 @@ public abstract class AbstractJdbc1DatabaseMetaData
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 "+
" FROM pg_class c "+
- " LEFT JOIN pg_description d ON (c.oid=d.objoid) "+
+ " 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') "+
" WHERE true ";
} else {
diff --git a/src/interfaces/jdbc/org/postgresql/test/jdbc2/DatabaseMetaDataTest.java b/src/interfaces/jdbc/org/postgresql/test/jdbc2/DatabaseMetaDataTest.java
index 4c46509c7c1..9ee4c0ab50c 100644
--- a/src/interfaces/jdbc/org/postgresql/test/jdbc2/DatabaseMetaDataTest.java
+++ b/src/interfaces/jdbc/org/postgresql/test/jdbc2/DatabaseMetaDataTest.java
@@ -9,7 +9,7 @@ import java.sql.*;
*
* PS: Do you know how difficult it is to type on a train? ;-)
*
- * $Id: DatabaseMetaDataTest.java,v 1.15 2002/10/01 00:39:02 davec Exp $
+ * $Id: DatabaseMetaDataTest.java,v 1.16 2002/11/11 07:11:12 barry Exp $
*/
public class DatabaseMetaDataTest extends TestCase
@@ -28,6 +28,11 @@ public class DatabaseMetaDataTest extends TestCase
{
con = TestUtil.openDB();
TestUtil.createTable( con, "testmetadata", "id int4, name text, updated timestamp" );
+ Statement stmt = con.createStatement();
+ //we add the following comments to ensure the joins to the comments
+ //are done correctly. This ensures we correctly test that case.
+ stmt.execute("comment on table testmetadata is 'this is a table comment'");
+ stmt.execute("comment on column testmetadata.id is 'this is a column comment'");
}
protected void tearDown() throws Exception
{
@@ -44,12 +49,14 @@ public class DatabaseMetaDataTest extends TestCase
DatabaseMetaData dbmd = con.getMetaData();
assertNotNull(dbmd);
- ResultSet rs = dbmd.getTables( null, null, "test%", new String[] {"TABLE"});
+ ResultSet rs = dbmd.getTables( null, null, "testmetadat%", new String[] {"TABLE"});
assertTrue( rs.next() );
String tableName = rs.getString("TABLE_NAME");
assertTrue( tableName.equals("testmetadata") );
String tableType = rs.getString("TABLE_TYPE");
assertTrue( tableType.equals("TABLE") );
+ //There should only be one row returned
+ assertTrue( "getTables() returned too many rows", rs.next() == false);
rs.close();
rs = dbmd.getColumns("", "", "test%", "%" );