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 da...@apache.org on 2009/08/27 19:02:54 UTC

svn commit: r808523 - in /db/derby/code/trunk/java/engine/org/apache/derby: iapi/sql/conn/ iapi/sql/dictionary/ iapi/util/ impl/sql/ impl/sql/compile/ impl/sql/conn/ impl/sql/execute/ impl/sql/execute/rts/

Author: dag
Date: Thu Aug 27 17:02:52 2009
New Revision: 808523

URL: http://svn.apache.org/viewvc?rev=808523&view=rev
Log:
DERBY-4087 Clean up debug printing of the abstract syntax trees after parsing, binding and optimization

Patch DERBY-4087-b, which improves debug-time printing of query trees.
Much of the changes concerns cleaning up when to use toString and when
to use printSubNodes, a pattern which is well-defined but was severely
broken, as well as including more data for each node, and sub-trees
not hitherto printed at all. Please see JIRA for mroe detail.

A new feature highlights aliases by suppressing printing of already
printed subtrees (the query tree is a DAG, not a pure tree).



Modified:
    db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/conn/LanguageConnectionContext.java
    db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/dictionary/ColumnDescriptor.java
    db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/dictionary/TableDescriptor.java
    db/derby/code/trunk/java/engine/org/apache/derby/iapi/util/StringUtil.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/GenericStatement.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/AggregateNode.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/AlterTableNode.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/BaseColumnNode.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CallStatementNode.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CoalesceFunctionNode.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ColumnDefinitionNode.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CreateTableNode.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CurrentDatetimeOperatorNode.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CursorNode.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/DDLStatementNode.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/DefaultNode.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/DistinctNode.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ExtractOperatorNode.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/FromList.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/FromSubquery.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/GenerationClauseNode.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/GroupByColumn.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/GroupByList.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/GroupByNode.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/OrderByColumn.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/OrderByList.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/OrderByNode.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/PredicateList.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/QueryTreeNode.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/QueryTreeNodeVector.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ResultColumnList.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ResultSetNode.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/SelectNode.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/SetOperatorNode.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/SpecialFunctionNode.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/SubqueryList.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/TableElementList.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/TableOperatorNode.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ValueNodeList.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/WindowFunctionColumnNode.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/conn/GenericLanguageConnectionContext.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/DependentResultSet.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/HashScanResultSet.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/IndexColumnOrder.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/TableScanResultSet.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/rts/RealDistinctScanStatistics.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/rts/RealHashScanStatistics.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/rts/RealTableScanStatistics.java

Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/conn/LanguageConnectionContext.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/conn/LanguageConnectionContext.java?rev=808523&r1=808522&r2=808523&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/conn/LanguageConnectionContext.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/conn/LanguageConnectionContext.java Thu Aug 27 17:02:52 2009
@@ -48,6 +48,7 @@
 import org.apache.derby.catalog.UUID;
 
 import java.util.Map;
+import java.util.AbstractMap;
 
 /**
  * LanguageConnectionContext keeps the result sets,
@@ -1200,6 +1201,13 @@
 	 */
     public  Object    getLastQueryTree();
 
+	/**
+	 * Return a map of AST nodes that have already been printed during a
+	 * compiler phase, so as to be able to avoid printing a node more than once.
+	 * @see org.apache.derby.impl.sql.compile.QueryTreeNode#treePrint(int)
+	 * @return the map
+	 */
+    public Map getPrintedObjectsMap();
 	
     /**
      * sets the XplainOnlyMode.

Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/dictionary/ColumnDescriptor.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/dictionary/ColumnDescriptor.java?rev=808523&r1=808522&r2=808523&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/dictionary/ColumnDescriptor.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/dictionary/ColumnDescriptor.java Thu Aug 27 17:02:52 2009
@@ -448,7 +448,7 @@
 				"columnType: " + columnType + "\n" +
 				"columnDefault: " + columnDefault + "\n" +
 				"uuid: " + uuid + "\n" +
-				"defaultUUID: " + defaultUUID + "\n";
+				"defaultUUID: " + defaultUUID ;
 		}
 		else
 		{

Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/dictionary/TableDescriptor.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/dictionary/TableDescriptor.java?rev=808523&r1=808522&r2=808523&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/dictionary/TableDescriptor.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/dictionary/TableDescriptor.java Thu Aug 27 17:02:52 2009
@@ -878,7 +878,9 @@
 	{
 		if (SanityManager.DEBUG)
 		{
-			String tempString = "SCHEMA:\n" + schema + "\ntableName: " + tableName + "\n" +
+			String tempString =
+				"\n" + "schema: " + schema + "\n" +
+				"tableName: " + tableName + "\n" +
 				"oid: " + oid + " tableType: " + tableType + "\n" +
 				"conglomerateDescriptorList: " + conglomerateDescriptorList + "\n" +
 				"columnDescriptorList: " + columnDescriptorList + "\n" +
@@ -886,10 +888,12 @@
 				"heapConglomNumber: " + heapConglomNumber + "\n";
 			if (tableType == TableDescriptor.GLOBAL_TEMPORARY_TABLE_TYPE)
 			{
-				tempString = tempString + "onCommitDeleteRows: " + "\n" + onCommitDeleteRows + "\n";
-				tempString = tempString + "onRollbackDeleteRows: " + "\n" + onRollbackDeleteRows + "\n";
+				tempString = tempString + "onCommitDeleteRows: " + "\n" +
+					onCommitDeleteRows + "\n";
+				tempString = tempString + "onRollbackDeleteRows: " + "\n" +
+					onRollbackDeleteRows;
 			} else
-				tempString = tempString + "lockGranularity: " + lockGranularity + "\n";
+				tempString = tempString + "lockGranularity: " + lockGranularity;
 			return tempString;
 		}
 		else

Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/util/StringUtil.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/iapi/util/StringUtil.java?rev=808523&r1=808522&r2=808523&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/iapi/util/StringUtil.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/util/StringUtil.java Thu Aug 27 17:02:52 2009
@@ -24,6 +24,9 @@
 import java.util.Locale;
 import java.util.StringTokenizer;
 
+import java.util.regex.Pattern;
+import java.util.regex.Matcher;
+
 /**
 	A set of public static methods for dealing with Strings
 */
@@ -516,4 +519,43 @@
 
         return buffer.toString();
     }
+
+
+	/**
+	 * Utility for formatting which bends a multi-line string into shape for
+	 * outputting it in a context where there is <i>depth</i> tabs. Trailing
+	 * newlines are discarded as well.
+	 * <p>
+	 * Replace     "^[\t]*" with "depth" number of tabs.<br>
+	 * Replace     "\n+$" with "".
+	 * Replace all "\n[\t]*" with "\n" + "depth" number of tabs.<br>
+	 * </p>
+	 * @param formatted string to sanitize
+	 * @param depth the string is to be printed at
+	 */
+	public static String ensureIndent(String formatted, int depth) {
+		StringBuffer buf = new StringBuffer();
+		StringBuffer indent = new StringBuffer();
+
+		while (depth-- > 0) {
+			indent.append("\t");
+		}
+
+
+		Pattern pat_a = Pattern.compile("\\A\\t*");
+		Matcher m_a = pat_a.matcher(formatted);
+
+		formatted = m_a.replaceFirst(indent.toString());
+
+		Pattern pat_b = Pattern.compile("\\n+\\Z");
+		Matcher m_b = pat_b.matcher(formatted);
+		formatted = m_b.replaceFirst("");
+
+		Pattern pat_c = Pattern.compile("\\n\\t*");
+		Matcher m_c = pat_c.matcher(formatted);
+		formatted = m_c.replaceAll("\n" + indent.toString());
+
+
+		return formatted;
+	}
 }

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/GenericStatement.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/GenericStatement.java?rev=808523&r1=808522&r2=808523&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/GenericStatement.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/GenericStatement.java Thu Aug 27 17:02:52 2009
@@ -285,7 +285,10 @@
 				{
 					if (SanityManager.DEBUG_ON("DumpParseTree")) 
 					{
+						SanityManager.GET_DEBUG_STREAM().print(
+							"\n\n============PARSE===========\n\n");
 						qt.treePrint();
+						lcc.getPrintedObjectsMap().clear();
 					}
 
 					if (SanityManager.DEBUG_ON("StopAfterParsing")) 
@@ -320,7 +323,10 @@
 					{
 						if (SanityManager.DEBUG_ON("DumpBindTree")) 
 						{
+							SanityManager.GET_DEBUG_STREAM().print(
+								"\n\n============BIND===========\n\n");
 							qt.treePrint();
+							lcc.getPrintedObjectsMap().clear();
 						}
 
 						if (SanityManager.DEBUG_ON("StopAfterBinding")) {
@@ -437,7 +443,10 @@
 					{
 						if (SanityManager.DEBUG_ON("DumpOptimizedTree")) 
 						{
+							SanityManager.GET_DEBUG_STREAM().print(
+								"\n\n============OPT===========\n\n");
 							qt.treePrint();
+							lcc.getPrintedObjectsMap().clear();
 						}
 
 						if (SanityManager.DEBUG_ON("StopAfterOptimizing")) 

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/AggregateNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/AggregateNode.java?rev=808523&r1=808522&r2=808523&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/AggregateNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/AggregateNode.java Thu Aug 27 17:02:52 2009
@@ -617,8 +617,8 @@
 	{
 		if (SanityManager.DEBUG)
 		{
-			return "Aggregate: "+aggregateName+
-				"\ndistinct: "+distinct+
+			return "aggregateName: " + aggregateName + "\n" +
+				"distinct: " + distinct + "\n" +
 				super.toString();
 		}
 		else

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/AlterTableNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/AlterTableNode.java?rev=808523&r1=808522&r2=808523&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/AlterTableNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/AlterTableNode.java Thu Aug 27 17:02:52 2009
@@ -258,18 +258,18 @@
 		if (SanityManager.DEBUG)
 		{
 			return super.toString() +
-				"objectName: " + "\n" + getObjectName() + "\n" +
-				"tableElementList: " + "\n" + tableElementList + "\n" +
-				"lockGranularity: " + "\n" + lockGranularity + "\n" +
-				"compressTable: " + "\n" + compressTable + "\n" +
-				"sequential: " + "\n" + sequential + "\n" +
-				"truncateTable: " + "\n" + truncateTable + "\n" +
-				"purge: " + "\n" + purge + "\n" +
-				"defragment: " + "\n" + defragment + "\n" +
-				"truncateEndOfTable: " + "\n" + truncateEndOfTable + "\n" +
-				"updateStatistics: " + "\n" + updateStatistics + "\n" +
-				"updateStatisticsAll: " + "\n" + updateStatisticsAll + "\n" +
-				"indexNameForUpdateStatistics: " + "\n" + indexNameForUpdateStatistics + "\n";
+				"objectName: " + getObjectName() + "\n" +
+				"lockGranularity: " + lockGranularity + "\n" +
+				"compressTable: " + compressTable + "\n" +
+				"sequential: " + sequential + "\n" +
+				"truncateTable: " + truncateTable + "\n" +
+				"purge: " + purge + "\n" +
+				"defragment: " + defragment + "\n" +
+				"truncateEndOfTable: " + truncateEndOfTable + "\n" +
+				"updateStatistics: " + updateStatistics + "\n" +
+				"updateStatisticsAll: " + updateStatisticsAll + "\n" +
+				"indexNameForUpdateStatistics: " +
+				     indexNameForUpdateStatistics + "\n";
 		}
 		else
 		{
@@ -277,7 +277,19 @@
 		}
 	}
 
-	public String statementToString()
+	/**
+	 * Prints the sub-nodes of this object.  See QueryTreeNode.java for
+	 * how tree printing is supposed to work.
+	 * @param depth		The depth to indent the sub-nodes
+	 */
+	public void printSubNodes(int depth) {
+		if (SanityManager.DEBUG) {
+			printLabel(depth, "tableElementList: ");
+			tableElementList.treePrint(depth + 1);
+		}
+	}
+
+public String statementToString()
 	{
 		if(truncateTable)
 			return "TRUNCATE TABLE";

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/BaseColumnNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/BaseColumnNode.java?rev=808523&r1=808522&r2=808523&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/BaseColumnNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/BaseColumnNode.java Thu Aug 27 17:02:52 2009
@@ -86,9 +86,10 @@
 		if (SanityManager.DEBUG)
 		{
 			return "columnName: " + columnName + "\n" +
+				"tableName: " +
 				( ( tableName != null) ?
 						tableName.toString() :
-						"tableName: null\n") +
+						"null") + "\n" +
 				super.toString();
 		}
 		else

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CallStatementNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CallStatementNode.java?rev=808523&r1=808522&r2=808523&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CallStatementNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CallStatementNode.java Thu Aug 27 17:02:52 2009
@@ -75,25 +75,6 @@
 		this.methodCall.getJavaValueNode().markForCallStatement();
 	}
 
-	/**
-	 * Convert this object to a String.  See comments in QueryTreeNode.java
-	 * for how this should be done for tree printing.
-	 *
-	 * @return	This object as a String
-	 */
-
-	public String toString()
-	{
-		if (SanityManager.DEBUG)
-		{
-			return "CALL " + methodCall.toString() + "\n" +
-				super.toString();
-		}
-		else
-		{
-			return "";
-		}
-	}
 
 	public String statementToString()
 	{

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CoalesceFunctionNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CoalesceFunctionNode.java?rev=808523&r1=808522&r2=808523&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CoalesceFunctionNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CoalesceFunctionNode.java Thu Aug 27 17:02:52 2009
@@ -320,7 +320,10 @@
 	{
 		if (SanityManager.DEBUG)
 		{
-			return super.toString()+functionName+"("+argumentsList+")\n";
+			return
+				"functionName: " + functionName + "\n" +
+				"firstNonParameterNodeIdx: " + firstNonParameterNodeIdx + "\n" +
+				super.toString();
 		}
 		else
 		{
@@ -329,6 +332,25 @@
 	}
         
 	/**
+	 * Prints the sub-nodes of this object.  See QueryTreeNode.java for
+	 * how tree printing is supposed to work.
+	 *
+	 * @param depth		The depth of this node in the tree
+	 */
+
+	public void printSubNodes(int depth)
+	{
+		if (SanityManager.DEBUG)
+		{
+			super.printSubNodes(depth);
+
+			printLabel(depth, "argumentsList: ");
+			argumentsList.treePrint(depth + 1);
+		}
+	}
+
+
+	/**
 	 * {@inheritDoc}
 	 */
 	protected boolean isEquivalent(ValueNode o) throws StandardException
@@ -405,27 +427,4 @@
 		}
 		return this;
 	}
-
-
-	/**
-	 * Prints the sub-nodes of this object.  See QueryTreeNode.java for
-	 * how tree printing is supposed to work.
-	 *
-	 * @param depth					The depth of this node in the tree
-	 */
-
-	public void printSubNodes(int depth)
-	{
-		if (SanityManager.DEBUG)
-		{
-			super.printSubNodes(depth);
-			printLabel(depth, "argumentsList: [firstNonParameterNodeIdx=" +
-					   firstNonParameterNodeIdx + "]" );
-			int argumentsListSize = argumentsList.size();
-			for (int i=0; i < argumentsListSize; i++) {
-			    ((ValueNode)argumentsList.elementAt(i)).treePrint(depth+1);
-			}
-		}
-	}
-        
 }

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ColumnDefinitionNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ColumnDefinitionNode.java?rev=808523&r1=808522&r2=808523&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ColumnDefinitionNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ColumnDefinitionNode.java Thu Aug 27 17:02:52 2009
@@ -864,4 +864,28 @@
 
 	}
 
+    /**
+	 * Prints the sub-nodes of this object.  See QueryTreeNode.java for
+	 * how tree printing is supposed to work.
+	 *
+	 * @param depth		The depth of this node in the tree
+	 */
+	public void printSubNodes(int depth)
+	{
+		if (SanityManager.DEBUG)
+		{
+			super.printSubNodes(depth);
+
+			if (defaultNode != null) {
+				printLabel(depth, "default: ");
+				defaultNode.treePrint(depth + 1);
+			}
+
+
+			if (generationClauseNode != null) {
+				printLabel(depth, "generationClause: ");
+				generationClauseNode.treePrint(depth + 1);
+			}
+		}
+	}
 }

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CreateTableNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CreateTableNode.java?rev=808523&r1=808522&r2=808523&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CreateTableNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CreateTableNode.java Thu Aug 27 17:02:52 2009
@@ -195,13 +195,17 @@
 	{
 		if (SanityManager.DEBUG)
 		{
-			String tempString = "tableElementList: " + "\n" + tableElementList + "\n";
+			String tempString = "";
 			if (tableType == TableDescriptor.GLOBAL_TEMPORARY_TABLE_TYPE)
 			{
 				tempString = tempString + "onCommitDeleteRows: " + "\n" + onCommitDeleteRows + "\n";
 				tempString = tempString + "onRollbackDeleteRows: " + "\n" + onRollbackDeleteRows + "\n";
 			} else
-				tempString = tempString + "properties: " + "\n" + properties + "\n" + "lockGranularity: " + "\n" + lockGranularity + "\n";
+				tempString = tempString +
+					(properties != null ?
+					 "properties: " + "\n" + properties + "\n" :
+					 "") +
+					"lockGranularity: " + lockGranularity + "\n";
 			return super.toString() +  tempString;
 		}
 		else
@@ -210,6 +214,19 @@
 		}
 	}
 
+	/**
+	 * Prints the sub-nodes of this object.  See QueryTreeNode.java for
+	 * how tree printing is supposed to work.
+	 * @param depth		The depth to indent the sub-nodes
+	 */
+	public void printSubNodes(int depth) {
+		if (SanityManager.DEBUG) {
+			printLabel(depth, "tableElementList: ");
+			tableElementList.treePrint(depth + 1);
+		}
+	}
+
+
 	public String statementToString()
 	{
 		if (tableType == TableDescriptor.GLOBAL_TEMPORARY_TABLE_TYPE)

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CurrentDatetimeOperatorNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CurrentDatetimeOperatorNode.java?rev=808523&r1=808522&r2=808523&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CurrentDatetimeOperatorNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CurrentDatetimeOperatorNode.java Thu Aug 27 17:02:52 2009
@@ -169,7 +169,8 @@
 	public String toString() {
 		if (SanityManager.DEBUG)
 		{
-			return super.toString()+"method = "+methodName[whichType]+"\n";
+			return "methodName: " + methodName[whichType] + "\n" +
+				super.toString();
 		}
 		else
 		{

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CursorNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CursorNode.java?rev=808523&r1=808522&r2=808523&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CursorNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CursorNode.java Thu Aug 27 17:02:52 2009
@@ -197,9 +197,10 @@
 		{
 			super.printSubNodes(depth);
 
-			printLabel(depth, "orderByList: ");
-			if (orderByList != null)
+			if (orderByList != null) {
+				printLabel(depth, "orderByList: "  + depth);
 				orderByList.treePrint(depth + 1);
+			}
 		}
 	}
 

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/DDLStatementNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/DDLStatementNode.java?rev=808523&r1=808522&r2=808523&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/DDLStatementNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/DDLStatementNode.java Thu Aug 27 17:02:52 2009
@@ -148,7 +148,8 @@
 	{
 		if (SanityManager.DEBUG)
 		{
-			return ((objectName==null)?"":objectName.toString()) + super.toString();
+			return ((objectName==null)?"":
+					"name: " + objectName.toString() +"\n") + super.toString();
 		}
 		else
 		{

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/DefaultNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/DefaultNode.java?rev=808523&r1=808522&r2=808523&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/DefaultNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/DefaultNode.java Thu Aug 27 17:02:52 2009
@@ -109,8 +109,8 @@
 	{
 		if (SanityManager.DEBUG)
 		{
-			return "defaultTree: " + defaultTree + "\n" +
-				   "defaultText: " + defaultText + "\n" +
+			return "columnName: " + columnName + "\n" +
+				"defaultText: " + defaultText + "\n" +
 				super.toString();
 		}
 		else
@@ -119,6 +119,26 @@
 		}
 	}
 
+    /**
+	 * Prints the sub-nodes of this object.  See QueryTreeNode.java for
+	 * how tree printing is supposed to work.
+	 *
+	 * @param depth		The depth of this node in the tree
+	 */
+	public void printSubNodes(int depth)
+	{
+		if (SanityManager.DEBUG)
+		{
+			super.printSubNodes(depth);
+
+			if (defaultTree != null) {
+				printLabel(depth, "defaultTree:");
+				defaultTree.treePrint(depth + 1);
+			}
+		}
+	}
+
+
 	/**
 	 * Bind this expression.  This means binding the sub-expressions,
 	 * as well as figuring out what the return type is for this expression.

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/DistinctNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/DistinctNode.java?rev=808523&r1=808522&r2=808523&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/DistinctNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/DistinctNode.java Thu Aug 27 17:02:52 2009
@@ -204,24 +204,6 @@
 		// return ((Optimizable) childResult).pushOptPredicate(optimizablePredicate);
 	}
 
-	/**
-	 * Convert this object to a String.  See comments in QueryTreeNode.java
-	 * for how this should be done for tree printing.
-	 *
-	 * @return	This object as a String
-	 */
-
-	public String toString()
-	{
-		if (SanityManager.DEBUG)
-		{
-			return childResult.toString() + "\n" + super.toString();
-		}
-		else
-		{
-			return "";
-		}
-	}
 
 	/**
 	 * Optimize this DistinctNode.  

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ExtractOperatorNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ExtractOperatorNode.java?rev=808523&r1=808522&r2=808523&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ExtractOperatorNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ExtractOperatorNode.java Thu Aug 27 17:02:52 2009
@@ -176,7 +176,8 @@
 	public String toString() {
 		if (SanityManager.DEBUG)
 		{
-			return super.toString() + "field is "+fieldName[extractField]+"\n";
+			return "fieldName: " + fieldName[extractField] + "\n" +
+				super.toString();
 		}
 		else
 		{

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/FromList.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/FromList.java?rev=808523&r1=808522&r2=808523&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/FromList.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/FromList.java Thu Aug 27 17:02:52 2009
@@ -853,29 +853,6 @@
 		}
 	}
 
-	/**
-	 * Prints the sub-nodes of this object.  See QueryTreeNode.java for
-	 * how tree printing is supposed to work.
-	 *
-	 * @param depth		The depth of this node in the tree
-	 */
-
-	public void printSubNodes(int depth)
-	{
-		if (SanityManager.DEBUG)
-		{
-			FromTable	fromTable;
-
-			super.printSubNodes(depth);
-
-			int size = size();
-			for (int index = 0; index < size; index++)
-			{
-				fromTable = (FromTable) elementAt(index);
-				fromTable.treePrint(depth + 1);
-			}
-		}
-	}
 
 	/**
 	 * Set the (query block) level (0-based) for the FromTables in this

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/FromSubquery.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/FromSubquery.java?rev=808523&r1=808522&r2=808523&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/FromSubquery.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/FromSubquery.java Thu Aug 27 17:02:52 2009
@@ -73,25 +73,6 @@
 	}
 
 	/**
-	 * Convert this object to a String.  See comments in QueryTreeNode.java
-	 * for how this should be done for tree printing.
-	 *
-	 * @return	This object as a String
-	 */
-
-	public String toString()
-	{
-		if (SanityManager.DEBUG)
-		{
-			return  super.toString();
-		}
-		else
-		{
-			return "";
-		}
-	}
-
-	/**
 	 * Prints the sub-nodes of this object.  See QueryTreeNode.java for
 	 * how tree printing is supposed to work.
 	 *

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/GenerationClauseNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/GenerationClauseNode.java?rev=808523&r1=808522&r2=808523&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/GenerationClauseNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/GenerationClauseNode.java Thu Aug 27 17:02:52 2009
@@ -168,9 +168,35 @@
 	 */
 	public String toString()
     {
-        return "GENERATED ALWAYS AS ( " + _expressionText + " )";
+        return
+            "expressionText: GENERATED ALWAYS AS ( " +
+            _expressionText + " )\n" +
+            super.toString();
 	}
         
+
+    /**
+	 * Prints the sub-nodes of this object.  See QueryTreeNode.java for
+	 * how tree printing is supposed to work.
+	 *
+	 * @param depth		The depth of this node in the tree
+	 */
+	public void printSubNodes(int depth)
+	{
+		if (SanityManager.DEBUG)
+		{
+			super.printSubNodes(depth);
+
+            printLabel(depth, "generationExpression: ");
+            _generationExpression.treePrint(depth + 1);
+
+            if (_boundExpression != null) {
+                printLabel(depth, "boundExpression. ");
+                _boundExpression.treePrint(depth + 1);
+            }
+		}
+	}
+
     ///////////////////////////////////////////////////////////////////////////////////
     //
     // MINIONS

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/GroupByColumn.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/GroupByColumn.java?rev=808523&r1=808522&r2=808523&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/GroupByColumn.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/GroupByColumn.java Thu Aug 27 17:02:52 2009
@@ -52,24 +52,6 @@
 	}
 
 	/**
-	 * Convert this object to a String.  See comments in QueryTreeNode.java
-	 * for how this should be done for tree printing.
-	 *
-	 * @return	This object as a String
-	 */
-	public String toString() 
-	{
-		if (SanityManager.DEBUG)
-		{
-			return "Column Expression: "+columnExpression+super.toString();
-		}
-		else
-		{
-			return "";
-		}
-	}
-
-	/**
 	 * Prints the sub-nodes of this object.  See QueryTreeNode.java for
 	 * how tree printing is supposed to work.
 	 *
@@ -84,7 +66,7 @@
 
 			if (columnExpression != null)
 			{
-				printLabel(depth, "colRef: ");
+				printLabel(depth, "columnExpression: ");
 				columnExpression.treePrint(depth + 1);
 			}
 		}

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/GroupByList.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/GroupByList.java?rev=808523&r1=808522&r2=808523&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/GroupByList.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/GroupByList.java Thu Aug 27 17:02:52 2009
@@ -74,21 +74,6 @@
 		return (GroupByColumn) elementAt(position);
 	}
 
-	/**
-		Print the list.
-
-		@param depth		The depth at which to indent the sub-nodes
-	 */
-	public void printSubNodes(int depth)
-	{
-		if (SanityManager.DEBUG)
-		{
-			for (int index = 0; index < size(); index++)
-			{
-				( (GroupByColumn) elementAt(index) ).treePrint(depth);
-			}
-		}
-	}
 
 	/**
 	 * Get the number of grouping columns that need to be added to the SELECT list.
@@ -300,29 +285,24 @@
 		}
 	}
 
+
 	/**
-	 * Print it out, baby
+	 * Convert this object to a String.  See comments in QueryTreeNode.java
+	 * for how this should be done for tree printing.
+	 *
+	 * @return	This object as a String
 	 */
 	public String toString()
 	{
-		if (SanityManager.DEBUG)
-		{
-			StringBuffer	buf = new StringBuffer();
-
-			for (int index = 0; index < size(); index++)
-			{
-				GroupByColumn	groupingCol = (GroupByColumn) elementAt(index);
-
-				buf.append(groupingCol.toString());
-			}
-			return buf.toString();
-		}
-		else
-		{
+		if (SanityManager.DEBUG) {
+			return "numGroupingColsAdded: " + numGroupingColsAdded + "\n" +
+				super.toString();
+		} else {
 			return "";
 		}
 	}
 
+
 	public void preprocess(
 			int numTables, FromList fromList, SubqueryList whereSubquerys, 
 			PredicateList wherePredicates) throws StandardException 

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/GroupByNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/GroupByNode.java?rev=808523&r1=808522&r2=808523&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/GroupByNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/GroupByNode.java Thu Aug 27 17:02:52 2009
@@ -866,7 +866,7 @@
 		if (SanityManager.DEBUG)
 		{
 			return "singleInputRowOptimization: " + singleInputRowOptimization + "\n" +
-				childResult.toString() + "\n" + super.toString();
+				super.toString();
 		}
 		else
 		{
@@ -875,6 +875,45 @@
 	}
 
 	/**
+	 * Prints the sub-nodes of this object.  See QueryTreeNode.java for
+	 * how tree printing is supposed to work.
+	 *
+	 * @param depth		The depth of this node in the tree
+	 */
+	public void printSubNodes(int depth) {
+		if (SanityManager.DEBUG)
+		{
+			super.printSubNodes(depth);
+
+			printLabel(depth, "aggregateVector:\n");
+
+			for (int i=0; i < aggregateVector.size(); i++) {
+					AggregateNode agg =
+						(AggregateNode)aggregateVector.elementAt(i);
+					debugPrint(formatNodeString("[" + i + "]:", depth + 1));
+					agg.treePrint(depth + 1);
+			}
+
+			if (groupingList != null) {
+				printLabel(depth, "groupingList: ");
+				groupingList.treePrint(depth + 1);
+			}
+
+			if (havingClause != null)
+			{
+				printLabel(depth, "havingClause: ");
+				havingClause.treePrint(depth + 1);
+			}
+
+			if (havingSubquerys != null)
+			{
+				printLabel(depth, "havingSubqueries: ");
+				havingSubquerys.treePrint(depth + 1);
+			}
+		}
+	}
+
+	/**
 	 * Evaluate whether or not the subquery in a FromSubquery is flattenable.
 	 * Currently, a FSqry is flattenable if all of the following are true:
 	 *		o  Subquery is a SelectNode.

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/OrderByColumn.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/OrderByColumn.java?rev=808523&r1=808522&r2=808523&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/OrderByColumn.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/OrderByColumn.java Thu Aug 27 17:02:52 2009
@@ -74,12 +74,41 @@
 	 */
 	public String toString() {
 		if (SanityManager.DEBUG) {
-			return expression.toString();
+			return
+				"nullsOrderedLow: " + nullsOrderedLow + "\n" +
+				"ascending; " + ascending + "\n" +
+				"addedColumnOffset: " + addedColumnOffset + "\n" +
+				super.toString();
 		} else {
 			return "";
 		}
 	}
 
+
+	/**
+	 * Prints the sub-nodes of this object.  See QueryTreeNode.java for
+	 * how tree printing is supposed to work.
+	 *
+	 * @param depth		The depth of this node in the tree
+	 */
+	public void printSubNodes(int depth)
+	{
+		if (SanityManager.DEBUG)
+		{
+			super.printSubNodes(depth);
+
+			if (expression != null) {
+				printLabel(depth, "expression: ");
+				expression.treePrint(depth + 1);
+			}
+
+			if (resultCol != null) {
+				printLabel(depth, "resultCol: ");
+				resultCol.treePrint(depth + 1);
+			}
+		}
+	}
+
 	/**
 	 * Mark the column as descending order
 	 */

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/OrderByList.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/OrderByList.java?rev=808523&r1=808522&r2=808523&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/OrderByList.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/OrderByList.java Thu Aug 27 17:02:52 2009
@@ -112,22 +112,6 @@
 	}
 
 	/**
-		Print the list.
-	
-		@param depth		The depth at which to indent the sub-nodes
-	 */
-	public void printSubNodes(int depth) {
-
-		if (SanityManager.DEBUG) 
-		{
-			for (int index = 0; index < size(); index++)
-			{
-				( (OrderByColumn) (elementAt(index)) ).treePrint(depth);
-			}
-		}
-	}
-
-	/**
 		Bind the update columns by their names to the target resultset
 		of the cursor specification.
 
@@ -868,4 +852,24 @@
 		 */
 		columnOrdering = getColumnOrdering();		
 	}
+
+
+	public String toString() {
+
+		StringBuffer buff = new StringBuffer();
+
+		if (columnOrdering != null) {
+			for (int i = 0; i < columnOrdering.length; i++) {
+				buff.append("[" + i + "] " + columnOrdering[i] + "\n");
+			}
+		}
+
+		return
+			"allAscending: " + allAscending + "\n" +
+			"alwaysSort:" + allAscending + "\n" +
+			"sortNeeded: " + sortNeeded  + "\n" +
+			"columnOrdering: " + "\n" +
+			buff.toString() + "\n" +
+			super.toString();
+	}
 }

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/OrderByNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/OrderByNode.java?rev=808523&r1=808522&r2=808523&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/OrderByNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/OrderByNode.java Thu Aug 27 17:02:52 2009
@@ -83,28 +83,29 @@
 		resultColumns.genVirtualColumnNodes(this, prRCList);
 	}
 
+
 	/**
-	 * Convert this object to a String.  See comments in QueryTreeNode.java
-	 * for how this should be done for tree printing.
+	 * Prints the sub-nodes of this object.  See QueryTreeNode.java for
+	 * how tree printing is supposed to work.
 	 *
-	 * @return	This object as a String
+	 * @param depth		The depth of this node in the tree
 	 */
 
-	public String toString()
+	public void printSubNodes(int depth)
 	{
 		if (SanityManager.DEBUG)
 		{
-			return childResult.toString() + "\n" + 
-				"orderByList: " + 
-				(orderByList != null ? orderByList.toString() : "null") + "\n" +
-				super.toString();
-		}
-		else
-		{
-			return "";
+			super.printSubNodes(depth);
+
+			if (orderByList != null)
+			{
+				printLabel(depth, "orderByList: ");
+				orderByList.treePrint(depth + 1);
+			}
 		}
 	}
 
+
 	ResultColumnDescriptor[] makeResultDescriptors()
 	{
 	    return childResult.makeResultDescriptors();

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/PredicateList.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/PredicateList.java?rev=808523&r1=808522&r2=808523&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/PredicateList.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/PredicateList.java Thu Aug 27 17:02:52 2009
@@ -1097,29 +1097,6 @@
 
 
 	/**
-	 * Prints the sub-nodes of this object.  See QueryTreeNode.java for
-	 * how tree printing is supposed to work.
-	 *
-	 * @param depth		The depth of this node in the tree
-	 */
-
-	public void printSubNodes(int depth)
-	{
-		if (SanityManager.DEBUG)
-		{
-			Predicate		predicate;
-
-			super.printSubNodes(depth);
-
-			for (int index = 0; index < size(); index++)
-			{
-				predicate = (Predicate) elementAt(index);
-				predicate.treePrint(depth + 1);
-			}
-		}
-	}
-
-	/**
 	 *  Eliminate predicates of the form:
 	 *							AndNode
 	 *							/	   \

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/QueryTreeNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/QueryTreeNode.java?rev=808523&r1=808522&r2=808523&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/QueryTreeNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/QueryTreeNode.java Thu Aug 27 17:02:52 2009
@@ -22,6 +22,7 @@
 package	org.apache.derby.impl.sql.compile;
 
 import java.sql.Types;
+import java.util.Map;
 
 import org.apache.derby.catalog.AliasInfo;
 import org.apache.derby.catalog.types.SynonymAliasInfo;
@@ -328,7 +329,13 @@
 		if (SanityManager.DEBUG)
 		{
 			debugPrint(nodeHeader());
-			debugPrint(formatNodeString(this.toString(), 0));
+			String thisStr = formatNodeString(this.toString(), 0);
+
+			if (containsInfo(thisStr) &&
+					!SanityManager.DEBUG_ON("DumpBrief")) {
+				debugPrint(thisStr);
+			}
+
 			printSubNodes(0);
 			debugFlush();
 		}
@@ -347,12 +354,38 @@
 	{
 		if (SanityManager.DEBUG)
 		{
-			debugPrint(formatNodeString(nodeHeader(), depth));
-			debugPrint(formatNodeString(this.toString(), depth));
-			printSubNodes(depth);
+			Map printed =
+				getLanguageConnectionContext().getPrintedObjectsMap();
+
+			if (printed.containsKey(this)) {
+				debugPrint(formatNodeString(nodeHeader(), depth));
+				debugPrint(formatNodeString("***truncated***\n", depth));
+			} else {
+				printed.put(this, null);
+				debugPrint(formatNodeString(nodeHeader(), depth));
+				String thisStr = formatNodeString(this.toString(), depth);
+
+				if (containsInfo(thisStr) &&
+						!SanityManager.DEBUG_ON("DumpBrief")) {
+					debugPrint(thisStr);
+				}
+
+				printSubNodes(depth);
+			}
+
 		}
 	}
 
+
+	private static boolean containsInfo(String str) {
+		for (int i = 0; i < str.length(); i++) {
+			if (str.charAt(i) != '\t' && str.charAt(i) != '\n') {
+				return true;
+			}
+		}
+		return false;
+	}
+
 	/**
 	 * Print a String for debugging
 	 *
@@ -420,6 +453,12 @@
 	 *
 	 * "memberName: " + memberName + "\n" + ...
 	 *
+	 * Vector members containing subclasses of QueryTreeNode should subclass
+	 * QueryTreeNodeVector. Such subclasses form a special case: These classes
+	 * should not implement printSubNodes, since there is generic handling in
+	 * QueryTreeNodeVector.  They should only implement toString if they
+	 * contain additional members.
+	 *
 	 * @return	This node formatted as a String
 	 */
 

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/QueryTreeNodeVector.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/QueryTreeNodeVector.java?rev=808523&r1=808522&r2=808523&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/QueryTreeNodeVector.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/QueryTreeNodeVector.java Thu Aug 27 17:02:52 2009
@@ -106,34 +106,23 @@
 		v.insertElementAt(qt, index);
 	}
 
+
 	/**
-	 * Format this list as a string
-	 *
-	 * We can simply iterate through the list.  Note each list member
-	 * is a QueryTreeNode, and so should have its specialization of
-	 * toString defined.
-	 *
-	 * @return	This list formatted as a String
+	 * Prints the sub-nodes of this object.  See QueryTreeNode.java for
+	 * how tree printing is supposed to work.
+	 * @param depth		The depth to indent the sub-nodes
 	 */
-	public String toString()
-	{
-		if (SanityManager.DEBUG)
-		{
-			StringBuffer	buffer = new StringBuffer("");
-
-			for (int index = 0; index < size(); index++)
-			{
-				buffer.append(elementAt(index).toString()).append("; ");
+	public void printSubNodes(int depth) {
+		if (SanityManager.DEBUG) {
+			for (int index = 0; index < size(); index++) {
+				debugPrint(formatNodeString("[" + index + "]:", depth));
+				QueryTreeNode elt = (QueryTreeNode)elementAt(index);
+				elt.treePrint(depth);
 			}
-
-			return buffer.toString();
-		}
-		else
-		{
-			return "";
 		}
 	}
 
+
 	/**
 	 * Accept a visitor, and call v.visit()
 	 * on child nodes as necessary.  

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ResultColumnList.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ResultColumnList.java?rev=808523&r1=808522&r2=808523&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ResultColumnList.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ResultColumnList.java Thu Aug 27 17:02:52 2009
@@ -665,24 +665,6 @@
 		}
 	}
 
-	/**
-	 * This class needs a treePrint method, even though it is not a
-	 * descendant of QueryTreeNode, because its members contain tree
-	 * nodes, and these have to be printed and indented properly.
-	 *
-	 * @param depth		The depth at which to indent the sub-nodes
-	 */
-
-	public void treePrint(int depth)
-	{
-		if (SanityManager.DEBUG)
-		{
-			for (int index = 0; index < size(); index++)
-			{
-				((ResultColumn) elementAt(index) ).treePrint(depth);
-			}
-		}
-	}
 
 	/**
 	 * Bind the expressions in this ResultColumnList.  This means binding
@@ -4250,4 +4232,21 @@
 		resetVirtualColumnIds();
 	}
 
+	/**
+	 * Convert this object to a String.  See comments in QueryTreeNode.java
+	 * for how this should be done for tree printing.
+	 *
+	 * @return	This object as a String
+	 */
+	public String toString()
+	{
+		if (SanityManager.DEBUG) {
+			return "indexRow: " + indexRow + "\n" +
+				(indexRow ? "conglomerateId: " + conglomerateId + "\n"
+				 : "") +
+				super.toString();
+		} else {
+			return "";
+		}
+	}
 }

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ResultSetNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ResultSetNode.java?rev=808523&r1=808522&r2=808523&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ResultSetNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ResultSetNode.java Thu Aug 27 17:02:52 2009
@@ -144,7 +144,7 @@
 			if (resultColumns != null)
 			{
 				printLabel(depth, "resultColumns: ");
-				resultColumns.treePrint(depth);
+				resultColumns.treePrint(depth + 1);
 			}
 		}
 	}

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/SelectNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/SelectNode.java?rev=808523&r1=808522&r2=808523&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/SelectNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/SelectNode.java Thu Aug 27 17:02:52 2009
@@ -162,10 +162,6 @@
 		if (SanityManager.DEBUG)
 		{
 			return "isDistinct: "+ isDistinct + "\n"+
-		    	"groupByList: " +
-				(groupByList != null ? groupByList.toString() : "null") + "\n" +
-				"orderByList: " + 
-				(orderByList != null ? orderByList.toString() : "null") + "\n" +
 				super.toString();
 		}
 		else
@@ -238,12 +234,22 @@
 				whereSubquerys.treePrint(depth + 1);
 			}
 
-			printLabel(depth, "preJoinFL: ");
+			if (groupByList != null) {
+				printLabel(depth, "groupByList:");
+				groupByList.treePrint(depth + 1);
+			}
+
+			if (orderByList != null) {
+				printLabel(depth, "orderByList:");
+				orderByList.treePrint(depth + 1);
+			}
 
 			if (preJoinFL != null)
 			{
+				printLabel(depth, "preJoinFL: ");
 				preJoinFL.treePrint(depth + 1);
 			}
+
 		}
 	}
 

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/SetOperatorNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/SetOperatorNode.java?rev=808523&r1=808522&r2=808523&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/SetOperatorNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/SetOperatorNode.java Thu Aug 27 17:02:52 2009
@@ -529,8 +529,6 @@
 		if (SanityManager.DEBUG)
 		{
 			return 	"all: " + all + "\n" +
-				"orderByList: " + 
-				(orderByList != null ? orderByList.toString() : "null") + "\n" +
 				super.toString();
 		}
 		else
@@ -540,6 +538,26 @@
 	}
 
 	/**
+	 * Prints the sub-nodes of this object.  See QueryTreeNode.java for
+	 * how tree printing is supposed to work.
+	 *
+	 * @param depth		The depth of this node in the tree
+	 */
+
+	public void printSubNodes(int depth)
+	{
+		if (SanityManager.DEBUG)
+		{
+			super.printSubNodes(depth);
+
+			if (orderByList != null) {
+				printLabel(depth, "orderByList:");
+				orderByList.treePrint(depth + 1);
+			}
+
+		}
+	}
+	/**
 	 * Bind the result columns of this ResultSetNode when there is no
 	 * base table to bind them to.  This is useful for SELECT statements,
 	 * where the result columns get their types from the expressions that

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/SpecialFunctionNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/SpecialFunctionNode.java?rev=808523&r1=808522&r2=808523&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/SpecialFunctionNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/SpecialFunctionNode.java Thu Aug 27 17:02:52 2009
@@ -257,7 +257,8 @@
 	public String toString() {
 		if (SanityManager.DEBUG)
 		{
-			return super.toString()+ sqlName;
+			return "sqlName: " + sqlName + "\n" +
+				super.toString();
 		}
 		else
 		{

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/SubqueryList.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/SubqueryList.java?rev=808523&r1=808522&r2=808523&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/SubqueryList.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/SubqueryList.java Thu Aug 27 17:02:52 2009
@@ -35,30 +35,6 @@
 
 public class SubqueryList extends QueryTreeNodeVector
 {
-
-	/**
-	 * Prints the sub-nodes of this object.  See QueryTreeNode.java for
-	 * how tree printing is supposed to work.
-	 *
-	 * @param depth		The depth of this node in the tree
-	 */
-
-	public void printSubNodes(int depth)
-	{
-		if (SanityManager.DEBUG)
-		{
-			SubqueryNode	subqueryNode;
-
-			super.printSubNodes(depth);
-
-			for (int index = 0; index < size(); index++)
-			{
-				subqueryNode = (SubqueryNode) elementAt(index);
-				subqueryNode.treePrint(depth + 1);
-			}
-		}
-	}
-
 	/**
 	 * Add a subquery to the list.
 	 *

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/TableElementList.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/TableElementList.java?rev=808523&r1=808522&r2=808523&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/TableElementList.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/TableElementList.java Thu Aug 27 17:02:52 2009
@@ -91,32 +91,6 @@
 	} 
 
 	/**
-	 * Convert this object to a String.  See comments in QueryTreeNode.java
-	 * for how this should be done for tree printing.
-	 *
-	 * @return	This object as a String
-	 */
-
-	public String toString()
-	{
-		if (SanityManager.DEBUG)
-		{
-			StringBuffer	buffer = new StringBuffer("");
-
-			for (int index = 0; index < size(); index++)
-			{
-				buffer.append(elementAt(index).toString()).append("\n");
-			}
-
-			return buffer.toString();
-		}
-		else
-		{
-			return "";
-		}
-	}
-
-	/**
 	 * Use the passed schema descriptor's collation type to set the collation
 	 * of the character string types in create table node
 	 * @param sd

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/TableOperatorNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/TableOperatorNode.java?rev=808523&r1=808522&r2=808523&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/TableOperatorNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/TableOperatorNode.java Thu Aug 27 17:02:52 2009
@@ -238,8 +238,6 @@
 		if (SanityManager.DEBUG)
 		{
 			return "nestedInParens: " + false + "\n" +
-				leftResultSet.toString() + "\n" +
-				rightResultSet.toString() + "\n" + 
 				super.toString();
 		}
 		else
@@ -264,13 +262,13 @@
 			if (leftResultSet != null)
 			{
 				printLabel(depth, "leftResultSet: ");
-				leftResultSet.printSubNodes(depth + 1);
+				leftResultSet.treePrint(depth + 1);
 			}
 
 			if (rightResultSet != null)
 			{
 				printLabel(depth, "rightResultSet: ");
-				rightResultSet.printSubNodes(depth + 1);
+				rightResultSet.treePrint(depth + 1);
 			}
 		}
 	}

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ValueNodeList.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ValueNodeList.java?rev=808523&r1=808522&r2=808523&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ValueNodeList.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ValueNodeList.java Thu Aug 27 17:02:52 2009
@@ -49,30 +49,6 @@
 
 public class ValueNodeList extends QueryTreeNodeVector
 {
-
-	/**
-	 * Prints the sub-nodes of this object.  See QueryTreeNode.java for
-	 * how tree printing is supposed to work.
-	 *
-	 * @param depth		The depth of this node in the tree
-	 */
-
-	public void printSubNodes(int depth)
-	{
-		if (SanityManager.DEBUG)
-		{
-			super.printSubNodes(depth);
-
-			for (int index = 0; index < size(); index++)
-			{
-				ValueNode		valueNode;
-				valueNode = (ValueNode) elementAt(index);
-				valueNode.treePrint(depth + 1);
-			}
-		}
-	}
-
-
 	/**
 	 * Add a ValueNode to the list.
 	 *

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/WindowFunctionColumnNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/WindowFunctionColumnNode.java?rev=808523&r1=808522&r2=808523&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/WindowFunctionColumnNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/WindowFunctionColumnNode.java Thu Aug 27 17:02:52 2009
@@ -167,4 +167,22 @@
 	{
 		return null;
 	}
+
+	/**
+	 * Prints the sub-nodes of this object.  See QueryTreeNode.java for
+	 * how tree printing is supposed to work.
+	 *
+	 * @param depth		The depth of this node in the tree
+	 */
+
+	public void printSubNodes(int depth)
+	{
+		super.printSubNodes(depth);
+		if (SanityManager.DEBUG)
+		{
+			printLabel(depth, "windownode: ");
+			windowNode.treePrint(depth + 1);
+		}
+	}
+
 }

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/conn/GenericLanguageConnectionContext.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/conn/GenericLanguageConnectionContext.java?rev=808523&r1=808522&r2=808523&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/conn/GenericLanguageConnectionContext.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/conn/GenericLanguageConnectionContext.java Thu Aug 27 17:02:52 2009
@@ -82,6 +82,8 @@
 import java.util.List;
 import java.util.ArrayList;
 import java.util.HashMap;
+import java.util.AbstractMap;
+import java.util.IdentityHashMap;
 import java.util.Iterator;
 import java.util.Map;
 
@@ -3473,6 +3475,22 @@
 			getInitialDefaultSchemaDescriptor());
 	}
 
+	/**
+	 * This holds a map of AST nodes that have already been printed during a
+	 * compiler phase, so as to be able to avoid printing a node more than once.
+	 * @see org.apache.derby.impl.sql.compile.QueryTreeNode#treePrint(int)
+	 */
+	Map printedObjectsMap = null;
+
+	/**
+	 * @see org.apache.derby.iapi.sql.conn.LanguageConnectionContext#getPrintedObjectsMap
+	 */
+	public Map getPrintedObjectsMap() {
+		if (printedObjectsMap == null) {
+			printedObjectsMap = new IdentityHashMap();
+		}
+		return printedObjectsMap;
+	}
 
 	/** @see LanguageConnectionContext#getXplainOnlyMode() */
 	public boolean getXplainOnlyMode() {

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/DependentResultSet.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/DependentResultSet.java?rev=808523&r1=808522&r2=808523&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/DependentResultSet.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/DependentResultSet.java Thu Aug 27 17:02:52 2009
@@ -675,17 +675,22 @@
 				MessageService.getTextMessage(
 											  SQLState.LANG_ORDERED_NULL_SEMANTICS) +
 				"\n";
+			boolean colSeen = false;
 			for (int position = 0; position < positioner.nColumns(); position++)
 			{
 				if (positioner.areNullsOrdered(position))
 				{
 					output = output + position + " ";
+					colSeen = true;
+				}
+
+				if (colSeen && position == positioner.nColumns() - 1) {
+					output = output +  "\n";
 				}
 			}
-	
 		}
 	
-		return output + "\n";
+		return output;
 	}
 
 

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/HashScanResultSet.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/HashScanResultSet.java?rev=808523&r1=808522&r2=808523&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/HashScanResultSet.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/HashScanResultSet.java Thu Aug 27 17:02:52 2009
@@ -740,15 +740,21 @@
 		output += "\t" + MessageService.getTextMessage(
 										SQLState.LANG_ORDERED_NULL_SEMANTICS) +
 										"\n";
+		boolean colSeen = false;
 		for (int position = 0; position < positioner.nColumns(); position++)
 		{
 			if (positioner.areNullsOrdered(position))
 			{
 				output = output + position + " ";
+				colSeen = true;
+			}
+
+			if (colSeen && position == positioner.nColumns() - 1) {
+				output = output +  "\n";
 			}
 		}
 		
-		return output + "\n";
+		return output;
 	}
 
 	public Properties getScanProperties()

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/IndexColumnOrder.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/IndexColumnOrder.java?rev=808523&r1=808522&r2=808523&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/IndexColumnOrder.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/IndexColumnOrder.java Thu Aug 27 17:02:52 2009
@@ -23,6 +23,8 @@
 
 import org.apache.derby.iapi.store.access.ColumnOrdering;
 
+import org.apache.derby.iapi.services.sanity.SanityManager;
+
 import org.apache.derby.iapi.services.io.StoredFormatIds;
 import org.apache.derby.iapi.services.io.FormatIdUtil;
 import org.apache.derby.iapi.services.io.Formatable;
@@ -172,4 +174,16 @@
 	 *	@return	the formatID of this class
 	 */
 	public	int	getTypeFormatId()	{ return StoredFormatIds.INDEX_COLUMN_ORDER_V01_ID; }
+
+	public String toString() {
+		if (SanityManager.DEBUG) {
+			return
+				"IndexColumnOrder.colNum: " + colNum + "\n" +
+				"IndexColumnOrder.ascending: " + ascending  + "\n" +
+				"IndexColumnOrder.nullsOrderedLow: " + nullsOrderedLow;
+		} else {
+			return super.toString();
+		}
+
+	}
 }

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/TableScanResultSet.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/TableScanResultSet.java?rev=808523&r1=808522&r2=808523&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/TableScanResultSet.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/TableScanResultSet.java Thu Aug 27 17:02:52 2009
@@ -1325,15 +1325,21 @@
 					MessageService.getTextMessage(
 						SQLState.LANG_ORDERED_NULL_SEMANTICS) +
 					"\n";
+		boolean colSeen = false;
 		for (int position = 0; position < positioner.nColumns(); position++)
 		{
 			if (positioner.areNullsOrdered(position))
 			{
 				output = output + position + " ";
+				colSeen = true;
+			}
+
+			if (colSeen && position == positioner.nColumns() - 1) {
+				output = output +  "\n";
 			}
 		}
-		
-		return output + "\n";
+
+		return output;
 	}
 
 	public Properties getScanProperties()

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=808523&r1=808522&r2=808523&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 Thu Aug 27 17:02:52 2009
@@ -28,6 +28,7 @@
 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 org.apache.derby.iapi.util.StringUtil;
 
 import java.util.Enumeration;
 import java.util.Hashtable;
@@ -194,17 +195,17 @@
 			scanInfo +
 			subIndent + MessageService.getTextMessage(
 												SQLState.RTS_START_POSITION) +
-						":\n" + startPosition + 
+			":\n" + StringUtil.ensureIndent(startPosition, depth + 2) + "\n" +
 			subIndent + MessageService.getTextMessage(
 												SQLState.RTS_STOP_POSITION) +
-						":\n" + stopPosition +
+			":\n" + StringUtil.ensureIndent(stopPosition, depth + 2) + "\n" +
 			subIndent + MessageService.getTextMessage(
 												SQLState.RTS_SCAN_QUALS) +
-						":\n" + scanQualifiers + "\n" +
-			subIndent +
-						MessageService.getTextMessage(
+			":\n" + StringUtil.ensureIndent(scanQualifiers, depth + 2) + "\n" +
+			subIndent + MessageService.getTextMessage(
 												SQLState.RTS_NEXT_QUALS) +
-						":\n" + nextQualifiers + "\n" +
+			":\n" + StringUtil.ensureIndent(nextQualifiers, depth + 2) + "\n" +
+
 			// RESOLVE - estimated row count and cost will eventually 
 			// be displayed for all nodes
 			dumpEstimatedCosts(subIndent);

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=808523&r1=808522&r2=808523&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 Thu Aug 27 17:02:52 2009
@@ -23,6 +23,7 @@
 
 import org.apache.derby.iapi.services.io.StoredFormatIds;
 import org.apache.derby.iapi.util.PropertyUtil;
+import org.apache.derby.iapi.util.StringUtil;
 
 import org.apache.derby.iapi.services.i18n.MessageService;
 import org.apache.derby.iapi.reference.SQLState;
@@ -225,17 +226,18 @@
 					"") + "\n" +
 			scanInfo +
 			subIndent + MessageService.getTextMessage(
-												SQLState.RTS_START_POSITION) +
-					": \n" + startPosition + 
+				SQLState.RTS_START_POSITION) +
+			": \n" + StringUtil.ensureIndent(startPosition, depth + 2) + "\n" +
 			subIndent + MessageService.getTextMessage(
 												SQLState.RTS_STOP_POSITION) +
-					": \n" + stopPosition +
+			": \n" + StringUtil.ensureIndent(stopPosition, depth + 2) + "\n" +
 			subIndent + MessageService.getTextMessage(
 													SQLState.RTS_SCAN_QUALS) +
-					":\n" + scanQualifiers + "\n" +
+			":\n" + StringUtil.ensureIndent(scanQualifiers, depth + 2) + "\n" +
 			subIndent + MessageService.getTextMessage(
 													SQLState.RTS_NEXT_QUALS) +
-					":\n" + nextQualifiers + "\n" +
+			":\n" + StringUtil.ensureIndent(nextQualifiers, depth + 2) + "\n" +
+
 			// RESOLVE - estimated row count and cost will eventually 
 			// be displayed for all nodes
 			dumpEstimatedCosts(subIndent);

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/rts/RealTableScanStatistics.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/rts/RealTableScanStatistics.java?rev=808523&r1=808522&r2=808523&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/rts/RealTableScanStatistics.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/rts/RealTableScanStatistics.java Thu Aug 27 17:02:52 2009
@@ -23,6 +23,7 @@
 
 import org.apache.derby.iapi.services.io.StoredFormatIds;
 import org.apache.derby.iapi.util.PropertyUtil;
+import org.apache.derby.iapi.util.StringUtil;
 
 import org.apache.derby.iapi.services.i18n.MessageService;
 import org.apache.derby.iapi.reference.SQLState;
@@ -217,12 +218,13 @@
 			scanInfo +
 			subIndent + MessageService.getTextMessage(
 												SQLState.RTS_START_POSITION) +
-				": \n" + startPosition + 
+			": \n" + StringUtil.ensureIndent(startPosition, depth + 2) + "\n" +
 			subIndent + MessageService.getTextMessage(
 												SQLState.RTS_STOP_POSITION) +
-				": \n" + stopPosition +
+			": \n" + StringUtil.ensureIndent(stopPosition, depth + 2) + "\n" +
 			subIndent + MessageService.getTextMessage(SQLState.RTS_QUALS) +
-				":\n" + qualifiers + "\n" +
+			": \n" + StringUtil.ensureIndent(qualifiers, depth + 2) + "\n" +
+
 			// RESOLVE - estimated row count and cost will eventually 
 			// be displayed for all nodes
 			dumpEstimatedCosts(subIndent);