Bug with DatabaseMetaData and temporary tables/schemas - Mailing list pgsql-jdbc

From Thomas Kellerer
Subject Bug with DatabaseMetaData and temporary tables/schemas
Date
Msg-id ib1l67$e22$1@dough.gmane.org
Whole thread Raw
Responses Re: Bug with DatabaseMetaData and temporary tables/schemas
List pgsql-jdbc
Hi,

DatabaseMetaData does not correctly report the implicitely created temporary schema when creating a temporary table.

I ran the following code using a 9.0.1 database on Windows XP, with the postgresql-9.0-801.jdbc4.jar driver:

rs = con.getMetaData().getSchemas();
System.out.println("before create table: ");
while (rs.next())
{
    System.out.println("schema: " + rs.getString(1));
}
rs.close();

stmt = con.createStatement();
stmt.execute("create temporary table foo (id integer)");
System.out.println("after create table: ");
rs = con.getMetaData().getSchemas();
while (rs.next())
{
    System.out.println("schema: " + rs.getString(1));
}
rs.close();

rs = stmt.executeQuery("select nspname from pg_namespace");
while (rs.next())
{
    System.out.println("schema from pg_namespace: " + rs.getString(1));
}
rs.close();

On an otherwise empty database this produces the following output:

before create table:
schema: information_schema
schema: pg_catalog
schema: pg_toast_temp_1
schema: pg_toast_temp_2
schema: pg_toast_temp_3
schema: public

after create table:
schema: information_schema
schema: pg_catalog
schema: pg_toast_temp_1
schema: pg_toast_temp_2
schema: pg_toast_temp_3
schema: public

schema from pg_namespace: pg_toast
schema from pg_namespace: pg_temp_1
schema from pg_namespace: pg_toast_temp_1
schema from pg_namespace: pg_catalog
schema from pg_namespace: information_schema
schema from pg_namespace: public
schema from pg_namespace: pg_temp_2
schema from pg_namespace: pg_toast_temp_2
schema from pg_namespace: pg_temp_3
schema from pg_namespace: pg_toast_temp_3

So the pg_temp_X schema(s) are there, but getSchemas() does not return them.

Am I missing something, or is this a bug in the driver?

Regards
Thomas

pgsql-jdbc by date:

Previous
From: Perepelkin Andrew
Date:
Subject: Re: Invalid Column Length
Next
From: Kris Jurka
Date:
Subject: Re: Bug with DatabaseMetaData and temporary tables/schemas