Re: TypeInfoCache.getPGType(pgTypeName) drops schema name when caching

From: Vladimir Sitnikov <sitnikov(dot)vladimir(at)gmail(dot)com>
To: Michael Glaesemann <grzm(at)seespotcode(dot)net>, List <pgsql-jdbc(at)postgresql(dot)org>
Subject: Re: TypeInfoCache.getPGType(pgTypeName) drops schema name when caching
Date: 2017-07-16 06:53:51
Message-ID: CAB=Je-EumgtG1m+XcSWMC0AScVs9HkAsUfXBgAwt9meVPFxVeA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

Michael>_pgNameToOid.put(schema + "." + name, oid)
Michael>I think it makes sense to follow this behavior in
getPGType(pgTypeName).

The idea of type cache is to avoid pg_catalog SQLs on the hot path.
Consider a user issuing `createArrayOf`. Do you mean pgjdbc should query
the catalog on each invocation of createArrayOf? I'm not sure it would be
the right thing, as it is basically the only way to create arrays.

Theoretically, there's java.sql.SQLType (since Java 1.8), however I don't
thing 1.8-specific APIs (e.g. implementing TypeCache via
Map<java.sql.SQLType, ...>) would be a good idea at this point.

Michael>search path. This results in the cache returning unqualified type

I think that is a separate issue and we might handle "search path" changes
by flushing the cache of user-provided names.

"search path change detector" has already been implemented (see
https://github.com/pgjdbc/pgjdbc/blob/a7e0c83be93600c6299ae99907942e2530cb5e30/pgjdbc/src/main/java/org/postgresql/core/v3/QueryExecutorImpl.java#L2088-L2096
),
so it makes sense to reuse it and flush type cache accordingly.

Vladimir

In response to

Responses

Browse pgsql-jdbc by date

  From Date Subject
Next Message Michael Glaesemann 2017-07-16 16:06:51 Re: TypeInfoCache.getPGType(pgTypeName) drops schema name when caching
Previous Message Michael Glaesemann 2017-07-15 22:46:39 TypeInfoCache.getPGType(pgTypeName) drops schema name when caching