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

From: Barry Lind <barry(at)xythos(dot)com>
To: Dave Cramer <Dave(at)micro-automation(dot)net>
Cc: pgsql-jdbc(at)postgresql(dot)org
Subject: Re: Read transactions don't work on 7.0.x db's 2nd patch
Date: 2001-09-05 18:42:23
Message-ID: 3B96720F.7030109@xythos.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc pgsql-patches

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
>
>

In response to

Browse pgsql-jdbc by date

  From Date Subject
Next Message Barry Lind 2001-09-05 18:49:24 Re: Re: Proposal to fix Statement.executeBatch()
Previous Message Barry Lind 2001-09-05 17:00:46 Re: Patch for jdbc2 ResultSet.java

Browse pgsql-patches by date

  From Date Subject
Next Message Barry Lind 2001-09-05 19:11:06 Re: JDBC patch (attempt#2) for util.Serialize and jdbc2.PreparedStatement
Previous Message Tom Lane 2001-09-05 17:33:41 Re: multiple inserts