mirror of
https://github.com/postgres/postgres.git
synced 2025-05-02 11:44:50 +03:00
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
This commit is contained in:
parent
ad18b10181
commit
5ec61f4d2b
@ -1988,7 +1988,7 @@ public abstract class AbstractJdbc1DatabaseMetaData
|
|||||||
" END "+
|
" END "+
|
||||||
" AS TABLE_TYPE, d.description AS REMARKS "+
|
" AS TABLE_TYPE, d.description AS REMARKS "+
|
||||||
" FROM pg_catalog.pg_namespace n, pg_catalog.pg_class c "+
|
" 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_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') "+
|
" LEFT JOIN pg_catalog.pg_namespace dn ON (dn.oid=dc.relnamespace AND dn.nspname='pg_catalog') "+
|
||||||
" WHERE c.relnamespace = n.oid ";
|
" WHERE c.relnamespace = n.oid ";
|
||||||
@ -2038,7 +2038,7 @@ public abstract class AbstractJdbc1DatabaseMetaData
|
|||||||
if (connection.haveMinimumServerVersion("7.1")) {
|
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 "+
|
||||||
" FROM pg_class c "+
|
" 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') "+
|
" LEFT JOIN pg_class dc ON (d.classoid = dc.oid AND dc.relname='pg_class') "+
|
||||||
" WHERE true ";
|
" WHERE true ";
|
||||||
} else {
|
} else {
|
||||||
|
@ -9,7 +9,7 @@ import java.sql.*;
|
|||||||
*
|
*
|
||||||
* PS: Do you know how difficult it is to type on a train? ;-)
|
* 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
|
public class DatabaseMetaDataTest extends TestCase
|
||||||
@ -28,6 +28,11 @@ public class DatabaseMetaDataTest extends TestCase
|
|||||||
{
|
{
|
||||||
con = TestUtil.openDB();
|
con = TestUtil.openDB();
|
||||||
TestUtil.createTable( con, "testmetadata", "id int4, name text, updated timestamp" );
|
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
|
protected void tearDown() throws Exception
|
||||||
{
|
{
|
||||||
@ -44,12 +49,14 @@ public class DatabaseMetaDataTest extends TestCase
|
|||||||
DatabaseMetaData dbmd = con.getMetaData();
|
DatabaseMetaData dbmd = con.getMetaData();
|
||||||
assertNotNull(dbmd);
|
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() );
|
assertTrue( rs.next() );
|
||||||
String tableName = rs.getString("TABLE_NAME");
|
String tableName = rs.getString("TABLE_NAME");
|
||||||
assertTrue( tableName.equals("testmetadata") );
|
assertTrue( tableName.equals("testmetadata") );
|
||||||
String tableType = rs.getString("TABLE_TYPE");
|
String tableType = rs.getString("TABLE_TYPE");
|
||||||
assertTrue( tableType.equals("TABLE") );
|
assertTrue( tableType.equals("TABLE") );
|
||||||
|
//There should only be one row returned
|
||||||
|
assertTrue( "getTables() returned too many rows", rs.next() == false);
|
||||||
rs.close();
|
rs.close();
|
||||||
|
|
||||||
rs = dbmd.getColumns("", "", "test%", "%" );
|
rs = dbmd.getColumns("", "", "test%", "%" );
|
||||||
|
Loading…
x
Reference in New Issue
Block a user