mirror of
				https://github.com/postgres/postgres.git
				synced 2025-11-03 09:13:20 +03:00 
			
		
		
		
	Merge fix from head for proper join to pg_description
Modified Files: Tag: REL7_3_STABLE jdbc/org/postgresql/jdbc1/AbstractJdbc1DatabaseMetaData.java jdbc/org/postgresql/test/jdbc2/DatabaseMetaDataTest.java
This commit is contained in:
		@@ -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 {
 | 
			
		||||
 
 | 
			
		||||
@@ -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.15.2.1 2002/11/11 07:30:08 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%", "%" );
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user