Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 7066253

Browse files
committed
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
1 parent 6ea41dc commit 7066253

File tree

1 file changed

+25
-8
lines changed

1 file changed

+25
-8
lines changed

src/interfaces/jdbc/org/postgresql/Connection.java

+25-8
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
import org.postgresql.core.*;
1212

1313
/**
14-
* $Id: Connection.java,v 1.27 2001/09/06 03:13:34 momjian Exp $
14+
* $Id: Connection.java,v 1.28 2001/09/07 22:17:02 momjian Exp $
1515
*
1616
* This abstract class is used by org.postgresql.Driver to open either the JDBC1 or
1717
* JDBC2 versions of the Connection class.
@@ -749,7 +749,12 @@ public void setAutoCommit(boolean autoCommit) throws SQLException {
749749
if (autoCommit)
750750
ExecSQL("end");
751751
else {
752-
ExecSQL("begin; " + getIsolationLevelSQL());
752+
if (haveMinimumServerVersion("7.1")){
753+
ExecSQL("begin;"+getIsolationLevelSQL());
754+
}else{
755+
ExecSQL("begin");
756+
ExecSQL(getIsolationLevelSQL());
757+
}
753758
}
754759
this.autoCommit = autoCommit;
755760
}
@@ -778,7 +783,13 @@ public boolean getAutoCommit() throws SQLException {
778783
public void commit() throws SQLException {
779784
if (autoCommit)
780785
return;
781-
ExecSQL("commit; begin; " + getIsolationLevelSQL());
786+
if (haveMinimumServerVersion("7.1")){
787+
ExecSQL("commit;begin;"+getIsolationLevelSQL());
788+
}else{
789+
ExecSQL("commit");
790+
ExecSQL("begin");
791+
ExecSQL(getIsolationLevelSQL());
792+
}
782793
}
783794

784795
/**
@@ -792,7 +803,13 @@ public void commit() throws SQLException {
792803
public void rollback() throws SQLException {
793804
if (autoCommit)
794805
return;
795-
ExecSQL("rollback; begin; " + getIsolationLevelSQL());
806+
if (haveMinimumServerVersion("7.1")){
807+
ExecSQL("rollback; begin;"+getIsolationLevelSQL());
808+
}else{
809+
ExecSQL("rollback");
810+
ExecSQL("begin");
811+
ExecSQL(getIsolationLevelSQL());
812+
}
796813
}
797814

798815
/**
@@ -878,21 +895,21 @@ protected String getIsolationLevelSQL() throws SQLException {
878895
if (haveMinimumServerVersion("7.1")) {
879896
return "";
880897
}
881-
String q = "SET TRANSACTION ISOLATION LEVEL";
898+
StringBuffer sb = new StringBuffer("SET TRANSACTION ISOLATION LEVEL");
882899

883900
switch(isolationLevel) {
884901
case java.sql.Connection.TRANSACTION_READ_COMMITTED:
885-
q = q + " READ COMMITTED";
902+
sb.append(" READ COMMITTED");
886903
break;
887904

888905
case java.sql.Connection.TRANSACTION_SERIALIZABLE:
889-
q = q + " SERIALIZABLE";
906+
sb.append(" SERIALIZABLE");
890907
break;
891908

892909
default:
893910
throw new PSQLException("postgresql.con.isolevel",new Integer(isolationLevel));
894911
}
895-
return q;
912+
return sb.toString();
896913
}
897914

898915
/**

0 commit comments

Comments
 (0)