Skip to content

Commit

Permalink
fix: make sure we select array_in from pg_catalog to avoid duplicate …
Browse files Browse the repository at this point in the history
…array_in functions fixes #Issue 2548 (#2552)

* fix: make sure we select array_in from pg_catalog to avoid duplicate array_in functions fixes #Issue 2548

* dont run tests for versions less than 10
  • Loading branch information
davecramer committed Sep 20, 2022
1 parent 036a30d commit 7bfff7a
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
Expand Up @@ -223,7 +223,7 @@ private String getSQLTypeQuery(boolean typoidParam) {
// (keeping old behaviour of finding types, that should not be found without correct search
// path)
StringBuilder sql = new StringBuilder();
sql.append("SELECT typinput='array_in'::regproc as is_array, typtype, typname, pg_type.oid ");
sql.append("SELECT typinput='pg_catalog.array_in'::regproc as is_array, typtype, typname, pg_type.oid ");
sql.append(" FROM pg_catalog.pg_type ");
sql.append(" LEFT JOIN (select ns.oid as nspoid, ns.nspname, r.r ");
sql.append(" from pg_namespace as ns ");
Expand Down
Expand Up @@ -473,4 +473,25 @@ public void testSortedDataTypes() throws SQLException {
lastType = type;
}
}

@Test
public void testGetSqlTypes() throws SQLException {
if (TestUtil.haveMinimumServerVersion(conn, ServerVersion.v10)) {
try (Connection privileged = TestUtil.openPrivilegedDB()) {
try (Statement stmt = privileged.createStatement()) {
// create a function called array_in
stmt.execute("CREATE OR REPLACE FUNCTION public.array_in(anyarray, oid, integer)\n"
+ " RETURNS anyarray\n"
+ " LANGUAGE internal\n"
+ " STABLE PARALLEL SAFE STRICT\n"
+ "AS $function$array_in$function$");
}
DatabaseMetaData dbmd = privileged.getMetaData();
ResultSet rs = dbmd.getTypeInfo();
try (Statement stmt = privileged.createStatement()) {
stmt.execute("drop function public.array_in(anyarray, oid, integer)");
}
}
}
}
}

0 comments on commit 7bfff7a

Please sign in to comment.