mirror of
https://github.com/postgres/postgres.git
synced 2025-06-17 17:02:08 +03:00
Attached is a patch that does the following:
1) improves performance of commit/rollback by reducing number of round trips to the server 2) uses 7.1 functionality for setting the transaction isolation level 3) backs out a patch from 11 days ago because that code failed to compile under jdk1.1 Details: 1) The old code was doing the following for each commit: commit begin set transaction isolation level xxx thus a call to commit was performing three round trips to the database. The new code does this in one round trip as: commit; begin; set transaction isolation level xxx In a simple test program that performs 1000 transactions (where each transaction does one simple select inside that transaction) has the following before and after timings: Client and Server on same machine old new --- --- 1.877sec 1.405sec 25.1% improvement Client and Server on different machines old new --- --- 4.184sec 2.927sec 34.3% improvement (all timings are an average of four different runs) 2) The driver was using 'set transaction isolation level xxx' at the begining of each transaction, instead of using the new 7.1 syntax of 'set session characteristics as transaction isolation level xxx' which only needs to be done once instead of for each transaction. This is done conditionally (i.e. if server is 7.0 or older do the old behaviour, else do the new behaviour) to not break backward compatibility. This also required the movement of some code to check/test database version numbers from the DatabaseMetaData object to the Connection object. 3) Finally while testing, I discovered that the code that was checked in 11 days ago actually didn't compile. The code in the patch for Connection.setCatalog() used Properties.setProperty() which only exists in JDK1.2 or higher. Thus compiling the JDBC1 driver failed as this method doesn't exist. Thus I backed out that patch. Barry Lind
This commit is contained in:
@ -47,15 +47,6 @@ public class DatabaseMetaData implements java.sql.DatabaseMetaData
|
||||
private static final byte defaultRemarks[]="no remarks".getBytes();
|
||||
|
||||
|
||||
private boolean haveMinimumServerVersion(String ver) throws SQLException
|
||||
{
|
||||
if (getDatabaseProductVersion().compareTo(ver)>=0)
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
public DatabaseMetaData(Connection conn)
|
||||
{
|
||||
this.connection = conn;
|
||||
@ -126,7 +117,7 @@ public class DatabaseMetaData implements java.sql.DatabaseMetaData
|
||||
*/
|
||||
public boolean nullsAreSortedHigh() throws SQLException
|
||||
{
|
||||
return haveMinimumServerVersion("7.2");
|
||||
return connection.haveMinimumServerVersion("7.2");
|
||||
}
|
||||
|
||||
/**
|
||||
@ -159,7 +150,7 @@ public class DatabaseMetaData implements java.sql.DatabaseMetaData
|
||||
*/
|
||||
public boolean nullsAreSortedAtEnd() throws SQLException
|
||||
{
|
||||
return ! haveMinimumServerVersion("7.2");
|
||||
return ! connection.haveMinimumServerVersion("7.2");
|
||||
}
|
||||
|
||||
/**
|
||||
@ -182,14 +173,7 @@ public class DatabaseMetaData implements java.sql.DatabaseMetaData
|
||||
*/
|
||||
public String getDatabaseProductVersion() throws SQLException
|
||||
{
|
||||
java.sql.ResultSet resultSet = connection.ExecSQL("select version()");
|
||||
resultSet.next();
|
||||
|
||||
StringTokenizer versionParts = new StringTokenizer(resultSet.getString(1));
|
||||
versionParts.nextToken(); /* "PostgreSQL" */
|
||||
String versionNumber = versionParts.nextToken(); /* "X.Y.Z" */
|
||||
|
||||
return versionNumber;
|
||||
return connection.getDBVersionNumber();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -558,7 +542,7 @@ public class DatabaseMetaData implements java.sql.DatabaseMetaData
|
||||
*/
|
||||
public boolean supportsOrderByUnrelated() throws SQLException
|
||||
{
|
||||
return haveMinimumServerVersion("6.4");
|
||||
return connection.haveMinimumServerVersion("6.4");
|
||||
}
|
||||
|
||||
/**
|
||||
@ -581,7 +565,7 @@ public class DatabaseMetaData implements java.sql.DatabaseMetaData
|
||||
*/
|
||||
public boolean supportsGroupByUnrelated() throws SQLException
|
||||
{
|
||||
return haveMinimumServerVersion("6.4");
|
||||
return connection.haveMinimumServerVersion("6.4");
|
||||
}
|
||||
|
||||
/**
|
||||
@ -608,7 +592,7 @@ public class DatabaseMetaData implements java.sql.DatabaseMetaData
|
||||
*/
|
||||
public boolean supportsLikeEscapeClause() throws SQLException
|
||||
{
|
||||
return haveMinimumServerVersion("7.1");
|
||||
return connection.haveMinimumServerVersion("7.1");
|
||||
}
|
||||
|
||||
/**
|
||||
@ -749,7 +733,7 @@ public class DatabaseMetaData implements java.sql.DatabaseMetaData
|
||||
*/
|
||||
public boolean supportsOuterJoins() throws SQLException
|
||||
{
|
||||
return haveMinimumServerVersion("7.1");
|
||||
return connection.haveMinimumServerVersion("7.1");
|
||||
}
|
||||
|
||||
/**
|
||||
@ -761,7 +745,7 @@ public class DatabaseMetaData implements java.sql.DatabaseMetaData
|
||||
*/
|
||||
public boolean supportsFullOuterJoins() throws SQLException
|
||||
{
|
||||
return haveMinimumServerVersion("7.1");
|
||||
return connection.haveMinimumServerVersion("7.1");
|
||||
}
|
||||
|
||||
/**
|
||||
@ -976,7 +960,7 @@ public class DatabaseMetaData implements java.sql.DatabaseMetaData
|
||||
*/
|
||||
public boolean supportsSelectForUpdate() throws SQLException
|
||||
{
|
||||
return haveMinimumServerVersion("6.5");
|
||||
return connection.haveMinimumServerVersion("6.5");
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1053,7 +1037,7 @@ public class DatabaseMetaData implements java.sql.DatabaseMetaData
|
||||
*/
|
||||
public boolean supportsCorrelatedSubqueries() throws SQLException
|
||||
{
|
||||
return haveMinimumServerVersion("7.1");
|
||||
return connection.haveMinimumServerVersion("7.1");
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1075,7 +1059,7 @@ public class DatabaseMetaData implements java.sql.DatabaseMetaData
|
||||
*/
|
||||
public boolean supportsUnionAll() throws SQLException
|
||||
{
|
||||
return haveMinimumServerVersion("7.1");
|
||||
return connection.haveMinimumServerVersion("7.1");
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1303,7 +1287,7 @@ public class DatabaseMetaData implements java.sql.DatabaseMetaData
|
||||
*/
|
||||
public int getMaxRowSize() throws SQLException
|
||||
{
|
||||
if (haveMinimumServerVersion("7.1"))
|
||||
if (connection.haveMinimumServerVersion("7.1"))
|
||||
return 1073741824; // 1 GB
|
||||
else
|
||||
return 8192; // XXX could be altered
|
||||
@ -1329,7 +1313,7 @@ public class DatabaseMetaData implements java.sql.DatabaseMetaData
|
||||
*/
|
||||
public int getMaxStatementLength() throws SQLException
|
||||
{
|
||||
if (haveMinimumServerVersion("7.0"))
|
||||
if (connection.haveMinimumServerVersion("7.0"))
|
||||
return 0; // actually whatever fits in size_t
|
||||
else
|
||||
return 16384;
|
||||
|
Reference in New Issue
Block a user