You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-commits@db.apache.org by ka...@apache.org on 2007/04/15 15:31:19 UTC

svn commit: r528973 - /db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/MultiProbeTableScanResultSet.java

Author: kahatlen
Date: Sun Apr 15 06:31:19 2007
New Revision: 528973

URL: http://svn.apache.org/viewvc?view=rev&rev=528973
Log:
DERBY-827 (partial) Make MultiProbeTableScanResultSet reusable across
executions. Patch contributed by A B <qo...@gmail.com>.

Modified:
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/MultiProbeTableScanResultSet.java

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/MultiProbeTableScanResultSet.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/MultiProbeTableScanResultSet.java?view=diff&rev=528973&r1=528972&r2=528973
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/MultiProbeTableScanResultSet.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/MultiProbeTableScanResultSet.java Sun Apr 15 06:31:19 2007
@@ -67,16 +67,21 @@
 {
     /* The values with which we will probe the table. */
     protected DataValueDescriptor [] probeValues;
+    /**
+     * The values with which we will probe the table, as they were passed to
+     * the constructor. We need to keep them unchanged in case the result set
+     * is reused when a statement is re-executed (see DERBY-827).
+     */
+    protected DataValueDescriptor [] origProbeValues;
 
     /* 0-based position of the *next* value to lookup w.r.t. the probe
      * values list.
      */
     protected int probeValIndex;
 
-    /* Whether or not we need to sort the values (sorting should only
-     * happen once).  If all values were specified as literals (as
-     * opposed to parameters) then we did the sort at compile time
-     * and so we do not need to do it here.
+    /* Whether or not we need to sort the values.  If all values were
+     * specified as literals (as opposed to parameters) then we did the
+     * sort at compile time and so we do not need to do it here.
      */
     private boolean needSort;
 
@@ -154,7 +159,7 @@
                 " is not the case.");
         }
 
-        this.probeValues = probingVals;
+        this.origProbeValues = probingVals;
         this.needSort = !probeValsAreSorted;
     }
 
@@ -183,17 +188,16 @@
              * ideal, but it works for now.
              */
             DataValueDescriptor [] pVals =
-                new DataValueDescriptor[probeValues.length];
+                new DataValueDescriptor[origProbeValues.length];
 
             for (int i = 0; i < pVals.length; i++)
-                pVals[i] = probeValues[i].getClone();
+                pVals[i] = origProbeValues[i].getClone();
 
             java.util.Arrays.sort(pVals);
             probeValues = pVals;
-
-            // Only sort once.
-            needSort = false;
         }
+        else
+            probeValues = origProbeValues;
 
         probeValIndex = 0;
         super.openCore();