[libpostgresql-jdbc-java] 03/11: When issuing multiple queries on one statement the driver was not clearing some intermediate state between executions. When an update, insert, or delete followed a select, the select's results were still available and would be returned instead of the non-query's affected row count.

Emmanuel Bourg ebourg-guest at moszumanska.debian.org
Mon Jan 9 10:19:57 UTC 2017


This is an automated email from the git hooks/post-receive script.

ebourg-guest pushed a commit to tag REL8_1_408
in repository libpostgresql-jdbc-java.

commit fdf4f16e32a2d5ae45fa7fd7815f5f95e30be079
Author: Kris Jurka <books at ejurka.com>
Date:   Fri Jul 7 01:12:35 2006 +0000

    When issuing multiple queries on one statement the driver was not
    clearing some intermediate state between executions.  When an
    update, insert, or delete followed a select, the select's results
    were still available and would be returned instead of the
    non-query's affected row count.
    
    Example from Gilles Rayrat.
---
 org/postgresql/core/v3/QueryExecutorImpl.java |  8 +++++++-
 org/postgresql/test/jdbc2/StatementTest.java  | 10 ++++++++--
 2 files changed, 15 insertions(+), 3 deletions(-)

diff --git a/org/postgresql/core/v3/QueryExecutorImpl.java b/org/postgresql/core/v3/QueryExecutorImpl.java
index 13d699b..80440cc 100644
--- a/org/postgresql/core/v3/QueryExecutorImpl.java
+++ b/org/postgresql/core/v3/QueryExecutorImpl.java
@@ -4,7 +4,7 @@
 * Copyright (c) 2004, Open Cloud Limited.
 *
 * IDENTIFICATION
-*   $PostgreSQL: pgjdbc/org/postgresql/core/v3/QueryExecutorImpl.java,v 1.25.2.2 2006/04/29 00:07:02 jurka Exp $
+*   $PostgreSQL: pgjdbc/org/postgresql/core/v3/QueryExecutorImpl.java,v 1.25.2.3 2006/04/29 13:31:19 jurka Exp $
 *
 *-------------------------------------------------------------------------
 */
@@ -1234,6 +1234,8 @@ public class QueryExecutorImpl implements QueryExecutor {
                     if (fields != null || tuples != null)
                     { // There was a resultset.
                         handler.handleResultRows(currentQuery, fields, tuples, null);
+                        fields = null;
+                        tuples = null;
                     }
                 }
                 break;
@@ -1271,6 +1273,8 @@ public class QueryExecutorImpl implements QueryExecutor {
                     if (fields != null || tuples != null)
                     { // There was a resultset.
                         handler.handleResultRows(currentQuery, fields, tuples, null);
+                        fields = null;
+                        tuples = null;
                     }
                     else
                     {
@@ -1368,6 +1372,8 @@ public class QueryExecutorImpl implements QueryExecutor {
                     if (fields != null || tuples != null)
                     { // There was a resultset.
                         handler.handleResultRows(currentQuery, fields, tuples, null);
+                        fields = null;
+                        tuples = null;
                     }
                 }
                 break;
diff --git a/org/postgresql/test/jdbc2/StatementTest.java b/org/postgresql/test/jdbc2/StatementTest.java
index 7684e07..431f58c 100644
--- a/org/postgresql/test/jdbc2/StatementTest.java
+++ b/org/postgresql/test/jdbc2/StatementTest.java
@@ -3,7 +3,7 @@
 * Copyright (c) 2004-2005, PostgreSQL Global Development Group
 *
 * IDENTIFICATION
-*   $PostgreSQL: pgjdbc/org/postgresql/test/jdbc2/StatementTest.java,v 1.17.2.1 2005/12/15 23:28:56 jurka Exp $
+*   $PostgreSQL: pgjdbc/org/postgresql/test/jdbc2/StatementTest.java,v 1.17.2.2 2006/02/01 18:52:30 jurka Exp $
 *
 *-------------------------------------------------------------------------
 */
@@ -79,18 +79,24 @@ public class StatementTest extends TestCase
     public void testMultiExecute() throws SQLException
     {
         Statement stmt = con.createStatement();
-        stmt.execute("SELECT 1; SELECT 2");
+        assertTrue(stmt.execute("SELECT 1; UPDATE test_statement SET i=1; SELECT 2"));
 
         ResultSet rs = stmt.getResultSet();
         assertTrue(rs.next());
         assertEquals(1, rs.getInt(1));
         rs.close();
 
+        assertTrue(!stmt.getMoreResults());
+        assertEquals(0, stmt.getUpdateCount());
+
         assertTrue(stmt.getMoreResults());
         rs = stmt.getResultSet();
         assertTrue(rs.next());
         assertEquals(2, rs.getInt(1));
         rs.close();
+
+        assertTrue(!stmt.getMoreResults());
+        assertEquals(-1, stmt.getUpdateCount());
         stmt.close();
     }
 

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-java/libpostgresql-jdbc-java.git



More information about the pkg-java-commits mailing list