Thread: type cache info fix
I found that type cache info wasn't honoring search path. (I had a UDT type that shared a name with a table). This fixed it. diff --git a/org/postgresql/jdbc2/TypeInfoCache.java b/org/postgresql/jdbc2/TypeInfoCache.java index 2e79758..2d26fd0 100644 --- a/org/postgresql/jdbc2/TypeInfoCache.java +++ b/org/postgresql/jdbc2/TypeInfoCache.java @@ -234,7 +234,7 @@ public class TypeInfoCache implements TypeInfo { if (_getOidStatement == null) { String sql; if (_conn.haveMinimumServerVersion("7.3")) { - sql = "SELECT oid FROM pg_catalog.pg_type WHERE typname = ?"; + sql = "SELECT ?::regtype::oid"; } else { sql = "SELECT oid FROM pg_type WHERE typname = ?"; }
Hello Gary,
the problem with this change is that it is not backwards compatible. Though the question is, why somebody would like to keep a not deterministic behavior of the current code.
And if you are fixing this, probably it would make sense to fix getSQLType() as well.
Also it can fill your server logs with errors, if the type does not exist, regtype cast will throw an ERROR
I have prepared a little bit different change: https://github.com/pgjdbc/pgjdbc/pull/52
Cheers,
-- Valentine
ვალენტინ გოგიჩაშვილი
Valentine Gogichashvili
Valentine Gogichashvili
On Fri, Mar 29, 2013 at 6:08 PM, Gary Baker <gary.baker@gmail.com> wrote:
I found that type cache info wasn't honoring search path. (I had a
UDT type that shared a name with a table).
This fixed it.
diff --git a/org/postgresql/jdbc2/TypeInfoCache.java
b/org/postgresql/jdbc2/TypeInfoCache.java
index 2e79758..2d26fd0 100644
--- a/org/postgresql/jdbc2/TypeInfoCache.java
+++ b/org/postgresql/jdbc2/TypeInfoCache.java
@@ -234,7 +234,7 @@ public class TypeInfoCache implements TypeInfo {
if (_getOidStatement == null) {
String sql;
if (_conn.haveMinimumServerVersion("7.3")) {
- sql = "SELECT oid FROM pg_catalog.pg_type WHERE typname = ?";
+ sql = "SELECT ?::regtype::oid";
} else {
sql = "SELECT oid FROM pg_type WHERE typname = ?";
}
--
Sent via pgsql-jdbc mailing list (pgsql-jdbc@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-jdbc
Valentine,
Your comments "should be working for complex cases" suggests that it might not be working ?
On Thu, Apr 11, 2013 at 9:40 PM, Valentine Gogichashvili <valgog@gmail.com> wrote:
Hello Gary,the problem with this change is that it is not backwards compatible. Though the question is, why somebody would like to keep a not deterministic behavior of the current code.And if you are fixing this, probably it would make sense to fix getSQLType() as well.Also it can fill your server logs with errors, if the type does not exist, regtype cast will throw an ERRORI have prepared a little bit different change: https://github.com/pgjdbc/pgjdbc/pull/52Cheers,-- Valentineვალენტინ გოგიჩაშვილი
Valentine GogichashviliOn Fri, Mar 29, 2013 at 6:08 PM, Gary Baker <gary.baker@gmail.com> wrote:I found that type cache info wasn't honoring search path. (I had a
UDT type that shared a name with a table).
This fixed it.
diff --git a/org/postgresql/jdbc2/TypeInfoCache.java
b/org/postgresql/jdbc2/TypeInfoCache.java
index 2e79758..2d26fd0 100644
--- a/org/postgresql/jdbc2/TypeInfoCache.java
+++ b/org/postgresql/jdbc2/TypeInfoCache.java
@@ -234,7 +234,7 @@ public class TypeInfoCache implements TypeInfo {
if (_getOidStatement == null) {
String sql;
if (_conn.haveMinimumServerVersion("7.3")) {
- sql = "SELECT oid FROM pg_catalog.pg_type WHERE typname = ?";
+ sql = "SELECT ?::regtype::oid";
} else {
sql = "SELECT oid FROM pg_type WHERE typname = ?";
}
--
Sent via pgsql-jdbc mailing list (pgsql-jdbc@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-jdbc