JDBC: Reinstate autocommit client hack for 7.4 - Mailing list pgsql-jdbc

From Fernando Nasser
Subject JDBC: Reinstate autocommit client hack for 7.4
Date
Msg-id 3ED3A6CD.2060909@redhat.com
Whole thread Raw
List pgsql-jdbc
I am not absolutely sure these are all the cases that have to be
revisited but it at least let us use the driver with the 7.4 current
sources (with no server autocommit).



--
Fernando Nasser
Red Hat Canada Ltd.                     E-Mail:  fnasser@redhat.com
2323 Yonge Street, Suite #300
Toronto, Ontario   M4P 2C9
Index: src/interfaces/jdbc/org/postgresql/jdbc1/AbstractJdbc1Connection.java
===================================================================
RCS file: /projects/cvsroot/pgsql-server/src/interfaces/jdbc/org/postgresql/jdbc1/AbstractJdbc1Connection.java,v
retrieving revision 1.18
diff -c -p -r1.18 AbstractJdbc1Connection.java
*** src/interfaces/jdbc/org/postgresql/jdbc1/AbstractJdbc1Connection.java    19 Mar 2003 04:06:20 -0000    1.18
--- src/interfaces/jdbc/org/postgresql/jdbc1/AbstractJdbc1Connection.java    27 May 2003 17:43:42 -0000
*************** public abstract class AbstractJdbc1Conne
*** 457,463 ****
          //We also set the client encoding so that the driver only needs
          //to deal with utf8.  We can only do this in 7.3 because multibyte
          //support is now always included
!         if (haveMinimumServerVersion("7.3"))
          {
              BaseResultSet acRset =
                  execSQL("set client_encoding = 'UNICODE'; show autocommit");
--- 457,463 ----
          //We also set the client encoding so that the driver only needs
          //to deal with utf8.  We can only do this in 7.3 because multibyte
          //support is now always included
!         if (haveMinimumServerVersion("7.3") && !haveMinimumServerVersion("7.4"))
          {
              BaseResultSet acRset =
                  execSQL("set client_encoding = 'UNICODE'; show autocommit");
*************** public abstract class AbstractJdbc1Conne
*** 478,483 ****
--- 478,493 ----
                  execSQL("set autocommit = on; commit;");
              }
          }
+         // On 7.4 there is no more backend autocommit, but we still need
+         // to set the client encoding.
+         else if (haveMinimumServerVersion("7.4"))
+         {
+             BaseResultSet acRset =
+                 execSQL("set client_encoding = 'UNICODE'");
+
+             //set encoding to be unicode
+             encoding = Encoding.getEncoding("UNICODE", null);
+         }

          // Initialise object handling
          initObjectTypes();
*************** public abstract class AbstractJdbc1Conne
*** 887,893 ****
              return ;
          if (autoCommit)
          {
!             if (haveMinimumServerVersion("7.3"))
              {
                  //We do the select to ensure a transaction is in process
                  //before we do the commit to avoid warning messages
--- 897,903 ----
              return ;
          if (autoCommit)
          {
!             if (haveMinimumServerVersion("7.3") && !haveMinimumServerVersion("7.4"))
              {
                  //We do the select to ensure a transaction is in process
                  //before we do the commit to avoid warning messages
*************** public abstract class AbstractJdbc1Conne
*** 905,911 ****
          }
          else
          {
!             if (haveMinimumServerVersion("7.3"))
              {
                  execSQL("set autocommit = off; " + getIsolationLevelSQL());
              }
--- 915,921 ----
          }
          else
          {
!             if (haveMinimumServerVersion("7.3") && !haveMinimumServerVersion("7.4"))
              {
                  execSQL("set autocommit = off; " + getIsolationLevelSQL());
              }
*************** public abstract class AbstractJdbc1Conne
*** 976,982 ****
      {
          if (autoCommit)
              return ;
!         if (haveMinimumServerVersion("7.3"))
          {
              //we don't automatically start a transaction
              //but let the server functionality automatically start
--- 986,992 ----
      {
          if (autoCommit)
              return ;
!         if (haveMinimumServerVersion("7.3") && !haveMinimumServerVersion("7.4"))
          {
              //we don't automatically start a transaction
              //but let the server functionality automatically start

pgsql-jdbc by date:

Previous
From: miguel angel rojas aquino
Date:
Subject: weird error while updating row
Next
From: Fernando Nasser
Date:
Subject: JDBC: LONGVARBINARY upload patch