patch: complain obviously about unknown transaction states - Mailing list pgsql-jdbc

From Oliver Jowett
Subject patch: complain obviously about unknown transaction states
Date
Msg-id 40E8C806.6070902@opencloud.com
Whole thread Raw
Responses Re: patch: complain obviously about unknown transaction states
List pgsql-jdbc
ReadyForQuery may change in 7.5, per discussion on -hackers:

   http://archives.postgresql.org/pgsql-hackers/2004-07/msg00184.php

The attached patch makes the driver generate errors on unknown
transaction states in a ReadyForQuery message, rather than silently
ignoring them (and probably getting confused).

-O
Index: org/postgresql/core/v3/QueryExecutorImpl.java
===================================================================
RCS file: /usr/local/cvsroot/pgjdbc/pgjdbc/org/postgresql/core/v3/QueryExecutorImpl.java,v
retrieving revision 1.1
diff -u -c -r1.1 QueryExecutorImpl.java
*** org/postgresql/core/v3/QueryExecutorImpl.java    29 Jun 2004 06:43:25 -0000    1.1
--- org/postgresql/core/v3/QueryExecutorImpl.java    5 Jul 2004 02:38:21 -0000
***************
*** 1175,1181 ****

      private void receiveRFQ() throws IOException {
          if (pgStream.ReceiveIntegerR(4) != 5)
!             throw new IOException("unexpected length of ReadyForQuery packet");

          char tStatus = (char)pgStream.ReceiveChar();
          if (Driver.logDebug)
--- 1175,1181 ----

      private void receiveRFQ() throws IOException {
          if (pgStream.ReceiveIntegerR(4) != 5)
!             throw new IOException("unexpected length of ReadyForQuery message");

          char tStatus = (char)pgStream.ReceiveChar();
          if (Driver.logDebug)
***************
*** 1193,1200 ****
              protoConnection.setTransactionState(ProtocolConnection.TRANSACTION_FAILED);
              break;
          default:
!             // Huh?
!             break;
          }
      }

--- 1193,1199 ----
              protoConnection.setTransactionState(ProtocolConnection.TRANSACTION_FAILED);
              break;
          default:
!             throw new IOException("unexpected transaction state in ReadyForQuery message: " + (int)tStatus);
          }
      }


pgsql-jdbc by date:

Previous
From: Stephan Szabo
Date:
Subject: Re: [BUGS] Error in DatabaseMetaData.getColumns() with Views
Next
From: "Dario V. Fassi"
Date:
Subject: Re: [BUGS] Error in DatabaseMetaData.getColumns() with Views