protected ResultSet getSchemas(int jdbcVersion, String catalog, String schemaPattern) throws SQLException { String sql; // Show only the users temp schemas, but not other peoples // because they can't access any objects in them. if (connection.haveMinimumServerVersion("7.3")) { // 7.3 can't extract elements from an array returned by // a function, so we've got to coerce it to text and then // hack it up with a regex. String tempSchema = "substring(textin(array_out(pg_catalog.current_schemas(true))) from '{(pg_temp_[0-9]+),')"; if (connection.haveMinimumServerVersion("7.4")) { tempSchema = "(pg_catalog.current_schemas(true))[1]"; } sql = "SELECT nspname AS TABLE_SCHEM "; if (jdbcVersion >= 3) sql += ", NULL AS TABLE_CATALOG "; sql += " FROM pg_catalog.pg_namespace WHERE nspname <> 'pg_toast' AND (nspname !~ '^pg_temp_' OR nspname = " + tempSchema + ") AND (nspname !~ '^pg_toast_temp_' OR nspname = replace(" + tempSchema + ", 'pg_temp_', 'pg_toast_temp_')) "; if (schemaPattern != null && !"".equals(schemaPattern)) { sql += " AND nspname LIKE " + escapeQuotes(schemaPattern); } sql += " ORDER BY TABLE_SCHEM"; } else { sql = "SELECT ''::text AS TABLE_SCHEM "; if (jdbcVersion >= 3) { sql += ", NULL AS TABLE_CATALOG "; } if (schemaPattern != null)
protected ResultSet getSchemas(int jdbcVersion, String catalog, String schemaPattern) throws SQLException { String sql; // Show only the users temp schemas, but not other peoples // because they can't access any objects in them. if (connection.haveMinimumServerVersion("7.3")) { // 7.3 can't extract elements from an array returned by // a function, so we've got to coerce it to text and then // hack it up with a regex. String tempSchema = "substring(textin(array_out(pg_catalog.current_schemas(true))) from '{(pg_temp_[0-9]+),')"; if (connection.haveMinimumServerVersion("7.4")) { tempSchema = "(pg_catalog.current_schemas(true))[1]"; } sql = "SELECT nspname AS TABLE_SCHEM "; if (jdbcVersion >= 3) sql += ", NULL AS TABLE_CATALOG "; sql += " FROM pg_catalog.pg_namespace WHERE nspname <> 'pg_toast' AND (nspname !~ '^pg_temp_' OR nspname = " + tempSchema + ") AND (nspname !~ '^pg_toast_temp_' OR nspname = replace(" + tempSchema + ", 'pg_temp_', 'pg_toast_temp_')) "; if (schemaPattern != null && !"".equals(schemaPattern)) { sql += " AND nspname LIKE " + escapeQuotes(schemaPattern); } sql += " ORDER BY TABLE_SCHEM"; } else { sql = "SELECT ''::text AS TABLE_SCHEM "; if (jdbcVersion >= 3) { sql += ", NULL AS TABLE_CATALOG "; } if (schemaPattern != null)