Bug: enum types in schema other than public and Connection.createArrayOf

From: Hans Klett <hansk(at)spectralogic(dot)com>
To: "pgsql-jdbc(at)postgresql(dot)org" <pgsql-jdbc(at)postgresql(dot)org>
Subject: Bug: enum types in schema other than public and Connection.createArrayOf
Date: 2014-09-30 00:02:31
Message-ID: C4746C300EA2D34FAF7805BBA5F4F5F9919A80F6@reactor.sldomain.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

Hello,

I found an issue with Connection.createArrayOf() when using qualified
enum type names. It doesn't like the qualified type name, and when you
give it the unqualified type name it just picks an enum type even if it's not
in the public schema. If the enum type name exists in multiple schemas it just
picks one, seemingly at random.

For instance, in database foo:
CREATE SCHEMA bar;
CREATE SCHEMA baz;
CREATE TYPE bar.mood AS ENUM ('happy', 'sad');
CREATE TYPE baz.mood AS ENUM ('grumpy', 'sassy');

Java:
final Properties props = new Properties();
props.setProperty("user", "postgres");
props.setProperty("password", "postgres");
try (final Connection conn = DriverManager.getConnection("jdbc:postgresql:foo", props)) {
final String[] strings = { "sad", "happy" };

// Works, but picks either baz.mood or bar.mood.
// I haven't figured out how it picks which one to use.
conn.createArrayOf("mood", strings);

// Throws org.postgresql.util.PSQLException:
// Unable to find server array type for provided name bar.mood
conn.createArrayOf("bar.mood", strings);
}

Thanks!
- Hans

Browse pgsql-jdbc by date

  From Date Subject
Next Message cowwoc 2014-09-30 01:32:50 Why is version 9.3-1102 missing Connection.getSchema() support?
Previous Message Alexis Meneses 2014-09-24 06:38:39 Re: Patch to allow setting schema/search_path in the connectionURL