Re: Read transactions don't work on 7.0.x db's 2nd patch - Mailing list pgsql-jdbc
From | Barry Lind |
---|---|
Subject | Re: Read transactions don't work on 7.0.x db's 2nd patch |
Date | |
Msg-id | 3B96720F.7030109@xythos.com Whole thread Raw |
In response to | Re: Read transactions don't work on 7.0.x db's ("Dave Cramer" <Dave@micro-automation.net>) |
List | pgsql-jdbc |
Dave, There is a bug in this patch. In the rollback case, you have: > ! ExecSQL("rollback; begin"+getIsolationLevelSQL()); You are missing a semicolon after the begin. thanks, --Barry Dave Cramer wrote: > Here is a revised patch with Barry's suggestions implemented > > Dave > > > ------------------------------------------------------------------------ > > Index: Connection.java > =================================================================== > RCS file: /home/projects/pgsql/cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/Connection.java,v > retrieving revision 1.26 > diff -c -r1.26 Connection.java > *** Connection.java 2001/08/24 16:50:12 1.26 > --- Connection.java 2001/09/04 17:21:29 > *************** > *** 906,912 **** > if (autoCommit) > ExecSQL("end"); > else { > ! ExecSQL("begin; " + getIsolationLevelSQL()); > } > this.autoCommit = autoCommit; > } > --- 906,917 ---- > if (autoCommit) > ExecSQL("end"); > else { > ! if (haveMinimumServerVersion("7.1")){ > ! ExecSQL("begin;"+getIsolationLevelSQL()); > ! }else{ > ! ExecSQL("begin"); > ! ExecSQL(getIsolationLevelSQL()); > ! } > } > this.autoCommit = autoCommit; > } > *************** > *** 935,941 **** > public void commit() throws SQLException { > if (autoCommit) > return; > ! ExecSQL("commit; begin; " + getIsolationLevelSQL()); > } > > /** > --- 940,952 ---- > public void commit() throws SQLException { > if (autoCommit) > return; > ! if (haveMinimumServerVersion("7.1")){ > ! ExecSQL("commit;begin;"+getIsolationLevelSQL()); > ! }else{ > ! ExecSQL("commit"); > ! ExecSQL("begin"); > ! ExecSQL(getIsolationLevelSQL()); > ! } > } > > /** > *************** > *** 949,955 **** > public void rollback() throws SQLException { > if (autoCommit) > return; > ! ExecSQL("rollback; begin; " + getIsolationLevelSQL()); > } > > /** > --- 960,972 ---- > public void rollback() throws SQLException { > if (autoCommit) > return; > ! if (haveMinimumServerVersion("7.1")){ > ! ExecSQL("rollback; begin"+getIsolationLevelSQL()); > ! }else{ > ! ExecSQL("rollback"); > ! ExecSQL("begin"); > ! ExecSQL(getIsolationLevelSQL()); > ! } > } > > /** > *************** > *** 1035,1055 **** > if (haveMinimumServerVersion("7.1")) { > return ""; > } > ! String q = "SET TRANSACTION ISOLATION LEVEL"; > > switch(isolationLevel) { > case java.sql.Connection.TRANSACTION_READ_COMMITTED: > ! q = q + " READ COMMITTED"; > break; > > case java.sql.Connection.TRANSACTION_SERIALIZABLE: > ! q = q + " SERIALIZABLE"; > break; > > default: > throw new PSQLException("postgresql.con.isolevel",new Integer(isolationLevel)); > } > ! return q; > } > > /** > --- 1052,1072 ---- > if (haveMinimumServerVersion("7.1")) { > return ""; > } > ! StringBuffer sb = new StringBuffer("SET TRANSACTION ISOLATION LEVEL"); > > switch(isolationLevel) { > case java.sql.Connection.TRANSACTION_READ_COMMITTED: > ! sb.append(" READ COMMITTED"); > break; > > case java.sql.Connection.TRANSACTION_SERIALIZABLE: > ! sb.append(" SERIALIZABLE"); > break; > > default: > throw new PSQLException("postgresql.con.isolevel",new Integer(isolationLevel)); > } > ! return sb.toString(); > } > > /** > > > ------------------------------------------------------------------------ > > > ---------------------------(end of broadcast)--------------------------- > TIP 6: Have you searched our list archives? > > http://www.postgresql.org/search.mpl > > Connection.patch > > Content-Type: > > text/plain > Content-Encoding: > > 7bit > > > ------------------------------------------------------------------------ > Part 1.3 > > Content-Type: > > text/plain > Content-Encoding: > > binary > >
pgsql-jdbc by date: