[libpostgresql-jdbc-java] 01/09: When doing batch execution we can have multiple Parse and DescribeStatement messages on the wire at the same time. When we finally get around to collecting the DescribeStatement results we must check whether they still apply to the currently parsed query. Otherwise we'll overwrite our type information with stale data that will cause failures down the line.

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


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

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

commit 84d681094467a96b3634f5b3d9cd1dc177775c12
Author: Kris Jurka <books at ejurka.com>
Date:   Mon Sep 24 12:34:20 2007 +0000

    When doing batch execution we can have multiple Parse and
    DescribeStatement messages on the wire at the same time.  When we
    finally get around to collecting the DescribeStatement results we
    must check whether they still apply to the currently parsed query.
    Otherwise we'll overwrite our type information with stale data that
    will cause failures down the line.
    
    With debugging assistance from Eric Faulhaber.
---
 org/postgresql/core/v3/QueryExecutorImpl.java | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/org/postgresql/core/v3/QueryExecutorImpl.java b/org/postgresql/core/v3/QueryExecutorImpl.java
index 80440cc..29f11e8 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.3 2006/04/29 13:31:19 jurka Exp $
+*   $PostgreSQL: pgjdbc/org/postgresql/core/v3/QueryExecutorImpl.java,v 1.25.2.4 2006/07/07 01:12:34 jurka Exp $
 *
 *-------------------------------------------------------------------------
 */
@@ -918,7 +918,7 @@ public class QueryExecutorImpl implements QueryExecutor {
             pgStream.Send(encodedStatementName);    // Statement name
         pgStream.SendChar(0);                       // end message
 
-        pendingDescribeStatementQueue.add(new Object[]{query, params, new Boolean(describeOnly)});
+        pendingDescribeStatementQueue.add(new Object[]{query, params, new Boolean(describeOnly), query.getStatementName()});
     }
 
     private void sendExecute(Query query, Portal portal, int limit) throws IOException {
@@ -1191,13 +1191,22 @@ public class QueryExecutorImpl implements QueryExecutor {
                     SimpleQuery query = (SimpleQuery)describeData[0];
                     SimpleParameterList params = (SimpleParameterList)describeData[1];
                     boolean describeOnly = ((Boolean)describeData[2]).booleanValue();
+                    String origStatementName = (String)describeData[3];
 
                     int numParams = pgStream.ReceiveIntegerR(2);
                     for (int i=1; i<=numParams; i++) {
                         int typeOid = pgStream.ReceiveIntegerR(4);
                         params.setResolvedType(i, typeOid);
                     }
-                    query.setStatementTypes((int[])params.getTypeOIDs().clone());
+
+                    // Since we can issue multiple Parse and DescribeStatement
+                    // messages in a single network trip, we need to make
+                    // sure the describe results we requested are still
+                    // applicable to the latest parsed query.
+                    //
+                    if ((origStatementName == null && query.getStatementName() == null) || (origStatementName != null && origStatementName.equals(query.getStatementName()))) {
+                        query.setStatementTypes((int[])params.getTypeOIDs().clone());
+		    }
 
                     if (describeOnly)
                         doneAfterRowDescNoData = true;

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