From: | Michael Glaesemann <grzm(at)seespotcode(dot)net> |
---|---|
To: | List <pgsql-jdbc(at)postgresql(dot)org> |
Subject: | TypeInfoCache.getPGType(pgTypeName) drops schema name when caching |
Date: | 2017-07-15 22:46:39 |
Message-ID: | 72F45272-226E-47FC-940F-F5E5FF446222@seespotcode.net |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-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).
From | Date | Subject | |
---|---|---|---|
Next Message | Vladimir Sitnikov | 2017-07-16 06:53:51 | Re: TypeInfoCache.getPGType(pgTypeName) drops schema name when caching |
Previous Message | Bear Giles | 2017-07-15 17:21:38 | Re: SCRAM client vs pgjdbc packaging |