pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Michael Glaesemann <grzm@seespotcode.net>
To: List <pgsql-jdbc@postgresql.org>
Subject: TypeInfoCache.getPGType(pgTypeName) drops schema name when caching
Date: Sat, 15 Jul 2017 17:46:39 -0500
Message-ID: <72F45272-226E-47FC-940F-F5E5FF446222@seespotcode.net> (raw)
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-jdbc>

When populating the _oidToPgName and _pgNameToOid caches, TypeInfoCache.getPGType(String pgTypeName) populates _oidToPgName with only pg_type.typname regardless of typnamespace or the search path. This results in the cache returning unqualified type names in lookups to cached values by getPGType(int oid).

It makes sense to normalize the name, which is presumably what motivates using internalName returned from oidStatement rather than the user-supplied pgTypeName. getPGType(oid) does schema-qualify the name used to populate _oidToPgName:

_pgNameToOid.put(schema + "." + name, oid)

I think it makes sense to follow this behavior in getPGType(pgTypeName). Looking at it briefly,   I wonder if adding "nspname = ANY(current_schemas(true))" and nspname columns to the results of  oidStatement would be sufficient, and using those to construct a normalized qualified type name in the manner of getPGType(oid).

If this makes sense, I'm happy to submit a patch with tests.

Cheers,

Michael Glaesemann
grzm seespotcode net


PS. When looking through open issues to see if this had been reported, I came across https://github.com/pgjdbc/pgjdbc/issues/189 "Connection.createArrayOf() does not handle enums correctly.". I think what I describe above is the root cause of this as well, as TypeInfoCache.getPGArrayType calls getPGType(pgTypeName).

-- 
Sent via pgsql-jdbc mailing list (pgsql-jdbc@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-jdbc



view thread (5+ messages)  latest in thread

Message-ID: <72F45272-226E-47FC-940F-F5E5FF446222@seespotcode.net>
Permalink:  ../72F45272-226E-47FC-940F-F5E5FF446222@seespotcode.net/
Also on:    postgresql.org/message-id/72F45272-226E-47FC-940F-F5E5FF446222@seespotcode.net

 · 

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: grzm@seespotcode.net
  Subject: Re: TypeInfoCache.getPGType(pgTypeName) drops schema name when caching
  In-Reply-To: <72F45272-226E-47FC-940F-F5E5FF446222@seespotcode.net>
  References: <72F45272-226E-47FC-940F-F5E5FF446222@seespotcode.net>

* 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