From: Thomas Kellerer <spam_eater@gmx.net>
To: pgsql-jdbc@postgresql.org
Subject: DatabaseMetaData.getTypeInfo() - returns all tables as well
Date: Wed, 30 Sep 2015 21:37:19 +0200
Message-ID: <muhdlg$9c9$1@ger.gmane.org> (raw)
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-jdbc>
Hello,
DatabaseMetaData.getTypeInfo() returns not only data types, but also all table types.
Strictly speaking this is correct as the row type for a table is indeed a "data type" in Postgres,
but I think the information returned is way too much from a practical point of view.
This could be reduced at least a bit by not only excluding pg_toast, but also pg_catalog and information_schema types:
SELECT t.typname,t.oid
FROM pg_catalog.pg_type t
JOIN pg_catalog.pg_namespace n ON (t.typnamespace = n.oid)
WHERE n.nspname not in ('pg_toast', 'pg_catalog', 'information_schema')
(instead of WHERE n.nspname != 'pg_toast' in AbstractJdbc2DatabaseMetaData.java getTypeInfo())
What I find even more confusing (from a JDBC point of view) is that each table type is reported twice:
Once with the table's name and once with an underscore prefixing the table name, e.g. foo and _foo.
These entries map to pg_type rows with typtype = 'c' and 'b' respectively.
I wonder if it would make sense to filter out the "real" tables from this result.
And if it does, if there is an efficient way of doing that and not removing real composite types
from the result at the same time.
Regards
Thomas
--
Sent via pgsql-jdbc mailing list (pgsql-jdbc@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-jdbc
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: DatabaseMetaData.getTypeInfo() - returns all tables as well
In-Reply-To: <muhdlg$9c9$1@ger.gmane.org>
References: <muhdlg$9c9$1@ger.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