JDBC Driver - Batch Prepared Statements - Mailing list pgsql-patches

From Kris Jurka
Subject JDBC Driver - Batch Prepared Statements
Date
Msg-id 3D7D3BD3.8070104@ejurka.com
Whole thread Raw
List pgsql-patches
The code in AbstractJbc1Statement: execute(String sql) and
executeUpdate(sql) was setting m_sqlFragments while ignoring m_binds.
This caused Batch Prepared Statements to fail becuase while at one point
the statement had binds, executeBatch turned the PreparedStatement into
a plain String without removing the binds.  I don't know why this wasn't
causing an IndexOutOfBoundsException in the QueryExecutor at or about
line 144, but this seems to fix it.

It seems like m_bindTypes, m_origSqlFragments, m_executeSqlFragments
might need to be reset as well, but this at least gets the regression
tests to pass.

Kris Jurka
Index: src/interfaces/jdbc/org/postgresql/jdbc1/AbstractJdbc1Statement.java
===================================================================
RCS file: /projects/cvsroot/pgsql-server/src/interfaces/jdbc/org/postgresql/jdbc1/AbstractJdbc1Statement.java,v
retrieving revision 1.8
diff -c -r1.8 AbstractJdbc1Statement.java
*** src/interfaces/jdbc/org/postgresql/jdbc1/AbstractJdbc1Statement.java    2002/09/08 00:15:29    1.8
--- src/interfaces/jdbc/org/postgresql/jdbc1/AbstractJdbc1Statement.java    2002/09/10 00:15:35
***************
*** 170,175 ****
--- 170,176 ----
      {
          String l_sql = replaceProcessing(p_sql);
          m_sqlFragments = new String[] {l_sql};
+         m_binds = new Object[0];
          //If we have already created a server prepared statement, we need
          //to deallocate the existing one
          if (m_statementName != null) {
***************
*** 213,218 ****
--- 214,220 ----
      {
          String l_sql = replaceProcessing(p_sql);
          m_sqlFragments = new String[] {l_sql};
+         m_binds = new Object[0];
          //If we have already created a server prepared statement, we need
          //to deallocate the existing one
          if (m_statementName != null) {

pgsql-patches by date:

Previous
From: Bruno Wolff III
Date:
Subject: Updated earthdistance/cube patches
Next
From: Bruce Momjian
Date:
Subject: Re: cube and earthdistance diffs