Skip to content

Commit

Permalink
In DatabaseMetaData.getSchemas, return the user's own temp schemas,
Browse files Browse the repository at this point in the history
but no others.  Previously it wasn't returning the users own temp
schema, but was showing all toast temp schemas.

Per report from Thomas Kellerer.
  • Loading branch information
kjurka committed Dec 22, 2010
1 parent 1c4f1a6 commit 8cc0f77
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
6 changes: 4 additions & 2 deletions org/postgresql/jdbc2/AbstractJdbc2DatabaseMetaData.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Copyright (c) 2004-2008, PostgreSQL Global Development Group
*
* IDENTIFICATION
* $PostgreSQL: pgjdbc/org/postgresql/jdbc2/AbstractJdbc2DatabaseMetaData.java,v 1.44.2.4 2010/05/01 16:52:28 jurka Exp $
* $PostgreSQL: pgjdbc/org/postgresql/jdbc2/AbstractJdbc2DatabaseMetaData.java,v 1.44.2.5 2010/10/16 00:39:27 jurka Exp $
*
*-------------------------------------------------------------------------
*/
Expand Down Expand Up @@ -2145,9 +2145,11 @@ else if (connection.haveMinimumServerVersion("7.1"))
public java.sql.ResultSet getSchemas() throws SQLException
{
String sql;
// Show only the users temp schemas, but not other peoples
// because they can't access any objects in them.
if (connection.haveMinimumServerVersion("7.3"))
{
sql = "SELECT nspname AS TABLE_SCHEM FROM pg_catalog.pg_namespace WHERE nspname <> 'pg_toast' AND nspname !~ '^pg_temp_' ORDER BY TABLE_SCHEM";
sql = "SELECT nspname AS TABLE_SCHEM FROM pg_catalog.pg_namespace WHERE nspname <> 'pg_toast' AND (nspname !~ '^pg_temp_' OR nspname = (pg_catalog.current_schemas(true))[1]) AND (nspname !~ '^pg_toast_temp_' OR nspname = replace((pg_catalog.current_schemas(true))[1], 'pg_temp_', 'pg_toast_temp_')) ORDER BY TABLE_SCHEM";
}
else
{
Expand Down
5 changes: 1 addition & 4 deletions org/postgresql/test/jdbc2/DatabaseMetaDataTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Copyright (c) 2004-2008, PostgreSQL Global Development Group
*
* IDENTIFICATION
* $PostgreSQL: pgjdbc/org/postgresql/test/jdbc2/DatabaseMetaDataTest.java,v 1.41.2.1 2008/11/07 09:11:49 jurka Exp $
* $PostgreSQL: pgjdbc/org/postgresql/test/jdbc2/DatabaseMetaDataTest.java,v 1.41.2.2 2010/10/16 00:39:27 jurka Exp $
*
*-------------------------------------------------------------------------
*/
Expand Down Expand Up @@ -613,9 +613,6 @@ public void testCatalogs() throws SQLException

public void testSchemas() throws Exception
{
if (!TestUtil.haveMinimumServerVersion(con, "7.3"))
return ;

DatabaseMetaData dbmd = con.getMetaData();
assertNotNull(dbmd);

Expand Down

0 comments on commit 8cc0f77

Please sign in to comment.