[JDBC] TypeInfoCache.getPGType(pgTypeName) drops schema name when caching - Mailing list pgsql-jdbc

From Michael Glaesemann
Subject [JDBC] TypeInfoCache.getPGType(pgTypeName) drops schema name when caching
Date
Msg-id 72F45272-226E-47FC-940F-F5E5FF446222@seespotcode.net
Whole thread Raw
Responses Re: [JDBC] TypeInfoCache.getPGType(pgTypeName) drops schema name when caching  (Vladimir Sitnikov <sitnikov.vladimir@gmail.com>)
Re: TypeInfoCache.getPGType(pgTypeName) drops schema name when caching  (Vladimir Sitnikov <sitnikov.vladimir@gmail.com>)
List pgsql-jdbc
When populating the _oidToPgName and _pgNameToOid caches, TypeInfoCache.getPGType(String pgTypeName) populates
_oidToPgNamewith only pg_type.typname regardless of typnamespace or the search path. This results in the cache
returningunqualified 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
ratherthan 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
usingthose 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
Idescribe above is the root cause of this as well, as TypeInfoCache.getPGArrayType calls getPGType(pgTypeName). 

pgsql-jdbc by date:

Previous
From: Bear Giles
Date:
Subject: Re: [JDBC] SCRAM client vs pgjdbc packaging
Next
From: Vladimir Sitnikov
Date:
Subject: Re: TypeInfoCache.getPGType(pgTypeName) drops schema name when caching