db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bpendle...@apache.org
Subject svn commit: r768597 [2/4] - in /db/derby/code/trunk/java: engine/org/apache/derby/ engine/org/apache/derby/catalog/ engine/org/apache/derby/iapi/sql/conn/ engine/org/apache/derby/iapi/sql/dictionary/ engine/org/apache/derby/iapi/sql/execute/ engine/org...
Date Sat, 25 Apr 2009 20:21:04 GMT
Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/NoRowsResultSetImpl.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/NoRowsResultSetImpl.java?rev=768597&r1=768596&r2=768597&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/NoRowsResultSetImpl.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/NoRowsResultSetImpl.java Sat Apr 25 20:21:03 2009
@@ -43,6 +43,8 @@
 import org.apache.derby.iapi.sql.execute.ExecRow;
 import org.apache.derby.iapi.sql.execute.NoPutResultSet;
 import org.apache.derby.iapi.sql.execute.ResultSetStatisticsFactory;
+import org.apache.derby.iapi.sql.execute.RunTimeStatistics;
+import org.apache.derby.iapi.sql.execute.xplain.XPLAINVisitor;
 import org.apache.derby.iapi.types.DataTypeDescriptor;
 import org.apache.derby.iapi.types.DataValueDescriptor;
 
@@ -368,21 +370,17 @@
                     lcc.getLanguageConnectionFactory().
                          getExecutionFactory().getResultSetStatisticsFactory();
 
-				lcc.setRunTimeStatisticsObject(
-					rssf.getRunTimeStatistics(activation, this, subqueryTrackingArray));
+                // get the RuntimeStatisticsImpl object which is the wrapper for all 
+                // statistics
+                RunTimeStatistics rsImpl = rssf.getRunTimeStatistics(activation, this, subqueryTrackingArray); 
+
+                // save RTS object in lcc
+                lcc.setRunTimeStatisticsObject(rsImpl);
+                
+                // explain gathered statistics
+                XPLAINVisitor visitor =  lcc.getLanguageConnectionFactory().getExecutionFactory().getXPLAINFactory().getXPLAINVisitor();
+                visitor.doXPLAIN(rsImpl,activation);
 
-				HeaderPrintWriter istream = lcc.getLogQueryPlan() ? Monitor.getStream() : null;
-				if (istream != null)
-				{
-					istream.printlnWithHeader(LanguageConnectionContext.xidStr + 
-											  lcc.getTransactionExecute().getTransactionIdString() +
-											  "), " +
-											  LanguageConnectionContext.lccStr +
-											  lcc.getInstanceNumber() +
-											  "), " +
-											  lcc.getRunTimeStatisticsObject().getStatementText() + " ******* " +
-											  lcc.getRunTimeStatisticsObject().getStatementExecutionPlanText());
-				}
 			}
 			dumpedStats = true;
 		}

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/rts/RealAnyResultSetStatistics.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/rts/RealAnyResultSetStatistics.java?rev=768597&r1=768596&r2=768597&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/rts/RealAnyResultSetStatistics.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/rts/RealAnyResultSetStatistics.java Sat Apr 25 20:21:03 2009
@@ -27,6 +27,11 @@
 import org.apache.derby.iapi.reference.SQLState;
 
 import org.apache.derby.iapi.services.io.FormatableHashtable;
+import org.apache.derby.catalog.UUID;
+import org.apache.derby.impl.sql.catalog.XPLAINResultSetDescriptor;
+import org.apache.derby.impl.sql.catalog.XPLAINResultSetTimingsDescriptor;
+import org.apache.derby.impl.sql.execute.xplain.XPLAINUtil;
+import org.apache.derby.iapi.sql.execute.xplain.XPLAINVisitor;
 
 import java.io.ObjectOutput;
 import java.io.ObjectInput;
@@ -159,4 +164,28 @@
   public String getNodeName(){
     return MessageService.getTextMessage(SQLState.RTS_ANY_RS);
   }
+  
+  // -----------------------------------------------------
+  // XPLAINable Implementation
+  // -----------------------------------------------------
+  
+    public void accept(XPLAINVisitor visitor) {
+        // I have only one child
+        visitor.setNumberOfChildren(1);
+        
+        // pre-order, depth-first traversal
+        // me first
+        visitor.visit(this);
+        // then my child
+        childResultSetStatistics.accept(visitor);
+	}
+  
+    public String getRSXplainType() { return XPLAINUtil.OP_ANY; }
+    public String getRSXplainDetails()
+    {
+        String attachmentString = (this.pointOfAttachment == -1) ? "" :
+                 "ATTACHED:" + this.pointOfAttachment;
+
+        return attachmentString + ";" + this.resultSetNumber;
+    }
 }

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/rts/RealBasicNoPutResultSetStatistics.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/rts/RealBasicNoPutResultSetStatistics.java?rev=768597&r1=768596&r2=768597&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/rts/RealBasicNoPutResultSetStatistics.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/rts/RealBasicNoPutResultSetStatistics.java Sat Apr 25 20:21:03 2009
@@ -21,6 +21,11 @@
 
 package org.apache.derby.impl.sql.execute.rts;
 
+import org.apache.derby.catalog.UUID;
+import org.apache.derby.impl.sql.catalog.XPLAINResultSetDescriptor;
+import org.apache.derby.impl.sql.catalog.XPLAINResultSetTimingsDescriptor;
+import org.apache.derby.impl.sql.execute.xplain.XPLAINUtil;
+
 import org.apache.derby.iapi.services.io.StoredFormatIds;
 import org.apache.derby.iapi.services.io.Formatable;
 
@@ -236,4 +241,59 @@
 	{
 		return optimizerEstimatedRowCount;
 	}
+
+    public String getRSXplainDetails() { return null; }
+
+    public Object getResultSetDescriptor(Object rsID, Object parentID,
+            Object scanID, Object sortID, Object stmtID, Object timingID)
+    {
+        return new XPLAINResultSetDescriptor(
+           (UUID)rsID,
+           getRSXplainType(),
+           getRSXplainDetails(),
+           new Integer(this.numOpens),
+           null,                              // the number of index updates 
+           null,                           // lock mode
+           null,                           // lock granularity
+           (UUID)parentID,
+           new Double(this.optimizerEstimatedRowCount),
+           new Double(this.optimizerEstimatedCost),
+           null,                              // the affected rows
+           null,                              // the deferred rows
+           null,                              // the input rows
+           new Integer(this.rowsSeen),
+           null,                              // the seen rows right
+           new Integer(this.rowsFiltered),
+           new Integer(this.rowsSeen - this.rowsFiltered),
+           null,                              // the empty right rows
+           null,                           // index key optimization
+           (UUID)scanID,
+           (UUID)sortID,
+           (UUID)stmtID,
+           (UUID)timingID);
+    }
+    public Object getResultSetTimingsDescriptor(Object timingID)
+    {
+        return new XPLAINResultSetTimingsDescriptor(
+           (UUID)timingID,
+           new Long(this.constructorTime),
+           new Long(this.openTime),
+           new Long(this.nextTime),
+           new Long(this.closeTime),
+           new Long(this.getNodeTime()),
+           XPLAINUtil.getAVGNextTime( (long)this.nextTime, this.rowsSeen),
+           null,                          // the projection time
+           null,                          // the restriction time
+           null,                          // the temp_cong_create_time
+           null                           // the temo_cong_fetch_time
+        );
+    }
+    public Object getSortPropsDescriptor(Object UUID)
+    {
+        return null; // Most statistics classes don't have sort props
+    }
+    public Object getScanPropsDescriptor(Object UUID)
+    {
+        return null; // Most statistics classes don't have Scan props
+    }
 }

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/rts/RealCurrentOfStatistics.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/rts/RealCurrentOfStatistics.java?rev=768597&r1=768596&r2=768597&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/rts/RealCurrentOfStatistics.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/rts/RealCurrentOfStatistics.java Sat Apr 25 20:21:03 2009
@@ -24,6 +24,8 @@
 import org.apache.derby.iapi.services.io.StoredFormatIds;
 
 import org.apache.derby.iapi.services.i18n.MessageService;
+import org.apache.derby.iapi.sql.execute.xplain.XPLAINVisitor;
+import org.apache.derby.impl.sql.execute.xplain.XPLAINUtil;
 import org.apache.derby.iapi.reference.SQLState;
 import java.io.ObjectOutput;
 import java.io.ObjectInput;
@@ -120,4 +122,18 @@
 	// NOTE: Not internationalizing because "CURRENT OF" are keywords.
     return "Current Of";
   }
+  
+  // -----------------------------------------------------
+  // XPLAINable Implementation
+  // -----------------------------------------------------
+  
+    public void accept(XPLAINVisitor visitor) {
+        visitor.setNumberOfChildren(0);
+        //
+        // Note that visiting this node does nothing in the current XPLAIN
+        // implementation. In a future version, we may add XPLAIN support
+        // for this node in XPLAINSystemTableVisitor.
+        visitor.visit(this);
+	}
+    public String getRSXplainType() { return XPLAINUtil.OP_CURRENT_OF; }
 }

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/rts/RealDeleteCascadeResultSetStatistics.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/rts/RealDeleteCascadeResultSetStatistics.java?rev=768597&r1=768596&r2=768597&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/rts/RealDeleteCascadeResultSetStatistics.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/rts/RealDeleteCascadeResultSetStatistics.java Sat Apr 25 20:21:03 2009
@@ -23,6 +23,8 @@
 
 import org.apache.derby.iapi.services.i18n.MessageService;
 import org.apache.derby.iapi.reference.SQLState;
+import org.apache.derby.iapi.sql.execute.xplain.XPLAINVisitor;
+import org.apache.derby.impl.sql.execute.xplain.XPLAINUtil;
 
 /**
   ResultSetStatistics implemenation for DeleteCascadeResultSet.
@@ -167,6 +169,57 @@
   public String getNodeName(){
     return MessageService.getTextMessage(SQLState.RTS_DELETE_CASCADE);
   }
+  
+  // -----------------------------------------------------
+  // XPLAINable Implementation
+  // -----------------------------------------------------
+  
+    public void accept(XPLAINVisitor visitor) {
+        // compute number of children of this node, which get visited
+        int noChildren = 0;
+        if(this.sourceResultSetStatistics!=null) noChildren++;
+        if(this.dependentTrackingArray!=null){
+            noChildren += dependentTrackingArray.length;
+        }
+        // inform the visitor
+        visitor.setNumberOfChildren(noChildren);
+        
+        // pre-order, depth-first traversal
+        // me first
+        visitor.visit(this);
+        // then my direct child
+        if(sourceResultSetStatistics!=null){
+            sourceResultSetStatistics.accept(visitor);
+        }
+        // and now the dependant resultsets, if there are any
+        if (dependentTrackingArray != null)
+        {
+            boolean foundAttached = false;
+
+            for (int index = 0; index < dependentTrackingArray.length; index++)
+            {
+                if (dependentTrackingArray[index] != null)
+                {
+                    // TODO add additional dependant referential action ?
+                    /*
+                    if (! foundAttached)
+                    {
+                        dependentInfo = indent  + "\n" +
+                            MessageService.getTextMessage(
+                                                SQLState.RTS_REFACTION_DEPENDENT) +
+                                ":\n";
+                        foundAttached = true;
+                    }*/
+                    
+                    dependentTrackingArray[index].accept(visitor);
+                }
+            }
+        }
+        
+        
+    }
+
+    public String getRSXplainDetails() { return XPLAINUtil.OP_CASCADE; }
 }
 
 

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/rts/RealDeleteResultSetStatistics.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/rts/RealDeleteResultSetStatistics.java?rev=768597&r1=768596&r2=768597&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/rts/RealDeleteResultSetStatistics.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/rts/RealDeleteResultSetStatistics.java Sat Apr 25 20:21:03 2009
@@ -22,6 +22,11 @@
 package org.apache.derby.impl.sql.execute.rts;
 
 import org.apache.derby.iapi.services.i18n.MessageService;
+import org.apache.derby.iapi.sql.execute.xplain.XPLAINVisitor;
+import org.apache.derby.catalog.UUID;
+import org.apache.derby.impl.sql.catalog.XPLAINResultSetDescriptor;
+import org.apache.derby.impl.sql.catalog.XPLAINResultSetTimingsDescriptor;
+import org.apache.derby.impl.sql.execute.xplain.XPLAINUtil;
 import org.apache.derby.iapi.reference.SQLState;
 
 /**
@@ -126,4 +131,55 @@
   public String getNodeName(){
     return MessageService.getTextMessage(SQLState.RTS_DELETE);
   }
+  
+  // -----------------------------------------------------
+  // XPLAINable Implementation
+  // -----------------------------------------------------
+  
+    public void accept(XPLAINVisitor visitor) {
+        int noChildren = 0;
+        if(this.sourceResultSetStatistics!=null) noChildren++;
+        
+        //inform the visitor
+        visitor.setNumberOfChildren(noChildren);
+        
+        // pre-order, depth-first traversal
+        // me first
+        visitor.visit(this);
+        // then my child
+        if(sourceResultSetStatistics!=null){
+            sourceResultSetStatistics.accept(visitor);
+		}
+
+    }
+    public String getRSXplainType() { return XPLAINUtil.OP_DELETE; }
+    public Object getResultSetDescriptor(Object rsID, Object parentID,
+            Object scanID, Object sortID, Object stmtID, Object timingID)
+    {
+        return new XPLAINResultSetDescriptor(
+           (UUID)rsID,
+           getRSXplainType(),
+           getRSXplainDetails(),
+           null,                              // the number of opens
+           new Integer(this.indexesUpdated),
+           null,                           // lock mode
+           this.tableLock?"T":"R",
+           (UUID)parentID,
+           null,                             // estimated row count
+           null,                             // estimated cost
+           new Integer(this.rowCount),
+           XPLAINUtil.getYesNoCharFromBoolean(this.deferred),
+           null,                              // the input rows
+           null,                              // the seen rows left
+           null,                              // the seen rows right
+           null,                              // the filtered rows
+           null,                              // the returned rows
+           null,                              // the empty right rows
+           null,                           // index key optimization
+           (UUID)scanID,
+           (UUID)sortID,
+           (UUID)stmtID,
+           (UUID)timingID);
+    }
+
 }

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/rts/RealDeleteVTIResultSetStatistics.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/rts/RealDeleteVTIResultSetStatistics.java?rev=768597&r1=768596&r2=768597&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/rts/RealDeleteVTIResultSetStatistics.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/rts/RealDeleteVTIResultSetStatistics.java Sat Apr 25 20:21:03 2009
@@ -22,6 +22,11 @@
 package org.apache.derby.impl.sql.execute.rts;
 
 import org.apache.derby.iapi.services.i18n.MessageService;
+import org.apache.derby.catalog.UUID;
+import org.apache.derby.impl.sql.catalog.XPLAINResultSetDescriptor;
+import org.apache.derby.impl.sql.catalog.XPLAINResultSetTimingsDescriptor;
+import org.apache.derby.iapi.sql.execute.xplain.XPLAINVisitor;
+import org.apache.derby.impl.sql.execute.xplain.XPLAINUtil;
 import org.apache.derby.iapi.reference.SQLState;
 
 /**
@@ -107,4 +112,56 @@
   public String getNodeName(){
     return MessageService.getTextMessage(SQLState.RTS_DELETE_VTI);
   }
+  
+  //------------------------------------------------------
+  // XPLAINable Implementation
+  // -----------------------------------------------------
+  
+    public void accept(XPLAINVisitor visitor) {
+        int noChildren = 0;
+        if(this.sourceResultSetStatistics!=null) noChildren++;
+        
+        //inform the visitor
+        visitor.setNumberOfChildren(noChildren);
+        
+        // pre-order, depth-first traversal
+        // me first
+        visitor.visit(this);
+        // then my child
+        if(sourceResultSetStatistics!=null){
+            sourceResultSetStatistics.accept(visitor);
+		}
+
+    }
+    public String getRSXplainType() { return XPLAINUtil.OP_DELETE; }
+    public String getRSXplainDetails() { return XPLAINUtil.OP_VTI; }
+    public Object getResultSetDescriptor(Object rsID, Object parentID,
+            Object scanID, Object sortID, Object stmtID, Object timingID)
+    {
+        return new XPLAINResultSetDescriptor(
+           (UUID)rsID,
+           getRSXplainType(),
+           getRSXplainDetails(),
+           null,                              // the number of opens
+           null,                              // the number of index updates 
+           null,                           // lock mode
+           null,                           // lock granularity
+           (UUID)parentID,
+           null,                             // estimated row count
+           null,                             // estimated cost
+           new Integer(this.rowCount),
+           null,                              // the deferred rows.
+           null,                              // the input rows
+           null,                              // the seen rows left
+           null,                              // the seen rows right
+           null,                              // the filtered rows
+           null,                              // the returned rows
+           null,                              // the empty right rows
+           null,                           // index key optimization
+           (UUID)scanID,
+           (UUID)sortID,
+           (UUID)stmtID,
+           (UUID)timingID);
+    }
+
 }

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/rts/RealDistinctScalarAggregateStatistics.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/rts/RealDistinctScalarAggregateStatistics.java?rev=768597&r1=768596&r2=768597&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/rts/RealDistinctScalarAggregateStatistics.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/rts/RealDistinctScalarAggregateStatistics.java Sat Apr 25 20:21:03 2009
@@ -22,6 +22,8 @@
 package org.apache.derby.impl.sql.execute.rts;
 
 import org.apache.derby.iapi.services.i18n.MessageService;
+import org.apache.derby.impl.sql.execute.xplain.XPLAINUtil;
+import org.apache.derby.iapi.sql.execute.xplain.XPLAINVisitor;
 import org.apache.derby.iapi.reference.SQLState;
 
 /**
@@ -136,4 +138,22 @@
   public String getNodeName(){
     return MessageService.getTextMessage(SQLState.RTS_DISTINCT_SCALAR_AGG);
   }
+  
+  // -----------------------------------------------------
+  // XPLAINable Implementation
+  // -----------------------------------------------------
+  
+    public void accept(XPLAINVisitor visitor) {
+        // I have only one child
+        visitor.setNumberOfChildren(1);
+        
+        // pre-order, depth-first traversal
+        // me first
+        visitor.visit(this);
+        // then my child
+        childResultSetStatistics.accept(visitor);
+	}
+
+    public String getRSXplainDetails() { return XPLAINUtil.OP_DISTINCT; }
+
 }

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/rts/RealDistinctScanStatistics.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/rts/RealDistinctScanStatistics.java?rev=768597&r1=768596&r2=768597&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/rts/RealDistinctScanStatistics.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/rts/RealDistinctScanStatistics.java Sat Apr 25 20:21:03 2009
@@ -24,6 +24,9 @@
 import org.apache.derby.iapi.util.PropertyUtil;
 
 import org.apache.derby.iapi.services.i18n.MessageService;
+import org.apache.derby.catalog.UUID;
+import org.apache.derby.impl.sql.execute.xplain.XPLAINUtil;
+import org.apache.derby.iapi.sql.execute.xplain.XPLAINVisitor;
 import org.apache.derby.iapi.reference.SQLState;
 
 import java.util.Enumeration;
@@ -254,4 +257,19 @@
 	{
 		return MessageService.getTextMessage(SQLState.RTS_DISTINCT_SCAN);
 	}
+	
+    // -----------------------------------------------------
+    // XPLAINable Implementation
+    // -----------------------------------------------------
+    
+      public void accept(XPLAINVisitor visitor) {
+          // I have no children
+          visitor.setNumberOfChildren(0);
+          // pre-order, depth-first traversal
+          // me first
+          visitor.visit(this);
+          // I´m a leaf node, I have no children ...
+      }
+
+    public String getRSXplainType() { return XPLAINUtil.OP_DISTINCTSCAN; }
 }

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/rts/RealGroupedAggregateStatistics.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/rts/RealGroupedAggregateStatistics.java?rev=768597&r1=768596&r2=768597&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/rts/RealGroupedAggregateStatistics.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/rts/RealGroupedAggregateStatistics.java Sat Apr 25 20:21:03 2009
@@ -21,7 +21,14 @@
 
 package org.apache.derby.impl.sql.execute.rts;
 
+import org.apache.derby.catalog.UUID;
+import org.apache.derby.impl.sql.catalog.XPLAINResultSetDescriptor;
+import org.apache.derby.impl.sql.catalog.XPLAINResultSetTimingsDescriptor;
+import org.apache.derby.impl.sql.catalog.XPLAINSortPropsDescriptor;
+import org.apache.derby.impl.sql.execute.xplain.XPLAINUtil;
+
 import org.apache.derby.iapi.services.i18n.MessageService;
+import org.apache.derby.iapi.sql.execute.xplain.XPLAINVisitor;
 import org.apache.derby.iapi.reference.SQLState;
 
 import org.apache.derby.iapi.util.PropertyUtil;
@@ -167,4 +174,78 @@
   public String getNodeName(){
     return MessageService.getTextMessage(SQLState.RTS_GROUPED_AGG);
   }
+  
+  // -----------------------------------------------------
+  // XPLAINable Implementation
+  // -----------------------------------------------------
+  
+    public void accept(XPLAINVisitor visitor) {
+        int noChildren = 0;
+        if(this.childResultSetStatistics!=null) noChildren++;
+        
+        //inform the visitor
+        visitor.setNumberOfChildren(noChildren);
+
+        // pre-order, depth-first traversal
+        // me first
+        visitor.visit(this);
+        // then my child
+        if(childResultSetStatistics!=null){
+            childResultSetStatistics.accept(visitor);
+		}
+
+    }
+
+    public String getRSXplainType() { return XPLAINUtil.OP_GROUP; }
+    public Object getResultSetDescriptor(Object rsID, Object parentID,
+            Object scanID, Object sortID, Object stmtID, Object timingID)
+    {
+        return new XPLAINResultSetDescriptor(
+           (UUID)rsID,
+           getRSXplainType(),
+           getRSXplainDetails(),
+           new Integer(this.numOpens),
+           null,                              // the number of index updates 
+           null,                           // lock mode
+           null,                           // lock granularity
+           (UUID)parentID,
+           new Double(this.optimizerEstimatedRowCount),
+           new Double(this.optimizerEstimatedCost),
+           null,                              // the affected rows
+           null,                              // the deferred rows
+           new Integer(this.rowsInput),
+           new Integer(this.rowsSeen),
+           null,                              // the seen rows right
+           new Integer(this.rowsFiltered),
+           null,                              // the rows returned
+           null,                              // the empty right rows
+           null,                           // index key optimization
+           (UUID)scanID,
+           (UUID)sortID,
+           (UUID)stmtID,
+           (UUID)timingID);
+    }
+    public Object getSortPropsDescriptor(Object sortPropsID)
+    {
+        Properties props = this.sortProperties;
+        
+        // create new scan info descriptor with some basic information
+        XPLAINSortPropsDescriptor sortRSDescriptor =            
+          new XPLAINSortPropsDescriptor(
+              (UUID)sortPropsID,      // the sort props UUID
+              null,             // the sort type, either (C)onstraint, (I)ndex or (T)able
+              null,                // the number of input rows
+              null,                // the number of output rows
+              null,                // the number of merge runs
+              null,             // merge run details
+              null,             // eliminate duplicates
+              XPLAINUtil.getYesNoCharFromBoolean(
+                    this.inSortedOrder),      // in sorted order
+              XPLAINUtil.getYesNoCharFromBoolean(
+                    this.hasDistinctAggregate)   // distinct_aggregate
+            );
+        
+        // fill additional information from scan properties
+        return XPLAINUtil.extractSortProps(sortRSDescriptor,props);
+    }
 }

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/rts/RealHashJoinStatistics.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/rts/RealHashJoinStatistics.java?rev=768597&r1=768596&r2=768597&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/rts/RealHashJoinStatistics.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/rts/RealHashJoinStatistics.java Sat Apr 25 20:21:03 2009
@@ -23,6 +23,7 @@
 
 import org.apache.derby.iapi.services.i18n.MessageService;
 import org.apache.derby.iapi.reference.SQLState;
+import org.apache.derby.impl.sql.execute.xplain.XPLAINUtil;
 
 /**
   ResultSetStatistics implemenation for HashJoinResultSet.
@@ -105,4 +106,14 @@
 											SQLState.RTS_HASH_JOIN_RS);
 		}
 	}
+    public String getRSXplainType() { return XPLAINUtil.OP_JOIN_HASH; }
+    public String getRSXplainDetails()
+    {
+        String op_details = "("+this.resultSetNumber + ")" +
+            this.resultSetName       + ", ";
+
+        // check to see if this NL Join is part of an Exist clause
+        if (this.oneRowRightSide) op_details+= ", EXISTS JOIN";
+        return op_details;
+    }
 }

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/rts/RealHashLeftOuterJoinStatistics.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/rts/RealHashLeftOuterJoinStatistics.java?rev=768597&r1=768596&r2=768597&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/rts/RealHashLeftOuterJoinStatistics.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/rts/RealHashLeftOuterJoinStatistics.java Sat Apr 25 20:21:03 2009
@@ -21,6 +21,11 @@
 
 package org.apache.derby.impl.sql.execute.rts;
 
+import org.apache.derby.catalog.UUID;
+import org.apache.derby.impl.sql.catalog.XPLAINResultSetDescriptor;
+import org.apache.derby.impl.sql.catalog.XPLAINResultSetTimingsDescriptor;
+import org.apache.derby.impl.sql.execute.xplain.XPLAINUtil;
+
 import org.apache.derby.iapi.services.i18n.MessageService;
 import org.apache.derby.iapi.reference.SQLState;
 
@@ -93,4 +98,42 @@
 		resultSetName =
 			MessageService.getTextMessage(SQLState.RTS_HASH_LEFT_OJ_RS);
 	}
+    public String getRSXplainType() { return XPLAINUtil.OP_JOIN_HASH_LO; }
+    public String getRSXplainDetails()
+    {
+        String op_details = "("+this.resultSetNumber + ")" +
+            this.resultSetName       + ", ";
+
+        // check to see if this NL Join is part of an Exist clause
+        if (this.oneRowRightSide) op_details+= ", EXISTS JOIN";
+        return op_details;
+    }
+    public Object getResultSetDescriptor(Object rsID, Object parentID,
+            Object scanID, Object sortID, Object stmtID, Object timingID)
+    {
+        return new XPLAINResultSetDescriptor(
+           (UUID)rsID,
+           getRSXplainType(),
+           getRSXplainDetails(),
+           new Integer(this.numOpens),
+           null,                           // index updates
+           null,                           // lock mode
+           null,                           // lock granularity
+           (UUID)parentID,
+           new Double(this.optimizerEstimatedRowCount),
+           new Double(this.optimizerEstimatedCost),
+           null,                              // affected rows
+           null,                              // deferred rows
+           null,                              // the input rows
+           new Integer(this.rowsSeenLeft),
+           new Integer(this.rowsSeenRight),
+           new Integer(this.rowsFiltered),
+           new Integer(this.rowsReturned),
+           new Integer(this.emptyRightRowsReturned),
+           null,                           // index key optimization
+           (UUID)scanID,
+           (UUID)sortID,
+           (UUID)stmtID,
+           (UUID)timingID);
+    }
 }

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/rts/RealHashScanStatistics.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/rts/RealHashScanStatistics.java?rev=768597&r1=768596&r2=768597&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/rts/RealHashScanStatistics.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/rts/RealHashScanStatistics.java Sat Apr 25 20:21:03 2009
@@ -29,6 +29,12 @@
 
 import org.apache.derby.iapi.services.io.FormatableHashtable;
 import org.apache.derby.iapi.services.io.FormatableProperties;
+import org.apache.derby.catalog.UUID;
+import org.apache.derby.impl.sql.catalog.XPLAINResultSetDescriptor;
+import org.apache.derby.impl.sql.catalog.XPLAINResultSetTimingsDescriptor;
+import org.apache.derby.impl.sql.catalog.XPLAINScanPropsDescriptor;
+import org.apache.derby.impl.sql.execute.xplain.XPLAINUtil;
+import org.apache.derby.iapi.sql.execute.xplain.XPLAINVisitor;
 
 import java.io.ObjectOutput;
 import java.io.ObjectInput;
@@ -279,4 +285,106 @@
   public String getNodeName(){
     return MessageService.getTextMessage(SQLState.RTS_HASH_SCAN);
   }
+  
+  // -----------------------------------------------------
+  // XPLAINable Implementation
+  // -----------------------------------------------------
+  
+    public void accept(XPLAINVisitor visitor) {
+        //inform the visitor about my children
+        visitor.setNumberOfChildren(0);
+        
+        // pre-order, depth-first traversal
+        // me first
+        visitor.visit(this);
+        // I´m a leaf node, I have no children ...
+        
+    }
+    public String getRSXplainType() { return XPLAINUtil.OP_HASHSCAN; }
+    public String getRSXplainDetails()
+    {
+        if (this.indexName!=null)
+            return (this.isConstraint ? "C: " : "I: ") + this.indexName;
+        else
+            return "T: " + this.tableName;
+    }
+    public Object getScanPropsDescriptor(Object scanPropsID)
+    {
+        String scanObjectType, scanObjectName;
+
+        if(this.indexName!=null){
+            if(this.isConstraint){
+                scanObjectType = "C";  // constraint
+                scanObjectName = this.indexName;
+            } else {
+                scanObjectType = "I";  // index
+                scanObjectName = this.indexName;
+            }
+        } else {
+            scanObjectType = "T";      // table
+            scanObjectName = this.tableName;
+        }
+        
+        String isoLevel = XPLAINUtil.getIsolationLevelCode(this.isolationLevel);
+        String hashkey_columns =
+            XPLAINUtil.getHashKeyColumnNumberString(this.hashKeyColumns);
+        
+        XPLAINScanPropsDescriptor scanRSDescriptor =            
+              new XPLAINScanPropsDescriptor(
+              (UUID)scanPropsID,      // the scan props UUID
+              scanObjectName,
+              scanObjectType,
+              null,             // the scan type: heap, btree, sort
+              isoLevel,         // the isolation level
+              null,             // the number of visited pages
+              null,             // the number of visited rows
+              null,             // the number of qualified rows
+              null,             // the number of visited deleted rows
+              null,             // the number of fetched columns
+              null,             // the bitset of fetched columns
+              null,             // the btree height
+              null,             // the fetch size
+              this.startPosition,
+              this.stopPosition,
+              this.scanQualifiers,
+              this.nextQualifiers,
+              hashkey_columns,
+              new Integer(this.hashtableSize)
+            );
+        
+        FormatableProperties props = this.scanProperties;
+
+        return XPLAINUtil.extractScanProps(scanRSDescriptor,props);
+    }
+    public Object getResultSetDescriptor(Object rsID, Object parentID,
+            Object scanID, Object sortID, Object stmtID, Object timingID)
+    {
+        String lockMode = XPLAINUtil.getLockModeCode(this.lockString);
+        String lockGran = XPLAINUtil.getLockGranularityCode(this.lockString);
+        
+        return new XPLAINResultSetDescriptor(
+           (UUID)rsID,
+           getRSXplainType(),
+           getRSXplainDetails(),
+           new Integer(this.numOpens),            // the number of opens
+           null,                           // the number of index updates 
+           lockMode,                       // lock mode
+           lockGran,                       // lock granularity
+           (UUID)parentID,
+           new Double(this.optimizerEstimatedRowCount),
+           new Double(this.optimizerEstimatedCost),
+           null,                              // the affected rows
+           null,                              // the deferred rows
+           null,                              // the input rows
+           new Integer(this.rowsSeen),            // the seen rows
+           null,                              // the seen rows right
+           new Integer(this.rowsFiltered),        // the filtered rows
+           new Integer(this.rowsSeen-this.rowsFiltered),// the returned rows
+           null,                              // the empty right rows
+           null,                           // index key optimization
+           (UUID)scanID,
+           (UUID)sortID,
+           (UUID)stmtID,
+           (UUID)timingID);
+    }
 }

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/rts/RealHashTableStatistics.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/rts/RealHashTableStatistics.java?rev=768597&r1=768596&r2=768597&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/rts/RealHashTableStatistics.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/rts/RealHashTableStatistics.java Sat Apr 25 20:21:03 2009
@@ -28,6 +28,10 @@
 
 import org.apache.derby.iapi.services.io.FormatableHashtable;
 import org.apache.derby.iapi.services.io.FormatableProperties;
+import org.apache.derby.catalog.UUID;
+import org.apache.derby.impl.sql.catalog.XPLAINScanPropsDescriptor;
+import org.apache.derby.impl.sql.execute.xplain.XPLAINUtil;
+import org.apache.derby.iapi.sql.execute.xplain.XPLAINVisitor;
 
 import java.io.ObjectOutput;
 import java.io.ObjectInput;
@@ -244,4 +248,89 @@
   public String getNodeName(){
     return MessageService.getTextMessage(SQLState.RTS_HASH_TABLE);
   }
+  
+  // -----------------------------------------------------
+  // XPLAINable Implementation
+  // -----------------------------------------------------
+  
+    public void accept(XPLAINVisitor visitor) {
+        // compute number of children of this node, which get visited
+        int noChildren = 0;
+        if(this.childResultSetStatistics!=null) noChildren++;
+        if(this.subqueryTrackingArray!=null){
+            noChildren += subqueryTrackingArray.length;
+        }
+        // inform the visitor
+        visitor.setNumberOfChildren(noChildren);
+        
+        // pre-order, depth-first traversal
+        // me first
+        visitor.visit(this);
+        // then my direct child
+        if(childResultSetStatistics!=null){
+            childResultSetStatistics.accept(visitor);
+        }
+        // and now the dependant resultsets, if there are any
+        if (subqueryTrackingArray != null)
+        {
+            boolean foundAttached = false;
+
+            for (int index = 0; index < subqueryTrackingArray.length; index++)
+            {
+                if (subqueryTrackingArray[index] != null)
+                {
+                    // TODO add additional dependant referential action ?
+                    /*
+                    if (! foundAttached)
+                    {
+                        dependentInfo = indent  + "\n" +
+                            MessageService.getTextMessage(
+                                                SQLState.RTS_REFACTION_DEPENDENT) +
+                                ":\n";
+                        foundAttached = true;
+                    }*/
+                    
+                    subqueryTrackingArray[index].accept(visitor);
+                }
+            }
+        }
+    }
+    public String getRSXplainType() { return XPLAINUtil.OP_HASHTABLE; }
+    public String getRSXplainDetails() { return "("+this.resultSetNumber+")"; }
+    public Object getScanPropsDescriptor(Object scanPropsID)
+    {
+        FormatableProperties props = this.scanProperties;
+        
+        String isoLevel = XPLAINUtil.getIsolationLevelCode(this.isolationLevel);
+        
+        String hashkey_columns =
+            XPLAINUtil.getHashKeyColumnNumberString(this.hashKeyColumns);
+        
+        // create new scan info descriptor with some basic information
+        XPLAINScanPropsDescriptor scanRSDescriptor =            
+              new XPLAINScanPropsDescriptor(
+              (UUID)scanPropsID,      // the scan props UUID
+              "Temporary HashTable", // the index/table name
+              null,             // the scan object, either (C)onstraint, (I)ndex or (T)able
+              null,             // the scan type: heap, btree, sort
+              isoLevel,         // the isolation level
+              null,             // the number of visited pages
+              null,             // the number of visited rows
+              null,             // the number of qualified rows
+              null,             // the number of visited deleted rows
+              null,             // the number of fetched columns
+              null,             // the bitset of fetched columns
+              null,             // the btree height
+              null,             // the fetch size
+              null,                          // the start position, internal encoding
+              null,                          // the stop position, internal encoding
+              null,                          // the scan qualifiers
+              this.nextQualifiers,     // the next qualifiers
+              hashkey_columns,               // the hash key column numbers
+              new Integer(this.hashtableSize) // the hash table size
+            );
+        
+        // fill additional information from scan properties
+        return XPLAINUtil.extractScanProps(scanRSDescriptor,props);
+    }
 }

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/rts/RealIndexRowToBaseRowStatistics.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/rts/RealIndexRowToBaseRowStatistics.java?rev=768597&r1=768596&r2=768597&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/rts/RealIndexRowToBaseRowStatistics.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/rts/RealIndexRowToBaseRowStatistics.java Sat Apr 25 20:21:03 2009
@@ -33,6 +33,9 @@
 import java.io.ObjectInput;
 import java.io.IOException;
 
+import org.apache.derby.impl.sql.execute.xplain.XPLAINUtil;
+import org.apache.derby.iapi.sql.execute.xplain.XPLAINVisitor;
+
 /**
   ResultSetStatistics implemenation for IndexRowToBaseRowResultSet.
 
@@ -182,4 +185,30 @@
 	{
 		return childResultSetStatistics;
 	}
+	
+    // -----------------------------------------------------
+    // XPLAINable Implementation
+    // -----------------------------------------------------
+	
+    public void accept(XPLAINVisitor visitor) {
+        int noChildren = 0;
+        if(this.childResultSetStatistics!=null) noChildren++;
+        
+        //inform the visitor
+        visitor.setNumberOfChildren(noChildren);
+        
+        // pre-order, depth-first traversal
+        // me first
+        visitor.visit(this);
+        // then my child
+        if(childResultSetStatistics!=null){
+            childResultSetStatistics.accept(visitor);
+        }
+    }
+
+    public String getRSXplainType() { return XPLAINUtil.OP_ROWIDSCAN; }
+    public String getRSXplainDetails()
+    {
+        return "("+this.resultSetNumber+")," + this.tableName;
+    }
 }

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/rts/RealInsertResultSetStatistics.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/rts/RealInsertResultSetStatistics.java?rev=768597&r1=768596&r2=768597&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/rts/RealInsertResultSetStatistics.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/rts/RealInsertResultSetStatistics.java Sat Apr 25 20:21:03 2009
@@ -27,6 +27,11 @@
 import org.apache.derby.iapi.reference.SQLState;
 
 import org.apache.derby.iapi.services.io.FormatableHashtable;
+import org.apache.derby.catalog.UUID;
+import org.apache.derby.impl.sql.catalog.XPLAINResultSetDescriptor;
+import org.apache.derby.impl.sql.catalog.XPLAINResultSetTimingsDescriptor;
+import org.apache.derby.impl.sql.execute.xplain.XPLAINUtil;
+import org.apache.derby.iapi.sql.execute.xplain.XPLAINVisitor;
 
 import java.io.ObjectOutput;
 import java.io.ObjectInput;
@@ -167,4 +172,59 @@
   public String getNodeName(){
     return MessageService.getTextMessage(SQLState.RTS_INSERT);
   }
+  
+  // -----------------------------------------------------
+  // XPLAINable Implementation
+  // -----------------------------------------------------
+  
+    public void accept(XPLAINVisitor visitor) {
+        int noChildren = 0;
+        if(this.sourceResultSetStatistics!=null) noChildren++;
+        
+        //inform the visitor
+        visitor.setNumberOfChildren(noChildren);
+
+        // pre-order, depth-first traversal
+        // me first
+        visitor.visit(this);
+        // then my child
+        if(sourceResultSetStatistics!=null){
+            sourceResultSetStatistics.accept(visitor);
+		}
+
+    }
+
+    public String getRSXplainType() { return XPLAINUtil.OP_INSERT; }
+    public String getRSXplainDetails()
+    {
+        return this.bulkInsertPerformed?XPLAINUtil.OP_BULK:null;
+    }
+    public Object getResultSetDescriptor(Object rsID, Object parentID,
+            Object scanID, Object sortID, Object stmtID, Object timingID)
+    {
+        return new XPLAINResultSetDescriptor(
+           (UUID)rsID,
+           getRSXplainType(),
+           getRSXplainDetails(),
+           null,                              // the number of opens
+           new Integer(this.indexesUpdated),
+           null,                           // lock mode
+           this.tableLock?"T":"R",
+           (UUID)parentID,
+           null,                             // estimated row count
+           null,                             // estimated cost
+           new Integer(this.rowCount),
+           XPLAINUtil.getYesNoCharFromBoolean(this.deferred),
+           null,                              // the input rows
+           null,                              // the seen rows left
+           null,                              // the seen rows right
+           null,                              // the filtered rows
+           null,                              // the returned rows
+           null,                              // the empty right rows
+           null,                           // index key optimization
+           (UUID)scanID,
+           (UUID)sortID,
+           (UUID)stmtID,
+           (UUID)timingID);
+    }
 }

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/rts/RealInsertVTIResultSetStatistics.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/rts/RealInsertVTIResultSetStatistics.java?rev=768597&r1=768596&r2=768597&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/rts/RealInsertVTIResultSetStatistics.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/rts/RealInsertVTIResultSetStatistics.java Sat Apr 25 20:21:03 2009
@@ -27,6 +27,11 @@
 import org.apache.derby.iapi.reference.SQLState;
 
 import org.apache.derby.iapi.services.io.FormatableHashtable;
+import org.apache.derby.catalog.UUID;
+import org.apache.derby.impl.sql.catalog.XPLAINResultSetDescriptor;
+import org.apache.derby.impl.sql.catalog.XPLAINResultSetTimingsDescriptor;
+import org.apache.derby.impl.sql.execute.xplain.XPLAINUtil;
+import org.apache.derby.iapi.sql.execute.xplain.XPLAINVisitor;
 
 import java.io.ObjectOutput;
 import java.io.ObjectInput;
@@ -121,4 +126,57 @@
   public String getNodeName(){
     return MessageService.getTextMessage(SQLState.RTS_INSERT_VTI);
   }
+  
+  // -----------------------------------------------------
+  // XPLAINable Implementation
+  // -----------------------------------------------------
+  
+    public void accept(XPLAINVisitor visitor) {
+        int noChildren = 0;
+        if(this.sourceResultSetStatistics!=null) noChildren++;
+        
+        //inform the visitor
+        visitor.setNumberOfChildren(noChildren);
+
+        // pre-order, depth-first traversal
+        // me first
+        visitor.visit(this);
+        // then my child
+        if(sourceResultSetStatistics!=null){
+            sourceResultSetStatistics.accept(visitor);
+		}
+
+    }
+
+    public String getRSXplainType() { return XPLAINUtil.OP_INSERT; }
+    public String getRSXplainDetails() { return XPLAINUtil.OP_VTI; }
+    public Object getResultSetDescriptor(Object rsID, Object parentID,
+            Object scanID, Object sortID, Object stmtID, Object timingID)
+    {
+        return new XPLAINResultSetDescriptor(
+           (UUID)rsID,
+           getRSXplainType(),
+           getRSXplainDetails(),
+           null,                              // the number of opens
+           null,                              // the number of index updates 
+           null,                           // lock mode
+           null,                           // lock granularity
+           (UUID)parentID,
+           null,                             // estimated row count
+           null,                             // estimated cost
+           new Integer(this.rowCount),
+           XPLAINUtil.getYesNoCharFromBoolean(this.deferred),
+           null,                              // the input rows
+           null,                              // the seen rows left
+           null,                              // the seen rows right
+           null,                              // the filtered rows
+           null,                              // the returned rows
+           null,                              // the empty right rows
+           null,                           // index key optimization
+           (UUID)scanID,
+           (UUID)sortID,
+           (UUID)stmtID,
+           (UUID)timingID);
+    }
+  
 }

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/rts/RealJoinResultSetStatistics.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/rts/RealJoinResultSetStatistics.java?rev=768597&r1=768596&r2=768597&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/rts/RealJoinResultSetStatistics.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/rts/RealJoinResultSetStatistics.java Sat Apr 25 20:21:03 2009
@@ -21,6 +21,11 @@
 
 package org.apache.derby.impl.sql.execute.rts;
 
+import org.apache.derby.catalog.UUID;
+import org.apache.derby.impl.sql.catalog.XPLAINResultSetDescriptor;
+import org.apache.derby.impl.sql.catalog.XPLAINResultSetTimingsDescriptor;
+import org.apache.derby.impl.sql.execute.xplain.XPLAINUtil;
+
 import org.apache.derby.iapi.services.io.StoredFormatIds;
 
 import org.apache.derby.iapi.services.i18n.MessageService;
@@ -101,4 +106,49 @@
   public String getNodeName(){
     return MessageService.getTextMessage(SQLState.RTS_JOIN);
   }
+    public Object getResultSetDescriptor(Object rsID, Object parentID,
+            Object scanID, Object sortID, Object stmtID, Object timingID)
+    {
+        return new XPLAINResultSetDescriptor(
+           (UUID)rsID,
+           getRSXplainType(),
+           getRSXplainDetails(),
+           new Integer(this.numOpens),
+           null,                           // index updates
+           null,                           // lock mode
+           null,                           // lock granularity
+           (UUID)parentID,
+           new Double(this.optimizerEstimatedRowCount),
+           new Double(this.optimizerEstimatedCost),
+           null,                              // affected rows
+           null,                              // deferred rows
+           null,                              // the input rows
+           new Integer(this.rowsSeenLeft),
+           new Integer(this.rowsSeenRight),
+           new Integer(this.rowsFiltered),
+           new Integer(this.rowsReturned),
+           null,                              // the empty right rows
+           null,                           // index key optimization
+           (UUID)scanID,
+           (UUID)sortID,
+           (UUID)stmtID,
+           (UUID)timingID);
+    }
+    public Object getResultSetTimingsDescriptor(Object timingID)
+    {
+        return new XPLAINResultSetTimingsDescriptor(
+           (UUID)timingID,
+           new Long(this.constructorTime),
+           new Long(this.openTime),
+           new Long(this.nextTime),
+           new Long(this.closeTime),
+           new Long(this.getNodeTime()),
+           XPLAINUtil.getAVGNextTime(
+               (long)this.nextTime, (this.rowsSeenLeft+this.rowsSeenRight)),
+           null,                          // the projection time
+           null,                          // the restriction time
+           null,                          // the temp_cong_create_time
+           null                           // the temo_cong_fetch_time
+        );
+    }
 }

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/rts/RealLastIndexKeyScanStatistics.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/rts/RealLastIndexKeyScanStatistics.java?rev=768597&r1=768596&r2=768597&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/rts/RealLastIndexKeyScanStatistics.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/rts/RealLastIndexKeyScanStatistics.java Sat Apr 25 20:21:03 2009
@@ -28,6 +28,12 @@
 
 import org.apache.derby.iapi.services.io.FormatableHashtable;
 import org.apache.derby.iapi.services.io.FormatableProperties;
+import org.apache.derby.catalog.UUID;
+import org.apache.derby.impl.sql.catalog.XPLAINResultSetDescriptor;
+import org.apache.derby.impl.sql.catalog.XPLAINResultSetTimingsDescriptor;
+import org.apache.derby.impl.sql.catalog.XPLAINScanPropsDescriptor;
+import org.apache.derby.impl.sql.execute.xplain.XPLAINUtil;
+import org.apache.derby.iapi.sql.execute.xplain.XPLAINVisitor;
 
 import java.io.ObjectOutput;
 import java.io.ObjectInput;
@@ -188,4 +194,84 @@
 										tableName,
 										indexName);
   }
+  
+  // -----------------------------------------------------
+  // XPLAINable Implementation
+  // -----------------------------------------------------
+  
+    public void accept(XPLAINVisitor visitor) {
+        //inform the visitor
+        visitor.setNumberOfChildren(0);
+
+        // pre-order, depth-first traversal
+        // me first
+        visitor.visit(this);
+        // I´m a leaf node and I have no children ...
+        
+    }
+    public String getRSXplainType() { return XPLAINUtil.OP_LASTINDEXKEYSCAN; }
+    public String getRSXplainDetails()
+    {
+        return "I: " + this.indexName + ", T: " + this.tableName;
+    }
+    public Object getScanPropsDescriptor(Object scanPropsID)
+    {
+        String isoLevel = XPLAINUtil.getIsolationLevelCode(this.isolationLevel);
+        
+        XPLAINScanPropsDescriptor scanRSDescriptor =            
+              new XPLAINScanPropsDescriptor(
+              (UUID)scanPropsID,      // the scan props UUID
+              this.indexName,
+              "I",
+              null,             // the scan type: heap, btree, sort
+              isoLevel,         // the isolation level
+              null,             // the number of visited pages
+              null,             // the number of visited rows
+              null,             // the number of qualified rows
+              null,             // the number of visited deleted rows
+              null,             // the number of fetched columns
+              null,             // the bitset of fetched columns
+              null,             // the btree height
+              null,             // the fetch size
+              null,                          // the start position, internal encoding
+              null,                          // the stop position, internal encoding
+              null,                          // the scan qualifiers
+              null,     // the next qualifiers
+              null,               // the hash key column numbers
+              null // the hash table size
+            );
+        
+        return scanRSDescriptor;
+    }
+    public Object getResultSetDescriptor(Object rsID, Object parentID,
+            Object scanID, Object sortID, Object stmtID, Object timingID)
+    {
+        String lockMode = XPLAINUtil.getLockModeCode(this.lockString);
+        String lockGran = XPLAINUtil.getLockGranularityCode(this.lockString);
+        
+        return new XPLAINResultSetDescriptor(
+           (UUID)rsID,
+           getRSXplainType(),
+           getRSXplainDetails(),
+           new Integer(this.numOpens),
+           null,                           // the number of index updates 
+           lockMode,
+           lockGran,
+           (UUID)parentID,
+           new Double(this.optimizerEstimatedRowCount),
+           new Double(this.optimizerEstimatedCost),
+           null,                              // the affected rows
+           null,                              // the deferred rows
+           null,                              // the input rows
+           new Integer(this.rowsSeen),            // the seen rows
+           null,                              // the seen rows right
+           new Integer(this.rowsFiltered),        // the filtered rows
+           new Integer(this.rowsSeen-this.rowsFiltered),// the returned rows
+           null,                              // the empty right rows
+           null,                           // index key optimization
+           (UUID)scanID,
+           (UUID)sortID,
+           (UUID)stmtID,                       // the stmt UUID
+           (UUID)timingID);
+    }
 }

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/rts/RealMaterializedResultSetStatistics.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/rts/RealMaterializedResultSetStatistics.java?rev=768597&r1=768596&r2=768597&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/rts/RealMaterializedResultSetStatistics.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/rts/RealMaterializedResultSetStatistics.java Sat Apr 25 20:21:03 2009
@@ -21,6 +21,11 @@
 
 package org.apache.derby.impl.sql.execute.rts;
 
+import org.apache.derby.catalog.UUID;
+import org.apache.derby.impl.sql.catalog.XPLAINResultSetTimingsDescriptor;
+import org.apache.derby.impl.sql.execute.xplain.XPLAINUtil;
+
+
 import org.apache.derby.iapi.services.io.StoredFormatIds;
 
 import org.apache.derby.iapi.services.i18n.MessageService;
@@ -32,6 +37,8 @@
 import java.io.ObjectInput;
 import java.io.IOException;
 
+import org.apache.derby.iapi.sql.execute.xplain.XPLAINVisitor;
+
 /**
   ResultSetStatistics implemenation for MaterializedResultSet.
 
@@ -152,4 +159,43 @@
   public String getNodeName(){
     return MessageService.getTextMessage(SQLState.RTS_MATERIALIZED_RS);
   }
+  
+  // -----------------------------------------------------
+  // XPLAINable Implementation
+  // -----------------------------------------------------
+  
+    public void accept(XPLAINVisitor visitor) {
+        int noChildren = 0;
+        if(this.childResultSetStatistics!=null) noChildren++;
+        
+        //inform the visitor
+        visitor.setNumberOfChildren(noChildren);
+
+        // pre-order, depth-first traversal
+        // me first
+        visitor.visit(this);
+        // then my child
+        if(childResultSetStatistics!=null){
+            childResultSetStatistics.accept(visitor);
+        }
+    }
+    public String getRSXplainType() { return XPLAINUtil.OP_MATERIALIZE; }
+    public String getRSXplainDetails() { return "("+this.resultSetNumber +")"; }
+  
+    public Object getResultSetTimingsDescriptor(Object timingID)
+    {
+        return new XPLAINResultSetTimingsDescriptor(
+           (UUID)timingID,
+           new Long(this.constructorTime),
+           new Long(this.openTime),
+           new Long(this.nextTime),
+           new Long(this.closeTime),
+           new Long(this.getNodeTime()),
+           XPLAINUtil.getAVGNextTime( (long)this.nextTime, this.rowsSeen),
+           null,                          // the projection time
+           null,                          // the restriction time
+           new Long(this.createTCTime),
+           new Long(this.fetchTCTime)
+        );
+    }
 }

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/rts/RealNestedLoopJoinStatistics.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/rts/RealNestedLoopJoinStatistics.java?rev=768597&r1=768596&r2=768597&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/rts/RealNestedLoopJoinStatistics.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/rts/RealNestedLoopJoinStatistics.java Sat Apr 25 20:21:03 2009
@@ -27,6 +27,8 @@
 import org.apache.derby.iapi.reference.SQLState;
 
 import org.apache.derby.iapi.services.io.FormatableHashtable;
+import org.apache.derby.iapi.sql.execute.xplain.XPLAINVisitor;
+import org.apache.derby.impl.sql.execute.xplain.XPLAINUtil;
 
 import java.io.ObjectOutput;
 import java.io.ObjectInput;
@@ -50,7 +52,7 @@
 	 * "Make" this a HashJoin if the right child is a HashScan.
 	 */
 	protected String nodeName ;
-	protected String resultSetName;
+	public String resultSetName;
 
 	// CONSTRUCTORS
 
@@ -217,4 +219,39 @@
 			}
 		}
 	}
+	
+    // -----------------------------------------------------
+    // XPLAINable Implementation
+    // -----------------------------------------------------
+    
+      public void accept(XPLAINVisitor visitor) {
+          int noChildren = 0;
+          if(this.leftResultSetStatistics!=null) noChildren++;
+          if(this.rightResultSetStatistics!=null) noChildren++;
+          
+          //inform the visitor
+          visitor.setNumberOfChildren(noChildren);
+
+          // pre-order, depth-first traversal
+          // me first
+          visitor.visit(this);
+          // then first my left child
+          if(leftResultSetStatistics!=null){
+              leftResultSetStatistics.accept(visitor);
+          }
+          // then first my right child
+          if(rightResultSetStatistics!=null){
+              rightResultSetStatistics.accept(visitor);
+          }
+          
+          
+      }
+    public String getRSXplainType() { return XPLAINUtil.OP_JOIN_NL; }
+    public String getRSXplainDetails()
+    {
+        String op_details = "("+this.resultSetNumber + ")";
+        // check to see if this NL Join is part of an Exist clause
+        if (this.oneRowRightSide) op_details+= ", EXISTS JOIN";
+        return op_details;
+    }
 }

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/rts/RealNestedLoopLeftOuterJoinStatistics.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/rts/RealNestedLoopLeftOuterJoinStatistics.java?rev=768597&r1=768596&r2=768597&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/rts/RealNestedLoopLeftOuterJoinStatistics.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/rts/RealNestedLoopLeftOuterJoinStatistics.java Sat Apr 25 20:21:03 2009
@@ -21,6 +21,11 @@
 
 package org.apache.derby.impl.sql.execute.rts;
 
+import org.apache.derby.catalog.UUID;
+import org.apache.derby.impl.sql.catalog.XPLAINResultSetDescriptor;
+import org.apache.derby.impl.sql.catalog.XPLAINResultSetTimingsDescriptor;
+import org.apache.derby.impl.sql.execute.xplain.XPLAINUtil;
+
 import org.apache.derby.iapi.services.io.StoredFormatIds;
 
 import org.apache.derby.iapi.services.i18n.MessageService;
@@ -171,4 +176,42 @@
 		resultSetName = MessageService.getTextMessage(
 										SQLState.RTS_NESTED_LOOP_LEFT_OJ_RS);
 	}
+    public String getRSXplainType() { return XPLAINUtil.OP_JOIN_NL_LO; }
+    public String getRSXplainDetails()
+    {
+        String op_details = "("+this.resultSetNumber + "), " +
+            this.resultSetName;
+
+        // check to see if this NL Join is part of an Exist clause
+        if (this.oneRowRightSide) op_details+= ", EXISTS JOIN";
+        return op_details;
+    }
+    public Object getResultSetDescriptor(Object rsID, Object parentID,
+            Object scanID, Object sortID, Object stmtID, Object timingID)
+    {
+        return new XPLAINResultSetDescriptor(
+           (UUID)rsID,
+           getRSXplainType(),
+           getRSXplainDetails(),
+           new Integer(this.numOpens),
+           null,                           // index updates
+           null,                           // lock mode
+           null,                           // lock granularity
+           (UUID)parentID,
+           new Double(this.optimizerEstimatedRowCount),
+           new Double(this.optimizerEstimatedCost),
+           null,                              // affected rows
+           null,                              // deferred rows
+           null,                              // the input rows
+           new Integer(this.rowsSeenLeft),
+           new Integer(this.rowsSeenRight),
+           new Integer(this.rowsFiltered),
+           new Integer(this.rowsReturned),
+           new Integer(this.emptyRightRowsReturned),
+           null,                           // index key optimization
+           (UUID)scanID,
+           (UUID)sortID,
+           (UUID)stmtID,
+           (UUID)timingID);
+    }
 }

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/rts/RealNoRowsResultSetStatistics.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/rts/RealNoRowsResultSetStatistics.java?rev=768597&r1=768596&r2=768597&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/rts/RealNoRowsResultSetStatistics.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/rts/RealNoRowsResultSetStatistics.java Sat Apr 25 20:21:03 2009
@@ -21,6 +21,11 @@
 
 package org.apache.derby.impl.sql.execute.rts;
 
+import org.apache.derby.catalog.UUID;
+import org.apache.derby.impl.sql.catalog.XPLAINResultSetDescriptor;
+import org.apache.derby.impl.sql.catalog.XPLAINResultSetTimingsDescriptor;
+import org.apache.derby.impl.sql.execute.xplain.XPLAINUtil;
+
 import org.apache.derby.iapi.services.io.Formatable;
 import org.apache.derby.iapi.services.i18n.MessageService;
 import org.apache.derby.iapi.reference.SQLState;
@@ -48,7 +53,7 @@
 	protected String subIndent;
 	protected int sourceDepth;
 	public	ResultSetStatistics	sourceResultSetStatistics;
-	protected long executeTime;
+	public long executeTime;
 
 	// variables to implement the inspectable interface.
 	// Do these have to be public? 
@@ -135,4 +140,57 @@
 	{
 		return 0.0;
 	}
+    public String getRSXplainDetails() { return null; }
+    public Object getResultSetDescriptor(Object rsID, Object parentID,
+            Object scanID, Object sortID, Object stmtID, Object timingID)
+    {
+        return new XPLAINResultSetDescriptor(
+           (UUID)rsID,
+           getRSXplainType(),
+           getRSXplainDetails(),
+           null,                              // the number of opens
+           null,                              // the number of index updates 
+           null,                           // lock mode
+           null,                           // lock granularity
+           (UUID)parentID,
+           null,                             // estimated row count
+           null,                             // estimated cost
+           null,                             // affected rows
+           null,                             // deferred rows.
+           null,                              // the input rows
+           null,                              // the seen rows left
+           null,                              // the seen rows right
+           null,                              // the filtered rows
+           null,                              // the returned rows
+           null,                              // the empty right rows
+           null,                           // index key optimization
+           (UUID)scanID,
+           (UUID)sortID,
+           (UUID)stmtID,
+           (UUID)timingID);
+    }
+    public Object getResultSetTimingsDescriptor(Object timingID)
+    {
+        return new XPLAINResultSetTimingsDescriptor(
+           (UUID)timingID,
+           null,                                   // the constructor time
+           null,                                   // the open time
+           null,                                   // the next time
+           null,                                   // the close time
+           new Long(this.executeTime),             // the execute time
+           null,                                   // the avg next time/row
+           null,                                   // the projection time
+           null,                                   // the restriction time
+           null,                                   // the temp_cong_create_time
+           null                                    // the temo_cong_fetch_time
+        );
+    }
+    public Object getSortPropsDescriptor(Object UUID)
+    {
+        return null; // Most statistics classes don't have sort props
+    }
+    public Object getScanPropsDescriptor(Object UUID)
+    {
+        return null; // Most statistics classes don't have sort props
+    }
 }

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/rts/RealNormalizeResultSetStatistics.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/rts/RealNormalizeResultSetStatistics.java?rev=768597&r1=768596&r2=768597&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/rts/RealNormalizeResultSetStatistics.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/rts/RealNormalizeResultSetStatistics.java Sat Apr 25 20:21:03 2009
@@ -27,6 +27,8 @@
 import org.apache.derby.iapi.reference.SQLState;
 
 import org.apache.derby.iapi.services.io.FormatableHashtable;
+import org.apache.derby.impl.sql.execute.xplain.XPLAINUtil;
+import org.apache.derby.iapi.sql.execute.xplain.XPLAINVisitor;
 
 import java.io.ObjectOutput;
 import java.io.ObjectInput;
@@ -142,4 +144,27 @@
   public String getNodeName(){
     return MessageService.getTextMessage(SQLState.RTS_NORMALIZE_RS);
   }
+  
+  // -----------------------------------------------------
+  // XPLAINable Implementation
+  // -----------------------------------------------------
+  
+    public void accept(XPLAINVisitor visitor) {
+        int noChildren = 0;
+        if(this.childResultSetStatistics!=null) noChildren++;
+        
+        //inform the visitor
+        visitor.setNumberOfChildren(noChildren);
+
+        // pre-order, depth-first traversal
+        // me first
+        visitor.visit(this);
+        // then my child
+        if(childResultSetStatistics!=null){
+            childResultSetStatistics.accept(visitor);
+		}
+
+    }
+    public String getRSXplainType() { return XPLAINUtil.OP_NORMALIZE; }
+
 }

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/rts/RealOnceResultSetStatistics.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/rts/RealOnceResultSetStatistics.java?rev=768597&r1=768596&r2=768597&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/rts/RealOnceResultSetStatistics.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/rts/RealOnceResultSetStatistics.java Sat Apr 25 20:21:03 2009
@@ -27,6 +27,8 @@
 import org.apache.derby.iapi.reference.SQLState;
 
 import org.apache.derby.iapi.services.io.FormatableHashtable;
+import org.apache.derby.impl.sql.execute.xplain.XPLAINUtil;
+import org.apache.derby.iapi.sql.execute.xplain.XPLAINVisitor;
 
 import java.io.ObjectOutput;
 import java.io.ObjectInput;
@@ -160,4 +162,33 @@
   public String getNodeName(){
     return MessageService.getTextMessage(SQLState.RTS_ONCE_RS);
   }
+  
+  // -----------------------------------------------------
+  // XPLAINable Implementation
+  // -----------------------------------------------------
+  
+    public void accept(XPLAINVisitor visitor) {
+        int noChildren = 0;
+        if(this.childResultSetStatistics!=null) noChildren++;
+        
+        //inform the visitor
+        visitor.setNumberOfChildren(noChildren);
+
+        // pre-order, depth-first traversal
+        // me first
+        visitor.visit(this);
+        // then my child
+        if(childResultSetStatistics!=null){
+            childResultSetStatistics.accept(visitor);
+        }
+    }
+    public String getRSXplainType() { return XPLAINUtil.OP_ONCE; }
+    public String getRSXplainDetails()
+    {
+        String attachmentString = (this.pointOfAttachment == -1) ? "" :
+                 "ATTACHED:" + this.pointOfAttachment;
+
+        return attachmentString + ";" + this.resultSetNumber;
+    }
+  
 }

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/rts/RealProjectRestrictStatistics.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/rts/RealProjectRestrictStatistics.java?rev=768597&r1=768596&r2=768597&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/rts/RealProjectRestrictStatistics.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/rts/RealProjectRestrictStatistics.java Sat Apr 25 20:21:03 2009
@@ -21,12 +21,17 @@
 
 package org.apache.derby.impl.sql.execute.rts;
 
+import org.apache.derby.catalog.UUID;
+import org.apache.derby.impl.sql.catalog.XPLAINResultSetTimingsDescriptor;
+import org.apache.derby.impl.sql.execute.xplain.XPLAINUtil;
+
 import org.apache.derby.iapi.services.io.StoredFormatIds;
 
 import org.apache.derby.iapi.services.i18n.MessageService;
 import org.apache.derby.iapi.reference.SQLState;
 
 import org.apache.derby.iapi.services.io.FormatableHashtable;
+import org.apache.derby.iapi.sql.execute.xplain.XPLAINVisitor;
 
 import java.io.ObjectOutput;
 import java.io.ObjectInput;
@@ -245,4 +250,82 @@
   public String getNodeName(){
     return MessageService.getTextMessage(SQLState.RTS_PR);
   }
+  
+  // -----------------------------------------------------
+  // XPLAINable Implementation
+  // -----------------------------------------------------
+  
+    public void accept(XPLAINVisitor visitor) {
+        // compute number of children of this node, which get visited
+        int noChildren = 0;
+        if(this.childResultSetStatistics!=null) noChildren++;
+        if(this.subqueryTrackingArray!=null){
+            noChildren += subqueryTrackingArray.length;
+        }
+        // inform the visitor
+        visitor.setNumberOfChildren(noChildren);
+
+        // pre-order, depth-first traversal
+        // me first
+        visitor.visit(this);
+        // then my direct child
+        if(childResultSetStatistics!=null){
+            childResultSetStatistics.accept(visitor);
+        }
+        // and now the dependant resultsets, if there are any
+        if (subqueryTrackingArray != null)
+        {
+            boolean foundAttached = false;
+
+            for (int index = 0; index < subqueryTrackingArray.length; index++)
+            {
+                if (subqueryTrackingArray[index] != null)
+                {
+                    // TODO add additional dependant referential action ?
+                    /*
+                    if (! foundAttached)
+                    {
+                        dependentInfo = indent  + "\n" +
+                            MessageService.getTextMessage(
+                                                SQLState.RTS_REFACTION_DEPENDENT) +
+                                ":\n";
+                        foundAttached = true;
+                    }*/
+                    
+                    subqueryTrackingArray[index].accept(visitor);
+                }
+            }
+        }
+    }
+    public String getRSXplainType()
+    {
+        
+        if (this.restriction && this.doesProjection)
+            return XPLAINUtil.OP_PROJ_RESTRICT;
+        if (this.doesProjection)
+            return XPLAINUtil.OP_PROJECT;
+        if (this.restriction)
+            return XPLAINUtil.OP_FILTER;
+        return XPLAINUtil.OP_PROJ_RESTRICT;
+    }
+    public String getRSXplainDetails()
+    {
+        return this.resultSetNumber + ";";
+    }
+    public Object getResultSetTimingsDescriptor(Object timingID)
+    {
+        return new XPLAINResultSetTimingsDescriptor(
+           (UUID)timingID,
+           new Long(this.constructorTime),
+           new Long(this.openTime),
+           new Long(this.nextTime),
+           new Long(this.closeTime),
+           new Long(this.getNodeTime()),
+           XPLAINUtil.getAVGNextTime( (long)this.nextTime, this.rowsSeen),
+           new Long(this.projectionTime),
+           new Long(this.restrictionTime),
+           null,                          // the temp_cong_create_time
+           null                           // the temo_cong_fetch_time
+        );
+    }
 }

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/rts/RealRowCountStatistics.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/rts/RealRowCountStatistics.java?rev=768597&r1=768596&r2=768597&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/rts/RealRowCountStatistics.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/rts/RealRowCountStatistics.java Sat Apr 25 20:21:03 2009
@@ -23,6 +23,8 @@
 
 
 import org.apache.derby.iapi.services.i18n.MessageService;
+import org.apache.derby.impl.sql.execute.xplain.XPLAINUtil;
+import org.apache.derby.iapi.sql.execute.xplain.XPLAINVisitor;
 import org.apache.derby.iapi.reference.SQLState;
 
 import java.util.Vector;
@@ -140,4 +142,11 @@
     public String getNodeName() {
         return MessageService.getTextMessage(SQLState.RTS_RC);
     }
+
+    public void accept(XPLAINVisitor visitor) {
+        visitor.setNumberOfChildren(1);
+        visitor.visit(this);
+        childResultSetStatistics.accept(visitor);
+    }
+    public String getRSXplainType() { return XPLAINUtil.OP_ROW_COUNT; }
 }

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/rts/RealRowResultSetStatistics.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/rts/RealRowResultSetStatistics.java?rev=768597&r1=768596&r2=768597&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/rts/RealRowResultSetStatistics.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/rts/RealRowResultSetStatistics.java Sat Apr 25 20:21:03 2009
@@ -32,6 +32,12 @@
 import java.io.ObjectInput;
 import java.io.IOException;
 
+import org.apache.derby.catalog.UUID;
+import org.apache.derby.impl.sql.catalog.XPLAINResultSetDescriptor;
+import org.apache.derby.impl.sql.catalog.XPLAINResultSetTimingsDescriptor;
+import org.apache.derby.impl.sql.execute.xplain.XPLAINUtil;
+import org.apache.derby.iapi.sql.execute.xplain.XPLAINVisitor;
+
 /**
   ResultSetStatistics implemenation for RowResultSet.
 
@@ -133,4 +139,49 @@
   public String getNodeName(){
     return MessageService.getTextMessage(SQLState.RTS_ROW_RS);
   }
+  
+  // -----------------------------------------------------
+  // XPLAINable Implementation
+  // -----------------------------------------------------
+  
+    public void accept(XPLAINVisitor visitor) {
+        
+        // I have no children, inform my visitor about that
+        visitor.setNumberOfChildren(0);
+        // pre-order, depth-first traversal
+        // me first
+        visitor.visit(this);
+        // I´m a leaf node, I have no children ...
+        
+    }
+
+    public String getRSXplainType() { return XPLAINUtil.OP_ROW; }
+    public Object getResultSetDescriptor(Object rsID, Object parentID,
+            Object scanID, Object sortID, Object stmtID, Object timingID)
+    {
+        return new XPLAINResultSetDescriptor(
+           (UUID)rsID,
+           getRSXplainType(),
+           getRSXplainDetails(),
+           new Integer(this.numOpens),
+           null,                              // the number of index updates 
+           null,                           // lock mode
+           null,                           // lock granularity
+           (UUID)parentID,
+           new Double(this.optimizerEstimatedRowCount),
+           new Double(this.optimizerEstimatedCost),
+           null,                              // the affected rows
+           null,                              // the deferred rows
+           null,                              // the input rows
+           new Integer(this.rowsSeen),
+           null,                              // the seen rows right
+           new Integer(this.rowsFiltered),
+           new Integer(this.rowsReturned),
+           null,                              // the empty right rows
+           null,                           // index key optimization
+           (UUID)scanID,
+           (UUID)sortID,
+           (UUID)stmtID,
+           (UUID)timingID);
+    }
 }

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/rts/RealScalarAggregateStatistics.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/rts/RealScalarAggregateStatistics.java?rev=768597&r1=768596&r2=768597&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/rts/RealScalarAggregateStatistics.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/rts/RealScalarAggregateStatistics.java Sat Apr 25 20:21:03 2009
@@ -27,6 +27,11 @@
 import org.apache.derby.iapi.reference.SQLState;
 
 import org.apache.derby.iapi.services.io.FormatableHashtable;
+import org.apache.derby.catalog.UUID;
+import org.apache.derby.impl.sql.catalog.XPLAINResultSetDescriptor;
+import org.apache.derby.impl.sql.catalog.XPLAINResultSetTimingsDescriptor;
+import org.apache.derby.impl.sql.execute.xplain.XPLAINUtil;
+import org.apache.derby.iapi.sql.execute.xplain.XPLAINVisitor;
 
 import java.io.ObjectOutput;
 import java.io.ObjectInput;
@@ -151,4 +156,54 @@
   public String getNodeName(){
     return MessageService.getTextMessage(SQLState.RTS_SCALAR_AGG);
   }
+  
+  // -----------------------------------------------------
+  // XPLAINable Implementation
+  // -----------------------------------------------------
+  
+    public void accept(XPLAINVisitor visitor) {
+        int noChildren = 0;
+        if(this.childResultSetStatistics!=null) noChildren++;
+        
+        //inform the visitor
+        visitor.setNumberOfChildren(noChildren);
+
+        // pre-order, depth-first traversal
+        // me first
+        visitor.visit(this);
+        // then my child
+        if(childResultSetStatistics!=null){
+            childResultSetStatistics.accept(visitor);
+		}
+
+    }
+    public String getRSXplainType() { return XPLAINUtil.OP_AGGREGATE; }
+    public Object getResultSetDescriptor(Object rsID, Object parentID,
+            Object scanID, Object sortID, Object stmtID, Object timingID)
+    {
+        return new XPLAINResultSetDescriptor(
+           (UUID)rsID,
+           getRSXplainType(),
+           getRSXplainDetails(),
+           new Integer(this.numOpens),
+           null,                              // the number of index updates 
+           null,                           // lock mode
+           null,                           // lock granularity
+           (UUID)parentID,
+           new Double(this.optimizerEstimatedRowCount),
+           new Double(this.optimizerEstimatedCost),
+           null,                              // the affected rows
+           null,                              // the deferred rows
+           new Integer(this.rowsInput),
+           new Integer(this.rowsSeen),
+           null,                              // the seen rows right
+           new Integer(this.rowsFiltered),
+           new Integer(this.rowsInput - this.rowsFiltered),
+           null,                              // the empty right rows
+           this.indexKeyOptimization?"Y":"N",
+           (UUID)scanID,
+           (UUID)sortID,
+           (UUID)stmtID,
+           (UUID)timingID);
+    }
 }

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/rts/RealScrollInsensitiveResultSetStatistics.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/rts/RealScrollInsensitiveResultSetStatistics.java?rev=768597&r1=768596&r2=768597&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/rts/RealScrollInsensitiveResultSetStatistics.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/rts/RealScrollInsensitiveResultSetStatistics.java Sat Apr 25 20:21:03 2009
@@ -27,6 +27,8 @@
 import org.apache.derby.iapi.reference.SQLState;
 
 import org.apache.derby.iapi.services.io.FormatableHashtable;
+import org.apache.derby.impl.sql.execute.xplain.XPLAINUtil;
+import org.apache.derby.iapi.sql.execute.xplain.XPLAINVisitor;
 
 import java.io.ObjectOutput;
 import java.io.ObjectInput;
@@ -154,4 +156,31 @@
   public String getNodeName(){
     return MessageService.getTextMessage(SQLState.RTS_SCROLL_INSENSITIVE_RS);
   }
+  
+  // -----------------------------------------------------
+  // XPLAINable Implementation
+  // -----------------------------------------------------
+  
+    public void accept(XPLAINVisitor visitor) {
+        int noChildren = 0;
+        if(this.childResultSetStatistics!=null) noChildren++;
+        
+        //inform the visitor
+        visitor.setNumberOfChildren(noChildren);
+
+        // pre-order, depth-first traversal
+        // me first
+        visitor.visit(this);
+        // then my child
+        if(childResultSetStatistics!=null){
+            childResultSetStatistics.accept(visitor);
+        }
+    }
+
+    public String getRSXplainType() { return XPLAINUtil.OP_SCROLL; }
+    public String getRSXplainDetails()
+    {
+        return "("+this.resultSetNumber +"), " +
+                "["+this.numFromHashTable+", "+ this.numToHashTable + "]";
+    }
 }



Mime
View raw message