pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Thomas Kellerer <spam_eater@gmx.net>
To: pgsql-jdbc@postgresql.org
Subject: Bug with DatabaseMetaData and temporary tables/schemas
Date: Fri, 05 Nov 2010 20:16:26 +0100
Message-ID: <ib1l67$e22$1@dough.gmane.org> (raw)

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




view thread (6+ messages)  latest in thread

Message-ID: <ib1l67$e22$1@dough.gmane.org>
Permalink:  ../ib1l67$e22$1@dough.gmane.org/
Also on:    postgresql.org/message-id/ib1l67$e22$1@dough.gmane.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-jdbc@postgresql.org
  Cc: spam_eater@gmx.net
  Subject: Re: Bug with DatabaseMetaData and temporary tables/schemas
  In-Reply-To: <ib1l67$e22$1@dough.gmane.org>
  References: <ib1l67$e22$1@dough.gmane.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox