|
@@ -1032,7 +1032,7 @@ public ResultSet getProcedureColumns(String catalog, String schemaPattern, |
|
|
StringTokenizer st = new StringTokenizer(strArgTypes); |
|
|
List<Long> argTypes = new ArrayList<Long>(); |
|
|
while (st.hasMoreTokens()) { |
|
|
argTypes.add(new Long(st.nextToken())); |
|
|
argTypes.add(Long.valueOf(st.nextToken())); |
|
|
} |
|
|
|
|
|
String argNames[] = null; |
|
@@ -1231,14 +1231,15 @@ public ResultSet getTables(String catalog, String schemaPattern, String tableNam |
|
|
} |
|
|
if (types != null) { |
|
|
select += " AND (false "; |
|
|
StringBuilder orclause = new StringBuilder(); |
|
|
for (String type : types) { |
|
|
Map<String, String> clauses = tableTypeClauses.get(type); |
|
|
if (clauses != null) { |
|
|
String clause = clauses.get(useSchemas); |
|
|
select += " OR ( " + clause + " ) "; |
|
|
orclause.append(" OR ( ").append(clause).append(" ) "); |
|
|
} |
|
|
} |
|
|
select += ") "; |
|
|
select += orclause.toString() + ") "; |
|
|
} |
|
|
String sql = select + orderby; |
|
|
|
|
@@ -2397,33 +2398,35 @@ public ResultSet getUDTs(String catalog, String schemaPattern, String typeNamePa |
|
|
+ " end as data_type, pg_catalog.obj_description(t.oid, 'pg_type') " |
|
|
+ "as remarks, CASE WHEN t.typtype = 'd' then (select CASE"; |
|
|
|
|
|
StringBuilder sqlwhen = new StringBuilder(); |
|
|
for (Iterator<String> i = connection.getTypeInfo().getPGTypeNamesWithSQLTypes(); i.hasNext(); ) { |
|
|
String pgType = i.next(); |
|
|
int sqlType = connection.getTypeInfo().getSQLType(pgType); |
|
|
sql += " when typname = " + escapeQuotes(pgType) + " then " + sqlType; |
|
|
sqlwhen.append(" when typname = ").append(escapeQuotes(pgType)).append(" then ").append(sqlType); |
|
|
} |
|
|
sql += sqlwhen.toString(); |
|
|
|
|
|
sql += " else " + java.sql.Types.OTHER + " end from pg_type where oid=t.typbasetype) " |
|
|
+ "else null end as base_type " |
|
|
+ "from pg_catalog.pg_type t, pg_catalog.pg_namespace n where t.typnamespace = n.oid and n.nspname != 'pg_catalog' and n.nspname != 'pg_toast'"; |
|
|
|
|
|
|
|
|
String toAdd = ""; |
|
|
StringBuilder toAdd = new StringBuilder(); |
|
|
if (types != null) { |
|
|
toAdd += " and (false "; |
|
|
toAdd.append(" and (false "); |
|
|
for (int type : types) { |
|
|
switch (type) { |
|
|
case Types.STRUCT: |
|
|
toAdd += " or t.typtype = 'c'"; |
|
|
toAdd.append(" or t.typtype = 'c'"); |
|
|
break; |
|
|
case Types.DISTINCT: |
|
|
toAdd += " or t.typtype = 'd'"; |
|
|
toAdd.append(" or t.typtype = 'd'"); |
|
|
break; |
|
|
} |
|
|
} |
|
|
toAdd += " ) "; |
|
|
toAdd.append(" ) "); |
|
|
} else { |
|
|
toAdd += " and t.typtype IN ('c','d') "; |
|
|
toAdd.append(" and t.typtype IN ('c','d') "); |
|
|
} |
|
|
// spec says that if typeNamePattern is a fully qualified name |
|
|
// then the schema and catalog are ignored |
|
@@ -2445,14 +2448,14 @@ public ResultSet getUDTs(String catalog, String schemaPattern, String typeNamePa |
|
|
// strip out just the typeName |
|
|
typeNamePattern = typeNamePattern.substring(secondQualifier + 1); |
|
|
} |
|
|
toAdd += " and t.typname like " + escapeQuotes(typeNamePattern); |
|
|
toAdd.append(" and t.typname like ").append(escapeQuotes(typeNamePattern)); |
|
|
} |
|
|
|
|
|
// schemaPattern may have been modified above |
|
|
if (schemaPattern != null) { |
|
|
toAdd += " and n.nspname like " + escapeQuotes(schemaPattern); |
|
|
toAdd.append(" and n.nspname like ").append(escapeQuotes(schemaPattern)); |
|
|
} |
|
|
sql += toAdd; |
|
|
sql += toAdd.toString(); |
|
|
sql += " order by data_type, type_schem, type_name"; |
|
|
return createMetaDataStatement().executeQuery(sql); |
|
|
} |
|
|