Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit7c55390

Browse files
author
Dave Cramer
committed
schema awareness patch provided by Kris Jurka
1 parent2a1e4a9 commit7c55390

File tree

9 files changed

+1353
-896
lines changed

9 files changed

+1353
-896
lines changed

‎src/interfaces/jdbc/org/postgresql/jdbc1/AbstractJdbc1Connection.java

Lines changed: 33 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
importorg.postgresql.util.*;
1515

1616

17-
/* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc1/Attic/AbstractJdbc1Connection.java,v 1.9 2002/09/11 05:38:44 barry Exp $
17+
/* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc1/Attic/AbstractJdbc1Connection.java,v 1.10 2002/10/01 00:39:01 davec Exp $
1818
* This class defines methods of the jdbc1 specification. This class is
1919
* extended by org.postgresql.jdbc2.AbstractJdbc2Connection which adds the jdbc2
2020
* methods. The real Connection class (for jdbc1) is org.postgresql.jdbc1.Jdbc1Connection
@@ -1147,6 +1147,11 @@ public String getDBVersionNumber()
11471147
returndbVersionNumber;
11481148
}
11491149

1150+
/**
1151+
* Is the server we are connected to running at least this version?
1152+
* This comparison method will fail whenever a major or minor version
1153+
* goes to two digits (10.3.0) or (7.10.1).
1154+
*/
11501155
publicbooleanhaveMinimumServerVersion(Stringver)throwsSQLException
11511156
{
11521157
return (getDBVersionNumber().compareTo(ver) >=0);
@@ -1184,16 +1189,29 @@ public int getSQLType(int oid) throws SQLException
11841189
// it's not in the cache, so perform a query, and add the result to the cache
11851190
if (sqlType ==null)
11861191
{
1187-
ResultSetresult =ExecSQL("select typname from pg_type where oid = " +oid);
1188-
if (((AbstractJdbc1ResultSet)result).getColumnCount() !=1 || ((AbstractJdbc1ResultSet)result).getTupleCount() !=1)
1189-
thrownewPSQLException("postgresql.unexpected");
1190-
result.next();
1191-
StringpgType =result.getString(1);
1192+
StringpgType;
1193+
// The opaque type does not exist in the system catalogs.
1194+
if (oid ==0) {
1195+
pgType ="opaque";
1196+
}else {
1197+
Stringsql;
1198+
if (haveMinimumServerVersion("7.3")) {
1199+
sql ="SELECT typname FROM pg_catalog.pg_type WHERE oid = " +oid;
1200+
}else {
1201+
sql ="SELECT typname FROM pg_type WHERE oid = " +oid;
1202+
}
1203+
ResultSetresult =ExecSQL(sql);
1204+
if (((AbstractJdbc1ResultSet)result).getColumnCount() !=1 || ((AbstractJdbc1ResultSet)result).getTupleCount() !=1) {
1205+
thrownewPSQLException("postgresql.unexpected");
1206+
}
1207+
result.next();
1208+
pgType =result.getString(1);
1209+
result.close();
1210+
}
11921211
IntegeriOid =newInteger(oid);
1193-
sqlType =newInteger(getSQLType(result.getString(1)));
1212+
sqlType =newInteger(getSQLType(pgType));
11941213
sqlTypeCache.put(iOid,sqlType);
11951214
pgTypeCache.put(iOid,pgType);
1196-
result.close();
11971215
}
11981216

11991217
returnsqlType.intValue();
@@ -1217,8 +1235,13 @@ public int getPGType(String typeName) throws SQLException
12171235
else
12181236
{
12191237
// it's not in the cache, so perform a query, and add the result to the cache
1220-
ResultSetresult =ExecSQL("select oid from pg_type where typname='"
1221-
+typeName +"'");
1238+
Stringsql;
1239+
if (haveMinimumServerVersion("7.3")) {
1240+
sql ="SELECT oid FROM pg_catalog.pg_type WHERE typname='" +typeName +"'";
1241+
}else {
1242+
sql ="SELECT oid FROM pg_type WHERE typname='" +typeName +"'";
1243+
}
1244+
ResultSetresult =ExecSQL(sql);
12221245
if (((AbstractJdbc1ResultSet)result).getColumnCount() !=1 || ((AbstractJdbc1ResultSet)result).getTupleCount() !=1)
12231246
thrownewPSQLException("postgresql.unexpected");
12241247
result.next();

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp