pg.ddx.io pgsql-jdbc@postgresql.org mailing list archive
help / color / mirror / Atom feedBug with DatabaseMetaData and temporary tables/schemas
6+ messages / 3 participants
[nested] [flat]
* Bug with DatabaseMetaData and temporary tables/schemas
@ 2010-11-05 19:16 Thomas Kellerer <spam_eater@gmx.net>
2010-11-06 23:52 ` Re: Bug with DatabaseMetaData and temporary tables/schemas Kris Jurka <books@ejurka.com>
0 siblings, 1 reply; 6+ messages in thread
From: Thomas Kellerer @ 2010-11-05 19:16 UTC (permalink / raw)
To: 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
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: Bug with DatabaseMetaData and temporary tables/schemas
2010-11-05 19:16 Bug with DatabaseMetaData and temporary tables/schemas Thomas Kellerer <spam_eater@gmx.net>
@ 2010-11-06 23:52 ` Kris Jurka <books@ejurka.com>
2010-11-07 01:02 ` Re: Bug with DatabaseMetaData and temporary tables/schemas Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 1 reply; 6+ messages in thread
From: Kris Jurka @ 2010-11-06 23:52 UTC (permalink / raw)
To: Thomas Kellerer <spam_eater@gmx.net>; +Cc: pgsql-jdbc
On Fri, 5 Nov 2010, Thomas Kellerer wrote:
> DatabaseMetaData does not correctly report the implicitely created temporary
> schema when creating a temporary table.
getSchemas is trying to help by not showing you tables that you cannot
access in other backends' temp schemas. It's not quite smart enough
though. It's not filtering the toast schemas and it isn't allowing you to
see your own temp schema.
It looks like psql will show you your own temp schema and all of the
temp toast schemas. So that could potentially be improved as well.
I'll take a look at making getSchemas a little more consistent.
Kris Jurka
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: Bug with DatabaseMetaData and temporary tables/schemas
2010-11-05 19:16 Bug with DatabaseMetaData and temporary tables/schemas Thomas Kellerer <spam_eater@gmx.net>
2010-11-06 23:52 ` Re: Bug with DatabaseMetaData and temporary tables/schemas Kris Jurka <books@ejurka.com>
@ 2010-11-07 01:02 ` Tom Lane <tgl@sss.pgh.pa.us>
2010-11-07 08:43 ` Re: Bug with DatabaseMetaData and temporary tables/schemas Thomas Kellerer <spam_eater@gmx.net>
0 siblings, 1 reply; 6+ messages in thread
From: Tom Lane @ 2010-11-07 01:02 UTC (permalink / raw)
To: Kris Jurka <books@ejurka.com>; +Cc: Thomas Kellerer <spam_eater@gmx.net>; pgsql-jdbc
Kris Jurka <books@ejurka.com> writes:
> It looks like psql will show you your own temp schema and all of the
> temp toast schemas. So that could potentially be improved as well.
Yeah, there was some discussion of that just recently:
http://archives.postgresql.org/message-id/16710.1284837096@sss.pgh.pa.us
I haven't got round to making that change yet, but maybe now is a
good time. The consensus seemed to be that \dn (without S) should
not show any pg_XXX schemas, nor information_schema. Not sure that
that's appropriate for getSchemas though --- an API intended for
programs should maybe just hide the temp and toast schemas.
regards, tom lane
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: Bug with DatabaseMetaData and temporary tables/schemas
2010-11-05 19:16 Bug with DatabaseMetaData and temporary tables/schemas Thomas Kellerer <spam_eater@gmx.net>
2010-11-06 23:52 ` Re: Bug with DatabaseMetaData and temporary tables/schemas Kris Jurka <books@ejurka.com>
2010-11-07 01:02 ` Re: Bug with DatabaseMetaData and temporary tables/schemas Tom Lane <tgl@sss.pgh.pa.us>
@ 2010-11-07 08:43 ` Thomas Kellerer <spam_eater@gmx.net>
2010-12-22 17:01 ` Re: Bug with DatabaseMetaData and temporary tables/schemas Kris Jurka <books@ejurka.com>
0 siblings, 1 reply; 6+ messages in thread
From: Thomas Kellerer @ 2010-11-07 08:43 UTC (permalink / raw)
To: pgsql-jdbc
Tom Lane wrote on 07.11.2010 02:02:
> Kris Jurka<books@ejurka.com> writes:
>> It looks like psql will show you your own temp schema and all of the
>> temp toast schemas. So that could potentially be improved as well.
>
> Yeah, there was some discussion of that just recently:
> http://archives.postgresql.org/message-id/16710.1284837096@sss.pgh.pa.us
>
> I haven't got round to making that change yet, but maybe now is a
> good time. The consensus seemed to be that \dn (without S) should
> not show any pg_XXX schemas, nor information_schema. Not sure that
> that's appropriate for getSchemas though --- an API intended for
> programs should maybe just hide the temp and toast schemas.
>
Well it should at least show "my" temp schemas.
Or getColumns() and getTables() should be smart enough to return information about temp tables without having to specify the temp schema.
Regards
Thomas
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: Bug with DatabaseMetaData and temporary tables/schemas
2010-11-05 19:16 Bug with DatabaseMetaData and temporary tables/schemas Thomas Kellerer <spam_eater@gmx.net>
2010-11-06 23:52 ` Re: Bug with DatabaseMetaData and temporary tables/schemas Kris Jurka <books@ejurka.com>
2010-11-07 01:02 ` Re: Bug with DatabaseMetaData and temporary tables/schemas Tom Lane <tgl@sss.pgh.pa.us>
2010-11-07 08:43 ` Re: Bug with DatabaseMetaData and temporary tables/schemas Thomas Kellerer <spam_eater@gmx.net>
@ 2010-12-22 17:01 ` Kris Jurka <books@ejurka.com>
2010-12-22 17:14 ` Re: Bug with DatabaseMetaData and temporary tables/schemas Thomas Kellerer <spam_eater@gmx.net>
0 siblings, 1 reply; 6+ messages in thread
From: Kris Jurka @ 2010-12-22 17:01 UTC (permalink / raw)
To: Thomas Kellerer <spam_eater@gmx.net>; +Cc: pgsql-jdbc
On Sun, 7 Nov 2010, Thomas Kellerer wrote:
> Tom Lane wrote on 07.11.2010 02:02:
>> Kris Jurka<books@ejurka.com> writes:
>>> It looks like psql will show you your own temp schema and all of the
>>> temp toast schemas. So that could potentially be improved as well.
>>
>> Yeah, there was some discussion of that just recently:
>> http://archives.postgresql.org/message-id/16710.1284837096@sss.pgh.pa.us
>>
>> I haven't got round to making that change yet, but maybe now is a
>> good time. The consensus seemed to be that \dn (without S) should
>> not show any pg_XXX schemas, nor information_schema. Not sure that
>> that's appropriate for getSchemas though --- an API intended for
>> programs should maybe just hide the temp and toast schemas.
>>
>
> Well it should at least show "my" temp schemas.
I've applied a patch to fix this. The driver will now show your own temp
schema and toast temp schema, but no other temp schemas (toast or
otherwise).
> Or getColumns() and getTables() should be smart enough to return information
> about temp tables without having to specify the temp schema.
I'm not sure what you are referring to here. You can certainly leave the
schema blank and it should work.
Kris Jurka
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: Bug with DatabaseMetaData and temporary tables/schemas
2010-11-05 19:16 Bug with DatabaseMetaData and temporary tables/schemas Thomas Kellerer <spam_eater@gmx.net>
2010-11-06 23:52 ` Re: Bug with DatabaseMetaData and temporary tables/schemas Kris Jurka <books@ejurka.com>
2010-11-07 01:02 ` Re: Bug with DatabaseMetaData and temporary tables/schemas Tom Lane <tgl@sss.pgh.pa.us>
2010-11-07 08:43 ` Re: Bug with DatabaseMetaData and temporary tables/schemas Thomas Kellerer <spam_eater@gmx.net>
2010-12-22 17:01 ` Re: Bug with DatabaseMetaData and temporary tables/schemas Kris Jurka <books@ejurka.com>
@ 2010-12-22 17:14 ` Thomas Kellerer <spam_eater@gmx.net>
0 siblings, 0 replies; 6+ messages in thread
From: Thomas Kellerer @ 2010-12-22 17:14 UTC (permalink / raw)
To: pgsql-jdbc
Kris Jurka wrote on 22.12.2010 18:01:
> I've applied a patch to fix this. The driver will now show your own
> temp schema and toast temp schema, but no other temp schemas (toast
> or otherwise).
Great! Thanks a lot
>> Or getColumns() and getTables() should be smart enough to return
>> information about temp tables without having to specify the temp
>> schema.
>
> I'm not sure what you are referring to here. You can certainly leave
> the schema blank and it should work.
You are right it does when leaving the schema blank
Regards
Thomas
^ permalink raw reply [nested|flat] 6+ messages in thread
end of thread, other threads:[~2010-12-22 17:14 UTC | newest]
Thread overview: 6+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2010-11-05 19:16 Bug with DatabaseMetaData and temporary tables/schemas Thomas Kellerer <spam_eater@gmx.net>
2010-11-06 23:52 ` Kris Jurka <books@ejurka.com>
2010-11-07 01:02 ` Tom Lane <tgl@sss.pgh.pa.us>
2010-11-07 08:43 ` Thomas Kellerer <spam_eater@gmx.net>
2010-12-22 17:01 ` Kris Jurka <books@ejurka.com>
2010-12-22 17:14 ` Thomas Kellerer <spam_eater@gmx.net>
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