Skip site navigation (1) Skip section navigation (2)

Bug with DatabaseMetaData and temporary tables/schemas

From: Thomas Kellerer <spam_eater(at)gmx(dot)net>
To: pgsql-jdbc(at)postgresql(dot)org
Subject: Bug with DatabaseMetaData and temporary tables/schemas
Date: 2010-11-05 19:16:26
Message-ID: ib1l67$e22$1@dough.gmane.org (view raw or flat)
Thread:
Lists: 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


Responses

pgsql-jdbc by date

Next:From: Kris JurkaDate: 2010-11-06 23:52:44
Subject: Re: Bug with DatabaseMetaData and temporary tables/schemas
Previous:From: Perepelkin AndrewDate: 2010-11-03 07:08:31
Subject: Re: Invalid Column Length

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group