Commit 7066253a authored by Bruce Momjian's avatar Bruce Momjian

Read transactions don't work on 7.0.x db's 2nd patch

Here is a revised patch with Barry's suggestions implemented

Dave Cramer
parent 6ea41dcc
...@@ -11,7 +11,7 @@ import org.postgresql.util.*; ...@@ -11,7 +11,7 @@ import org.postgresql.util.*;
import org.postgresql.core.*; import org.postgresql.core.*;
/** /**
* $Id: Connection.java,v 1.27 2001/09/06 03:13:34 momjian Exp $ * $Id: Connection.java,v 1.28 2001/09/07 22:17:02 momjian Exp $
* *
* This abstract class is used by org.postgresql.Driver to open either the JDBC1 or * This abstract class is used by org.postgresql.Driver to open either the JDBC1 or
* JDBC2 versions of the Connection class. * JDBC2 versions of the Connection class.
...@@ -749,7 +749,12 @@ public abstract class Connection ...@@ -749,7 +749,12 @@ public abstract class Connection
if (autoCommit) if (autoCommit)
ExecSQL("end"); ExecSQL("end");
else { else {
ExecSQL("begin; " + getIsolationLevelSQL()); if (haveMinimumServerVersion("7.1")){
ExecSQL("begin;"+getIsolationLevelSQL());
}else{
ExecSQL("begin");
ExecSQL(getIsolationLevelSQL());
}
} }
this.autoCommit = autoCommit; this.autoCommit = autoCommit;
} }
...@@ -778,7 +783,13 @@ public abstract class Connection ...@@ -778,7 +783,13 @@ public abstract class Connection
public void commit() throws SQLException { public void commit() throws SQLException {
if (autoCommit) if (autoCommit)
return; return;
ExecSQL("commit; begin; " + getIsolationLevelSQL()); if (haveMinimumServerVersion("7.1")){
ExecSQL("commit;begin;"+getIsolationLevelSQL());
}else{
ExecSQL("commit");
ExecSQL("begin");
ExecSQL(getIsolationLevelSQL());
}
} }
/** /**
...@@ -792,7 +803,13 @@ public abstract class Connection ...@@ -792,7 +803,13 @@ public abstract class Connection
public void rollback() throws SQLException { public void rollback() throws SQLException {
if (autoCommit) if (autoCommit)
return; return;
ExecSQL("rollback; begin; " + getIsolationLevelSQL()); if (haveMinimumServerVersion("7.1")){
ExecSQL("rollback; begin;"+getIsolationLevelSQL());
}else{
ExecSQL("rollback");
ExecSQL("begin");
ExecSQL(getIsolationLevelSQL());
}
} }
/** /**
...@@ -878,21 +895,21 @@ public abstract class Connection ...@@ -878,21 +895,21 @@ public abstract class Connection
if (haveMinimumServerVersion("7.1")) { if (haveMinimumServerVersion("7.1")) {
return ""; return "";
} }
String q = "SET TRANSACTION ISOLATION LEVEL"; StringBuffer sb = new StringBuffer("SET TRANSACTION ISOLATION LEVEL");
switch(isolationLevel) { switch(isolationLevel) {
case java.sql.Connection.TRANSACTION_READ_COMMITTED: case java.sql.Connection.TRANSACTION_READ_COMMITTED:
q = q + " READ COMMITTED"; sb.append(" READ COMMITTED");
break; break;
case java.sql.Connection.TRANSACTION_SERIALIZABLE: case java.sql.Connection.TRANSACTION_SERIALIZABLE:
q = q + " SERIALIZABLE"; sb.append(" SERIALIZABLE");
break; break;
default: default:
throw new PSQLException("postgresql.con.isolevel",new Integer(isolationLevel)); throw new PSQLException("postgresql.con.isolevel",new Integer(isolationLevel));
} }
return q; return sb.toString();
} }
/** /**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment