This is an automated email from the git hooks/post-receive script.

ebourg-guest pushed a commit to annotated tag REL9_3_1100
in repository libpostgresql-jdbc-java.

commit 818b84d28ac33cdc538fbfd4ccb6c6287d2003da
Author: Valentine Gogichashvili <vgogichashvili@vgogichashvili-ubuntu>
Date:   Fri Apr 12 17:05:00 2013 +0200

    search_path support should be working correctly even for complex cases
---
 org/postgresql/jdbc2/TypeInfoCache.java | 30 ++++++++++++++++++++++++++----
 1 file changed, 26 insertions(+), 4 deletions(-)

diff --git a/org/postgresql/jdbc2/TypeInfoCache.java 
b/org/postgresql/jdbc2/TypeInfoCache.java
index 56591d6..559cbbc 100644
--- a/org/postgresql/jdbc2/TypeInfoCache.java
+++ b/org/postgresql/jdbc2/TypeInfoCache.java
@@ -190,8 +190,19 @@ public class TypeInfoCache implements TypeInfo {
                 // in case of multiple records (in different schemas) choose 
the one from the current schema,
                 // otherwise take the last version of a type that is at least 
more deterministic then before
                 // (keeping old behaviour of finding types, that should not be 
found without correct search path)
-                sql = "SELECT typinput='array_in'::regproc, typtype FROM 
pg_catalog.pg_type WHERE typname = ? " +
-                      "ORDER BY ( select nspname = current_schema() from 
pg_namespace as ns where ns.oid = typnamespace ) DESC, oid DESC LIMIT 1";
+                sql = "SELECT typinput='array_in'::regproc, typtype " +
+                      "  FROM pg_catalog.pg_type " +
+                      "  LEFT " +
+                      "  JOIN (select ns.oid as nspoid, ns.nspname, r.r " +
+                      "          from pg_namespace as ns " +
+                      "          join ( select s.r, 
(current_schemas(false))[s.r] as nspname " +
+                      //                  -- go with older way of unnesting 
array to be compatible with 8.0
+                      "                   from generate_series(1, 
array_upper(current_schemas(false), 1)) as s(r) ) as r " +
+                      "         using ( nspname ) " +
+                      "       ) as sp " +
+                      "    ON sp.nspoid = typnamespace " +
+                      " WHERE typname = ? " +
+                      " ORDER BY sp.r, pg_type.oid DESC LIMIT 1;";
             } else if (_conn.haveMinimumServerVersion("7.3")) {
                 sql = "SELECT typinput='array_in'::regproc, typtype FROM 
pg_catalog.pg_type WHERE typname = ? ORDER BY oid DESC LIMIT 1";
             } else {
@@ -242,8 +253,19 @@ public class TypeInfoCache implements TypeInfo {
             String sql;
             if (_conn.haveMinimumServerVersion("8.0")) {
                 // see comments in @getSQLType()
-                sql = "SELECT oid FROM pg_catalog.pg_type WHERE typname = ? " +
-                      "ORDER BY ( select nspname = current_schema() from 
pg_namespace as ns where ns.oid = typnamespace ) DESC, oid DESC LIMIT 1";
+                sql = "SELECT pg_type.oid " +
+                      "  FROM pg_catalog.pg_type " +
+                      "  LEFT " +
+                      "  JOIN (select ns.oid as nspoid, ns.nspname, r.r " +
+                      "          from pg_namespace as ns " +
+                      "          join ( select s.r, 
(current_schemas(false))[s.r] as nspname " +
+                      //                  -- go with older way of unnesting 
array to be compatible with 8.0
+                      "                   from generate_series(1, 
array_upper(current_schemas(false), 1)) as s(r) ) as r " +
+                      "         using ( nspname ) " +
+                      "       ) as sp " +
+                      "    ON sp.nspoid = typnamespace " +
+                      " WHERE typname = ? " +
+                      " ORDER BY sp.r, pg_type.oid DESC LIMIT 1;";
             } else if (_conn.haveMinimumServerVersion("7.3")) {
                 sql = "SELECT oid FROM pg_catalog.pg_type WHERE typname = ? 
ORDER BY oid DESC LIMIT 1";
             } else {

-- 
Alioth's /usr/local/bin/git-commit-notice on 
/srv/git.debian.org/git/pkg-java/libpostgresql-jdbc-java.git

_______________________________________________
pkg-java-commits mailing list
[email protected]
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/pkg-java-commits

Reply via email to