db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From myrn...@apache.org
Subject svn commit: r1573813 - in /db/derby/code/branches/10.10: ./ java/engine/org/apache/derby/impl/sql/execute/ java/testing/org/apache/derbyTesting/functionTests/master/ java/testing/org/apache/derbyTesting/functionTests/tests/lang/
Date Mon, 03 Mar 2014 23:43:47 GMT
Author: myrnavl
Date: Mon Mar  3 23:43:46 2014
New Revision: 1573813

URL: http://svn.apache.org/r1573813
Log:
DERBY-6216; XPLAIN feature does not work and gives ERROR XCL16: ResultSet not open
   backport of revision 1502795 from trunk; 
   clean merge, but added modifications to XplainStatisticsTest from revision 1518111 (DERBY-6297)
not previously backported.

Added:
    db/derby/code/branches/10.10/java/testing/org/apache/derbyTesting/functionTests/master/xplain.out
      - copied unchanged from r1502795, db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/xplain.out
    db/derby/code/branches/10.10/java/testing/org/apache/derbyTesting/functionTests/tests/lang/xplain.sql
      - copied unchanged from r1502795, db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/xplain.sql
Modified:
    db/derby/code/branches/10.10/   (props changed)
    db/derby/code/branches/10.10/java/engine/org/apache/derby/impl/sql/execute/AnyResultSet.java
    db/derby/code/branches/10.10/java/engine/org/apache/derby/impl/sql/execute/BasicNoPutResultSetImpl.java
    db/derby/code/branches/10.10/java/engine/org/apache/derby/impl/sql/execute/BulkTableScanResultSet.java
    db/derby/code/branches/10.10/java/engine/org/apache/derby/impl/sql/execute/CurrentOfResultSet.java
    db/derby/code/branches/10.10/java/engine/org/apache/derby/impl/sql/execute/DependentResultSet.java
    db/derby/code/branches/10.10/java/engine/org/apache/derby/impl/sql/execute/DistinctScalarAggregateResultSet.java
    db/derby/code/branches/10.10/java/engine/org/apache/derby/impl/sql/execute/DistinctScanResultSet.java
    db/derby/code/branches/10.10/java/engine/org/apache/derby/impl/sql/execute/GroupedAggregateResultSet.java
    db/derby/code/branches/10.10/java/engine/org/apache/derby/impl/sql/execute/HashScanResultSet.java
    db/derby/code/branches/10.10/java/engine/org/apache/derby/impl/sql/execute/HashTableResultSet.java
    db/derby/code/branches/10.10/java/engine/org/apache/derby/impl/sql/execute/IndexRowToBaseRowResultSet.java
    db/derby/code/branches/10.10/java/engine/org/apache/derby/impl/sql/execute/LastIndexKeyResultSet.java
    db/derby/code/branches/10.10/java/engine/org/apache/derby/impl/sql/execute/MaterializedResultSet.java
    db/derby/code/branches/10.10/java/engine/org/apache/derby/impl/sql/execute/MergeJoinResultSet.java
    db/derby/code/branches/10.10/java/engine/org/apache/derby/impl/sql/execute/MultiProbeTableScanResultSet.java
    db/derby/code/branches/10.10/java/engine/org/apache/derby/impl/sql/execute/NestedLoopJoinResultSet.java
    db/derby/code/branches/10.10/java/engine/org/apache/derby/impl/sql/execute/NestedLoopLeftOuterJoinResultSet.java
    db/derby/code/branches/10.10/java/engine/org/apache/derby/impl/sql/execute/NormalizeResultSet.java
    db/derby/code/branches/10.10/java/engine/org/apache/derby/impl/sql/execute/OnceResultSet.java
    db/derby/code/branches/10.10/java/engine/org/apache/derby/impl/sql/execute/ProjectRestrictResultSet.java
    db/derby/code/branches/10.10/java/engine/org/apache/derby/impl/sql/execute/RowCountResultSet.java
    db/derby/code/branches/10.10/java/engine/org/apache/derby/impl/sql/execute/RowResultSet.java
    db/derby/code/branches/10.10/java/engine/org/apache/derby/impl/sql/execute/ScalarAggregateResultSet.java
    db/derby/code/branches/10.10/java/engine/org/apache/derby/impl/sql/execute/ScrollInsensitiveResultSet.java
    db/derby/code/branches/10.10/java/engine/org/apache/derby/impl/sql/execute/SetOpResultSet.java
    db/derby/code/branches/10.10/java/engine/org/apache/derby/impl/sql/execute/SortResultSet.java
    db/derby/code/branches/10.10/java/engine/org/apache/derby/impl/sql/execute/TableScanResultSet.java
    db/derby/code/branches/10.10/java/engine/org/apache/derby/impl/sql/execute/UnionResultSet.java
    db/derby/code/branches/10.10/java/engine/org/apache/derby/impl/sql/execute/VTIResultSet.java
    db/derby/code/branches/10.10/java/engine/org/apache/derby/impl/sql/execute/WindowResultSet.java
    db/derby/code/branches/10.10/java/testing/org/apache/derbyTesting/functionTests/tests/lang/LangScripts.java
    db/derby/code/branches/10.10/java/testing/org/apache/derbyTesting/functionTests/tests/lang/XplainStatisticsTest.java

Propchange: db/derby/code/branches/10.10/
------------------------------------------------------------------------------
  Merged /db/derby/code/trunk:r1502795

Modified: db/derby/code/branches/10.10/java/engine/org/apache/derby/impl/sql/execute/AnyResultSet.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.10/java/engine/org/apache/derby/impl/sql/execute/AnyResultSet.java?rev=1573813&r1=1573812&r2=1573813&view=diff
==============================================================================
--- db/derby/code/branches/10.10/java/engine/org/apache/derby/impl/sql/execute/AnyResultSet.java
(original)
+++ db/derby/code/branches/10.10/java/engine/org/apache/derby/impl/sql/execute/AnyResultSet.java
Mon Mar  3 23:43:46 2014
@@ -155,6 +155,9 @@ public class AnyResultSet extends NoPutR
 	 */
 	public ExecRow	getNextRowCore() throws StandardException 
 	{
+		if( isXplainOnlyMode() )
+			return null;
+
 	    ExecRow candidateRow = null;
 		ExecRow secondRow = null;
 	    ExecRow result = null;

Modified: db/derby/code/branches/10.10/java/engine/org/apache/derby/impl/sql/execute/BasicNoPutResultSetImpl.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.10/java/engine/org/apache/derby/impl/sql/execute/BasicNoPutResultSetImpl.java?rev=1573813&r1=1573812&r2=1573813&view=diff
==============================================================================
--- db/derby/code/branches/10.10/java/engine/org/apache/derby/impl/sql/execute/BasicNoPutResultSetImpl.java
(original)
+++ db/derby/code/branches/10.10/java/engine/org/apache/derby/impl/sql/execute/BasicNoPutResultSetImpl.java
Mon Mar  3 23:43:46 2014
@@ -137,6 +137,13 @@ implements NoPutResultSet
 		return activation;
 	}
 
+	protected final boolean isXplainOnlyMode()
+	{
+		LanguageConnectionContext lcc = getLanguageConnectionContext();
+		return
+		  (lcc.getRunTimeStatisticsMode() && lcc.getXplainOnlyMode());
+	}
+
 	// NoPutResultSet interface
 
 	/**
@@ -248,12 +255,7 @@ implements NoPutResultSet
 		attachStatementContext();
 
 		try {
-			LanguageConnectionContext lcc = getLanguageConnectionContext();
-			if(lcc.getRunTimeStatisticsMode() && lcc.getXplainOnlyMode()) {
-				// do nothing
-			} else {
-				openCore();
-			}
+			openCore();
 
 		} catch (StandardException se) {
 			activation.checkStatementValidity();
@@ -455,8 +457,8 @@ implements NoPutResultSet
 	 */
 	public final ExecRow	getNextRow() throws StandardException 
 	{
-		LanguageConnectionContext lcc = getLanguageConnectionContext();
-		if(lcc.getRunTimeStatisticsMode() && lcc.getXplainOnlyMode()){
+		if( isXplainOnlyMode() )
+		{
 			// return null to indicate no results available and 
 			// to bypass the execution
 			return null;

Modified: db/derby/code/branches/10.10/java/engine/org/apache/derby/impl/sql/execute/BulkTableScanResultSet.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.10/java/engine/org/apache/derby/impl/sql/execute/BulkTableScanResultSet.java?rev=1573813&r1=1573812&r2=1573813&view=diff
==============================================================================
--- db/derby/code/branches/10.10/java/engine/org/apache/derby/impl/sql/execute/BulkTableScanResultSet.java
(original)
+++ db/derby/code/branches/10.10/java/engine/org/apache/derby/impl/sql/execute/BulkTableScanResultSet.java
Mon Mar  3 23:43:46 2014
@@ -286,6 +286,9 @@ class BulkTableScanResultSet extends Tab
 	 */
 	public ExecRow getNextRowCore() throws StandardException
 	{
+		if( isXplainOnlyMode() )
+			return null;
+
 	    ExecRow result = null;
             
         checkCancellationFlag();

Modified: db/derby/code/branches/10.10/java/engine/org/apache/derby/impl/sql/execute/CurrentOfResultSet.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.10/java/engine/org/apache/derby/impl/sql/execute/CurrentOfResultSet.java?rev=1573813&r1=1573812&r2=1573813&view=diff
==============================================================================
--- db/derby/code/branches/10.10/java/engine/org/apache/derby/impl/sql/execute/CurrentOfResultSet.java
(original)
+++ db/derby/code/branches/10.10/java/engine/org/apache/derby/impl/sql/execute/CurrentOfResultSet.java
Mon Mar  3 23:43:46 2014
@@ -100,6 +100,9 @@ class CurrentOfResultSet extends NoPutRe
      */
 	public ExecRow	getNextRowCore() throws StandardException {
 
+		if( isXplainOnlyMode() )
+			return null;
+
 		if ( isOpen ) {
 	        if ( ! next ) {
 	            next = true;

Modified: db/derby/code/branches/10.10/java/engine/org/apache/derby/impl/sql/execute/DependentResultSet.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.10/java/engine/org/apache/derby/impl/sql/execute/DependentResultSet.java?rev=1573813&r1=1573812&r2=1573813&view=diff
==============================================================================
--- db/derby/code/branches/10.10/java/engine/org/apache/derby/impl/sql/execute/DependentResultSet.java
(original)
+++ db/derby/code/branches/10.10/java/engine/org/apache/derby/impl/sql/execute/DependentResultSet.java
Mon Mar  3 23:43:46 2014
@@ -338,6 +338,9 @@ class DependentResultSet extends ScanRes
 	public ExecRow	getNextRowCore() throws StandardException 
 	{
 		
+		if( isXplainOnlyMode() )
+			return null;
+
 		beginTime = getCurrentTimeMillis();
 		if (searchRow == null)
 		{

Modified: db/derby/code/branches/10.10/java/engine/org/apache/derby/impl/sql/execute/DistinctScalarAggregateResultSet.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.10/java/engine/org/apache/derby/impl/sql/execute/DistinctScalarAggregateResultSet.java?rev=1573813&r1=1573812&r2=1573813&view=diff
==============================================================================
--- db/derby/code/branches/10.10/java/engine/org/apache/derby/impl/sql/execute/DistinctScalarAggregateResultSet.java
(original)
+++ db/derby/code/branches/10.10/java/engine/org/apache/derby/impl/sql/execute/DistinctScalarAggregateResultSet.java
Mon Mar  3 23:43:46 2014
@@ -170,6 +170,9 @@ class DistinctScalarAggregateResultSet e
 	 */
 	public ExecRow	getNextRowCore() throws StandardException 
 	{
+		if( isXplainOnlyMode() )
+			return null;
+
 	    ExecIndexRow execIndexRow = null;
 	    ExecIndexRow aggResult = null;
 		boolean	cloneArg = true;

Modified: db/derby/code/branches/10.10/java/engine/org/apache/derby/impl/sql/execute/DistinctScanResultSet.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.10/java/engine/org/apache/derby/impl/sql/execute/DistinctScanResultSet.java?rev=1573813&r1=1573812&r2=1573813&view=diff
==============================================================================
--- db/derby/code/branches/10.10/java/engine/org/apache/derby/impl/sql/execute/DistinctScanResultSet.java
(original)
+++ db/derby/code/branches/10.10/java/engine/org/apache/derby/impl/sql/execute/DistinctScanResultSet.java
Mon Mar  3 23:43:46 2014
@@ -96,6 +96,9 @@ class DistinctScanResultSet extends Hash
 	 */
 	public ExecRow getNextRowCore() throws StandardException
 	{
+		if( isXplainOnlyMode() )
+			return null;
+
 	    ExecRow result = null;
 
 		beginTime = getCurrentTimeMillis();

Modified: db/derby/code/branches/10.10/java/engine/org/apache/derby/impl/sql/execute/GroupedAggregateResultSet.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.10/java/engine/org/apache/derby/impl/sql/execute/GroupedAggregateResultSet.java?rev=1573813&r1=1573812&r2=1573813&view=diff
==============================================================================
--- db/derby/code/branches/10.10/java/engine/org/apache/derby/impl/sql/execute/GroupedAggregateResultSet.java
(original)
+++ db/derby/code/branches/10.10/java/engine/org/apache/derby/impl/sql/execute/GroupedAggregateResultSet.java
Mon Mar  3 23:43:46 2014
@@ -352,6 +352,9 @@ class GroupedAggregateResultSet extends 
 	 */
 	public ExecRow	getNextRowCore() throws StandardException 
 	{
+		if( isXplainOnlyMode() )
+			return null;
+
 		if (!isOpen)
 		{
 			return null;

Modified: db/derby/code/branches/10.10/java/engine/org/apache/derby/impl/sql/execute/HashScanResultSet.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.10/java/engine/org/apache/derby/impl/sql/execute/HashScanResultSet.java?rev=1573813&r1=1573812&r2=1573813&view=diff
==============================================================================
--- db/derby/code/branches/10.10/java/engine/org/apache/derby/impl/sql/execute/HashScanResultSet.java
(original)
+++ db/derby/code/branches/10.10/java/engine/org/apache/derby/impl/sql/execute/HashScanResultSet.java
Mon Mar  3 23:43:46 2014
@@ -362,6 +362,9 @@ public class HashScanResultSet extends S
 	 */
 	public ExecRow getNextRowCore() throws StandardException
 	{
+		if( isXplainOnlyMode() )
+			return null;
+
 	    ExecRow result = null;
 		DataValueDescriptor[] columns = null;
 

Modified: db/derby/code/branches/10.10/java/engine/org/apache/derby/impl/sql/execute/HashTableResultSet.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.10/java/engine/org/apache/derby/impl/sql/execute/HashTableResultSet.java?rev=1573813&r1=1573812&r2=1573813&view=diff
==============================================================================
--- db/derby/code/branches/10.10/java/engine/org/apache/derby/impl/sql/execute/HashTableResultSet.java
(original)
+++ db/derby/code/branches/10.10/java/engine/org/apache/derby/impl/sql/execute/HashTableResultSet.java
Mon Mar  3 23:43:46 2014
@@ -298,6 +298,9 @@ class HashTableResultSet extends NoPutRe
 	 * @return the next row in the result
 	 */
 	public ExecRow	getNextRowCore() throws StandardException {
+		if( isXplainOnlyMode() )
+			return null;
+
 	    ExecRow result = null;
 		DataValueDescriptor[] columns = null;
 

Modified: db/derby/code/branches/10.10/java/engine/org/apache/derby/impl/sql/execute/IndexRowToBaseRowResultSet.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.10/java/engine/org/apache/derby/impl/sql/execute/IndexRowToBaseRowResultSet.java?rev=1573813&r1=1573812&r2=1573813&view=diff
==============================================================================
--- db/derby/code/branches/10.10/java/engine/org/apache/derby/impl/sql/execute/IndexRowToBaseRowResultSet.java
(original)
+++ db/derby/code/branches/10.10/java/engine/org/apache/derby/impl/sql/execute/IndexRowToBaseRowResultSet.java
Mon Mar  3 23:43:46 2014
@@ -297,6 +297,8 @@ class IndexRowToBaseRowResultSet extends
 	 * @return the next row in the result
 	 */
 	public ExecRow	getNextRowCore() throws StandardException {
+		if( isXplainOnlyMode() )
+			return null;
 
 	    ExecRow sourceRow = null;
 		ExecRow retval = null;

Modified: db/derby/code/branches/10.10/java/engine/org/apache/derby/impl/sql/execute/LastIndexKeyResultSet.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.10/java/engine/org/apache/derby/impl/sql/execute/LastIndexKeyResultSet.java?rev=1573813&r1=1573812&r2=1573813&view=diff
==============================================================================
--- db/derby/code/branches/10.10/java/engine/org/apache/derby/impl/sql/execute/LastIndexKeyResultSet.java
(original)
+++ db/derby/code/branches/10.10/java/engine/org/apache/derby/impl/sql/execute/LastIndexKeyResultSet.java
Mon Mar  3 23:43:46 2014
@@ -203,6 +203,9 @@ class LastIndexKeyResultSet extends Scan
 	 */
 	public ExecRow getNextRowCore() throws StandardException
 	{
+		if( isXplainOnlyMode() )
+			return null;
+
 		if (returnedRow || !isOpen)
 		{
 		    clearCurrentRow();

Modified: db/derby/code/branches/10.10/java/engine/org/apache/derby/impl/sql/execute/MaterializedResultSet.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.10/java/engine/org/apache/derby/impl/sql/execute/MaterializedResultSet.java?rev=1573813&r1=1573812&r2=1573813&view=diff
==============================================================================
--- db/derby/code/branches/10.10/java/engine/org/apache/derby/impl/sql/execute/MaterializedResultSet.java
(original)
+++ db/derby/code/branches/10.10/java/engine/org/apache/derby/impl/sql/execute/MaterializedResultSet.java
Mon Mar  3 23:43:46 2014
@@ -176,6 +176,9 @@ class MaterializedResultSet extends NoPu
 	 */
 	public ExecRow	getNextRowCore() throws StandardException
 	{
+		if( isXplainOnlyMode() )
+			return null;
+
 		ExecRow result = null;
 
 		beginTime = getCurrentTimeMillis();

Modified: db/derby/code/branches/10.10/java/engine/org/apache/derby/impl/sql/execute/MergeJoinResultSet.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.10/java/engine/org/apache/derby/impl/sql/execute/MergeJoinResultSet.java?rev=1573813&r1=1573812&r2=1573813&view=diff
==============================================================================
--- db/derby/code/branches/10.10/java/engine/org/apache/derby/impl/sql/execute/MergeJoinResultSet.java
(original)
+++ db/derby/code/branches/10.10/java/engine/org/apache/derby/impl/sql/execute/MergeJoinResultSet.java
Mon Mar  3 23:43:46 2014
@@ -116,6 +116,9 @@ class MergeJoinResultSet extends JoinRes
 	 */
 	public ExecRow	getNextRowCore() throws StandardException
 	{
+		if( isXplainOnlyMode() )
+			return null;
+
 		beginTime = getCurrentTimeMillis();
 		if (! isOpen)
 			throw StandardException.newException(SQLState.LANG_RESULT_SET_NOT_OPEN, "next");

Modified: db/derby/code/branches/10.10/java/engine/org/apache/derby/impl/sql/execute/MultiProbeTableScanResultSet.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.10/java/engine/org/apache/derby/impl/sql/execute/MultiProbeTableScanResultSet.java?rev=1573813&r1=1573812&r2=1573813&view=diff
==============================================================================
--- db/derby/code/branches/10.10/java/engine/org/apache/derby/impl/sql/execute/MultiProbeTableScanResultSet.java
(original)
+++ db/derby/code/branches/10.10/java/engine/org/apache/derby/impl/sql/execute/MultiProbeTableScanResultSet.java
Mon Mar  3 23:43:46 2014
@@ -416,6 +416,9 @@ class MultiProbeTableScanResultSet exten
      */
     public ExecRow getNextRowCore() throws StandardException
     {
+		if( isXplainOnlyMode() )
+			return null;
+
         checkCancellationFlag();
 
         // Step 1.

Modified: db/derby/code/branches/10.10/java/engine/org/apache/derby/impl/sql/execute/NestedLoopJoinResultSet.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.10/java/engine/org/apache/derby/impl/sql/execute/NestedLoopJoinResultSet.java?rev=1573813&r1=1573812&r2=1573813&view=diff
==============================================================================
--- db/derby/code/branches/10.10/java/engine/org/apache/derby/impl/sql/execute/NestedLoopJoinResultSet.java
(original)
+++ db/derby/code/branches/10.10/java/engine/org/apache/derby/impl/sql/execute/NestedLoopJoinResultSet.java
Mon Mar  3 23:43:46 2014
@@ -74,6 +74,9 @@ class NestedLoopJoinResultSet extends Jo
 	 */
 	public ExecRow	getNextRowCore() throws StandardException
 	{
+		if( isXplainOnlyMode() )
+			return null;
+
 	    ExecRow result = null;
 		boolean haveRow = false;
 	    boolean restrict = false;

Modified: db/derby/code/branches/10.10/java/engine/org/apache/derby/impl/sql/execute/NestedLoopLeftOuterJoinResultSet.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.10/java/engine/org/apache/derby/impl/sql/execute/NestedLoopLeftOuterJoinResultSet.java?rev=1573813&r1=1573812&r2=1573813&view=diff
==============================================================================
--- db/derby/code/branches/10.10/java/engine/org/apache/derby/impl/sql/execute/NestedLoopLeftOuterJoinResultSet.java
(original)
+++ db/derby/code/branches/10.10/java/engine/org/apache/derby/impl/sql/execute/NestedLoopLeftOuterJoinResultSet.java
Mon Mar  3 23:43:46 2014
@@ -68,6 +68,9 @@ class NestedLoopLeftOuterJoinResultSet e
 	 */
 	public ExecRow	getNextRowCore() throws StandardException
 	{
+		if( isXplainOnlyMode() )
+			return null;
+
 	    ExecRow result = null;
 		boolean haveRow = false;
 	    boolean restrict = false;

Modified: db/derby/code/branches/10.10/java/engine/org/apache/derby/impl/sql/execute/NormalizeResultSet.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.10/java/engine/org/apache/derby/impl/sql/execute/NormalizeResultSet.java?rev=1573813&r1=1573812&r2=1573813&view=diff
==============================================================================
--- db/derby/code/branches/10.10/java/engine/org/apache/derby/impl/sql/execute/NormalizeResultSet.java
(original)
+++ db/derby/code/branches/10.10/java/engine/org/apache/derby/impl/sql/execute/NormalizeResultSet.java
Mon Mar  3 23:43:46 2014
@@ -175,6 +175,9 @@ class NormalizeResultSet extends NoPutRe
 	 */
 	public ExecRow	getNextRowCore() throws StandardException
 	{
+		if( isXplainOnlyMode() )
+			return null;
+
 		ExecRow		sourceRow = null;
 		ExecRow		result = null;
 

Modified: db/derby/code/branches/10.10/java/engine/org/apache/derby/impl/sql/execute/OnceResultSet.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.10/java/engine/org/apache/derby/impl/sql/execute/OnceResultSet.java?rev=1573813&r1=1573812&r2=1573813&view=diff
==============================================================================
--- db/derby/code/branches/10.10/java/engine/org/apache/derby/impl/sql/execute/OnceResultSet.java
(original)
+++ db/derby/code/branches/10.10/java/engine/org/apache/derby/impl/sql/execute/OnceResultSet.java
Mon Mar  3 23:43:46 2014
@@ -161,6 +161,9 @@ public class OnceResultSet extends NoPut
 	 */
 	public ExecRow	getNextRowCore() throws StandardException 
 	{
+		if( isXplainOnlyMode() )
+			return null;
+
 	    ExecRow candidateRow = null;
 		ExecRow secondRow = null;
 	    ExecRow result = null;

Modified: db/derby/code/branches/10.10/java/engine/org/apache/derby/impl/sql/execute/ProjectRestrictResultSet.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.10/java/engine/org/apache/derby/impl/sql/execute/ProjectRestrictResultSet.java?rev=1573813&r1=1573812&r2=1573813&view=diff
==============================================================================
--- db/derby/code/branches/10.10/java/engine/org/apache/derby/impl/sql/execute/ProjectRestrictResultSet.java
(original)
+++ db/derby/code/branches/10.10/java/engine/org/apache/derby/impl/sql/execute/ProjectRestrictResultSet.java
Mon Mar  3 23:43:46 2014
@@ -242,6 +242,8 @@ class ProjectRestrictResultSet extends N
 	 * @return the next row in the result
 	 */
 	public ExecRow	getNextRowCore() throws StandardException {
+		if( isXplainOnlyMode() )
+			return null;
 
 	    ExecRow candidateRow = null;
 	    ExecRow result = null;

Modified: db/derby/code/branches/10.10/java/engine/org/apache/derby/impl/sql/execute/RowCountResultSet.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.10/java/engine/org/apache/derby/impl/sql/execute/RowCountResultSet.java?rev=1573813&r1=1573812&r2=1573813&view=diff
==============================================================================
--- db/derby/code/branches/10.10/java/engine/org/apache/derby/impl/sql/execute/RowCountResultSet.java
(original)
+++ db/derby/code/branches/10.10/java/engine/org/apache/derby/impl/sql/execute/RowCountResultSet.java
Mon Mar  3 23:43:46 2014
@@ -180,6 +180,8 @@ class RowCountResultSet extends NoPutRes
      * @return the next row in the result
      */
     public ExecRow  getNextRowCore() throws StandardException {
+	if( isXplainOnlyMode() )
+		return null;
 
         ExecRow result = null;
 

Modified: db/derby/code/branches/10.10/java/engine/org/apache/derby/impl/sql/execute/RowResultSet.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.10/java/engine/org/apache/derby/impl/sql/execute/RowResultSet.java?rev=1573813&r1=1573812&r2=1573813&view=diff
==============================================================================
--- db/derby/code/branches/10.10/java/engine/org/apache/derby/impl/sql/execute/RowResultSet.java
(original)
+++ db/derby/code/branches/10.10/java/engine/org/apache/derby/impl/sql/execute/RowResultSet.java
Mon Mar  3 23:43:46 2014
@@ -131,6 +131,8 @@ class RowResultSet extends NoPutResultSe
 	 * @exception StandardException thrown on failure.
      */
 	public ExecRow	getNextRowCore() throws StandardException {
+		if( isXplainOnlyMode() )
+			return null;
 
 		currentRow = null;
 		beginTime = getCurrentTimeMillis();

Modified: db/derby/code/branches/10.10/java/engine/org/apache/derby/impl/sql/execute/ScalarAggregateResultSet.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.10/java/engine/org/apache/derby/impl/sql/execute/ScalarAggregateResultSet.java?rev=1573813&r1=1573812&r2=1573813&view=diff
==============================================================================
--- db/derby/code/branches/10.10/java/engine/org/apache/derby/impl/sql/execute/ScalarAggregateResultSet.java
(original)
+++ db/derby/code/branches/10.10/java/engine/org/apache/derby/impl/sql/execute/ScalarAggregateResultSet.java
Mon Mar  3 23:43:46 2014
@@ -152,6 +152,9 @@ class ScalarAggregateResultSet extends G
 	 */
 	public ExecRow	getNextRowCore() throws StandardException 
 	{
+		if( isXplainOnlyMode() )
+			return null;
+
 		if (nextSatisfied)
 		{
 			clearCurrentRow();

Modified: db/derby/code/branches/10.10/java/engine/org/apache/derby/impl/sql/execute/ScrollInsensitiveResultSet.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.10/java/engine/org/apache/derby/impl/sql/execute/ScrollInsensitiveResultSet.java?rev=1573813&r1=1573812&r2=1573813&view=diff
==============================================================================
--- db/derby/code/branches/10.10/java/engine/org/apache/derby/impl/sql/execute/ScrollInsensitiveResultSet.java
(original)
+++ db/derby/code/branches/10.10/java/engine/org/apache/derby/impl/sql/execute/ScrollInsensitiveResultSet.java
Mon Mar  3 23:43:46 2014
@@ -499,6 +499,9 @@ public class ScrollInsensitiveResultSet 
 	 */
 	public ExecRow	getNextRowCore() throws StandardException
 	{
+		if( isXplainOnlyMode() )
+			return null;
+
 		ExecRow result = null;
 
 		beginTime = getCurrentTimeMillis();

Modified: db/derby/code/branches/10.10/java/engine/org/apache/derby/impl/sql/execute/SetOpResultSet.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.10/java/engine/org/apache/derby/impl/sql/execute/SetOpResultSet.java?rev=1573813&r1=1573812&r2=1573813&view=diff
==============================================================================
--- db/derby/code/branches/10.10/java/engine/org/apache/derby/impl/sql/execute/SetOpResultSet.java
(original)
+++ db/derby/code/branches/10.10/java/engine/org/apache/derby/impl/sql/execute/SetOpResultSet.java
Mon Mar  3 23:43:46 2014
@@ -135,6 +135,9 @@ class SetOpResultSet extends NoPutResult
 	 */
 	public ExecRow	getNextRowCore() throws StandardException
     {
+		if( isXplainOnlyMode() )
+			return null;
+
 		beginTime = getCurrentTimeMillis();
 	    if ( isOpen )
         {

Modified: db/derby/code/branches/10.10/java/engine/org/apache/derby/impl/sql/execute/SortResultSet.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.10/java/engine/org/apache/derby/impl/sql/execute/SortResultSet.java?rev=1573813&r1=1573812&r2=1573813&view=diff
==============================================================================
--- db/derby/code/branches/10.10/java/engine/org/apache/derby/impl/sql/execute/SortResultSet.java
(original)
+++ db/derby/code/branches/10.10/java/engine/org/apache/derby/impl/sql/execute/SortResultSet.java
Mon Mar  3 23:43:46 2014
@@ -332,6 +332,9 @@ class SortResultSet extends NoPutResultS
 	 */
 	public ExecRow	getNextRowCore() throws StandardException 
 	{
+		if( isXplainOnlyMode() )
+			return null;
+
 		if (!isOpen)
 		{
 			return null;

Modified: db/derby/code/branches/10.10/java/engine/org/apache/derby/impl/sql/execute/TableScanResultSet.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.10/java/engine/org/apache/derby/impl/sql/execute/TableScanResultSet.java?rev=1573813&r1=1573812&r2=1573813&view=diff
==============================================================================
--- db/derby/code/branches/10.10/java/engine/org/apache/derby/impl/sql/execute/TableScanResultSet.java
(original)
+++ db/derby/code/branches/10.10/java/engine/org/apache/derby/impl/sql/execute/TableScanResultSet.java
Mon Mar  3 23:43:46 2014
@@ -455,6 +455,9 @@ class TableScanResultSet extends ScanRes
 	 */
 	public ExecRow getNextRowCore() throws StandardException
 	{
+		if( isXplainOnlyMode() )
+			return null;
+
         checkCancellationFlag();
             
 		if (currentRow == null || scanRepositioned)

Modified: db/derby/code/branches/10.10/java/engine/org/apache/derby/impl/sql/execute/UnionResultSet.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.10/java/engine/org/apache/derby/impl/sql/execute/UnionResultSet.java?rev=1573813&r1=1573812&r2=1573813&view=diff
==============================================================================
--- db/derby/code/branches/10.10/java/engine/org/apache/derby/impl/sql/execute/UnionResultSet.java
(original)
+++ db/derby/code/branches/10.10/java/engine/org/apache/derby/impl/sql/execute/UnionResultSet.java
Mon Mar  3 23:43:46 2014
@@ -115,6 +115,9 @@ class UnionResultSet extends NoPutResult
  	 *	@exception StandardException thrown on failure
 	 */
 	public ExecRow	getNextRowCore() throws StandardException {
+		if( isXplainOnlyMode() )
+			return null;
+
 	    ExecRow result = null;
 
 		beginTime = getCurrentTimeMillis();

Modified: db/derby/code/branches/10.10/java/engine/org/apache/derby/impl/sql/execute/VTIResultSet.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.10/java/engine/org/apache/derby/impl/sql/execute/VTIResultSet.java?rev=1573813&r1=1573812&r2=1573813&view=diff
==============================================================================
--- db/derby/code/branches/10.10/java/engine/org/apache/derby/impl/sql/execute/VTIResultSet.java
(original)
+++ db/derby/code/branches/10.10/java/engine/org/apache/derby/impl/sql/execute/VTIResultSet.java
Mon Mar  3 23:43:46 2014
@@ -394,6 +394,9 @@ class VTIResultSet extends NoPutResultSe
      */
 	public ExecRow	getNextRowCore() throws StandardException 
 	{
+		if( isXplainOnlyMode() )
+			return null;
+
 	    ExecRow result = null;
 
 		beginTime = getCurrentTimeMillis();

Modified: db/derby/code/branches/10.10/java/engine/org/apache/derby/impl/sql/execute/WindowResultSet.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.10/java/engine/org/apache/derby/impl/sql/execute/WindowResultSet.java?rev=1573813&r1=1573812&r2=1573813&view=diff
==============================================================================
--- db/derby/code/branches/10.10/java/engine/org/apache/derby/impl/sql/execute/WindowResultSet.java
(original)
+++ db/derby/code/branches/10.10/java/engine/org/apache/derby/impl/sql/execute/WindowResultSet.java
Mon Mar  3 23:43:46 2014
@@ -175,6 +175,9 @@ class WindowResultSet extends NoPutResul
      */
     public ExecRow getNextRowCore() throws StandardException
     {
+		if( isXplainOnlyMode() )
+			return null;
+
         ExecRow sourceRow = null;
         ExecRow retval = null;
         boolean restrict = false;

Modified: db/derby/code/branches/10.10/java/testing/org/apache/derbyTesting/functionTests/tests/lang/LangScripts.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.10/java/testing/org/apache/derbyTesting/functionTests/tests/lang/LangScripts.java?rev=1573813&r1=1573812&r2=1573813&view=diff
==============================================================================
--- db/derby/code/branches/10.10/java/testing/org/apache/derbyTesting/functionTests/tests/lang/LangScripts.java
(original)
+++ db/derby/code/branches/10.10/java/testing/org/apache/derbyTesting/functionTests/tests/lang/LangScripts.java
Mon Mar  3 23:43:46 2014
@@ -92,6 +92,7 @@ public final class LangScripts extends S
         "union",
         "update",
         "valuesclause",
+        "xplain",
         };
     
     /**

Modified: db/derby/code/branches/10.10/java/testing/org/apache/derbyTesting/functionTests/tests/lang/XplainStatisticsTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.10/java/testing/org/apache/derbyTesting/functionTests/tests/lang/XplainStatisticsTest.java?rev=1573813&r1=1573812&r2=1573813&view=diff
==============================================================================
--- db/derby/code/branches/10.10/java/testing/org/apache/derbyTesting/functionTests/tests/lang/XplainStatisticsTest.java
(original)
+++ db/derby/code/branches/10.10/java/testing/org/apache/derbyTesting/functionTests/tests/lang/XplainStatisticsTest.java
Mon Mar  3 23:43:46 2014
@@ -71,7 +71,7 @@ import org.w3c.dom.NodeList;
  *
  * FIXME -- some general to-do items that I don't want to forget:
  * - should resultSetNumber be its own column in sysxplain_resultsets?
- * - need tests of xplain-only mode
+ * - need MORE tests of xplain-only mode
  * - need a test of external sorting/merging
  * - need to cross-check the result set types, and verify that they're
  *   all tested at least once
@@ -520,6 +520,18 @@ public class XplainStatisticsTest extend
         s.execute("call syscs_util.syscs_set_statistics_timing(1)");
     }
     
+    private static void enableXplainOnlyMode(Statement s)
+            throws SQLException
+    {
+        s.execute("call syscs_util.syscs_set_xplain_mode(1)");
+    }
+    
+    private static void clearXplainOnlyMode(Statement s)
+            throws SQLException
+    {
+        s.execute("call syscs_util.syscs_set_xplain_mode(0)");
+    }
+    
     /**
      * 
      * @param s
@@ -559,6 +571,7 @@ public class XplainStatisticsTest extend
     					null);
     		}
     	} 
+        s.execute("call syscs_util.syscs_set_xplain_schema('')");
     }
 
     private static void verifyXplainUnset(Statement s)
@@ -624,6 +637,32 @@ public class XplainStatisticsTest extend
         rs.close();
     }
     
+    private void dumpStatements(Statement s)
+        throws SQLException
+    {
+        ResultSet rs;
+        rs = s.executeQuery("select * from xpltest.sysxplain_statements");
+        while (rs.next())
+        {
+            System.out.println(
+                    rs.getString("stmt_id")+","+
+                    rs.getString("stmt_name")+","+
+                    rs.getString("stmt_type")+","+
+                    rs.getString("stmt_text")+","+
+                    rs.getString("jvm_id")+","+
+                    rs.getString("os_identifier")+","+
+                    rs.getString("xplain_mode")+","+
+                    rs.getString("xplain_time")+","+
+                    rs.getString("xplain_thread_id")+","+
+                    rs.getString("transaction_id")+","+
+                    rs.getString("session_id")+","+
+                    rs.getString("database_name")+","+
+                    rs.getString("drda_id")+","+
+                    rs.getString("timing_id"));
+        }
+        rs.close();
+    }
+    
     /**
      * Added by DERBY-4587
      * Returns the stmt_id for this particular statement
@@ -1045,6 +1084,300 @@ public class XplainStatisticsTest extend
         }
     }
     
+    private String getStmtIDByName(Statement s, String sName)
+			throws SQLException
+    {
+    	ResultSet rs;
+        String stmt_id = "?";
+        rs = s.executeQuery( 
+    		"select stmt_id from XPLTEST.sysxplain_statements "+
+		"where stmt_name='"+sName+"'"); 
+        if( rs.next() )
+	{
+            stmt_id = rs.getString(1); 
+	    //System.out.println("Found statemnt id " + stmt_id);
+	}
+        rs.close();
+        return stmt_id;
+    }
+    public void testSimpleXplainOnly() throws Exception
+    {
+        Statement s = createStatement();
+
+        enableXplainStyle(s);
+        enableXplainOnlyMode(s);
+	s.setCursorName("1");
+        JDBC.assertEmpty(s.executeQuery(
+        	"SELECT country from countries "+
+	         "WHERE region = 'Central America'" ));
+        clearXplainOnlyMode(s);
+        disableXplainStyle(s);
+
+	// dumpStatements(s);
+        // dumpResultSets(s);
+	// There should be 1 statement captured with stmt_id='1'.
+	// It should have a PROJECTION and a TABLESCAN; the TABLESCAN should be
+	// on the COUNTRIES table.
+        JDBC.assertSingleValueResultSet(s.executeQuery(
+            "select count(*) from xpltest.sysxplain_statements"), "1");
+        JDBC.assertSingleValueResultSet(s.executeQuery(
+            "select count(*) from xpltest.sysxplain_statements "+
+	    "where stmt_name='1'"), "1");
+	String stmt_id = getStmtIDByName( s, "1" );
+        JDBC.assertSingleValueResultSet(s.executeQuery(
+            "select count(*) from xpltest.sysxplain_resultsets "+
+	    "where stmt_id='"+stmt_id+"'"), "2");
+        JDBC.assertSingleValueResultSet(s.executeQuery(
+            "select count(*) from xpltest.sysxplain_resultsets "+
+	    "where stmt_id='"+stmt_id+"' and op_identifier='PROJECTION'"), "1");
+        JDBC.assertSingleValueResultSet(s.executeQuery(
+            "select count(*) from xpltest.sysxplain_resultsets "+
+	    "where stmt_id='"+stmt_id+"' and op_identifier='TABLESCAN'"), "1");
+        JDBC.assertSingleValueResultSet(s.executeQuery(
+            "select op_details from xpltest.sysxplain_resultsets "+
+	    "where stmt_id='"+stmt_id+"' and op_identifier='TABLESCAN'"),
+	    "T: COUNTRIES");
+
+        enableXplainStyle(s);
+        enableXplainOnlyMode(s);
+	s.setCursorName("2");
+        JDBC.assertEmpty(s.executeQuery(
+            "select sql_text from syscs_diag.transaction_table " +
+	    "where status != 'IDLE'" ));
+        clearXplainOnlyMode(s);
+        disableXplainStyle(s);
+
+	//dumpStatements(s);
+        //dumpResultSets(s);
+
+	// This statement should have three result sets:
+	// - PROJECTION (select sql_text)
+	// - PROJECT-FILTER (where status != IDLE)
+	// - VTI (syscs_diag.transaction_table)
+	//
+        JDBC.assertSingleValueResultSet(s.executeQuery(
+            "select count(*) from xpltest.sysxplain_statements"), "1");
+        JDBC.assertSingleValueResultSet(s.executeQuery(
+            "select count(*) from xpltest.sysxplain_statements "+
+	    "where stmt_name='2'"), "1");
+	stmt_id = getStmtIDByName( s, "2" );
+        JDBC.assertSingleValueResultSet(s.executeQuery(
+            "select count(*) from xpltest.sysxplain_resultsets "+
+	    "where stmt_id='"+stmt_id+"' and op_identifier='PROJECTION'"), "1");
+        JDBC.assertSingleValueResultSet(s.executeQuery(
+            "select count(*) from xpltest.sysxplain_resultsets "+
+	    "where stmt_id='"+stmt_id+"' and "+
+	    "      op_identifier='PROJECT-FILTER'"), "1");
+        JDBC.assertSingleValueResultSet(s.executeQuery(
+            "select count(*) from xpltest.sysxplain_resultsets "+
+	    "where stmt_id='"+stmt_id+"' and op_identifier='VTI'"), "1");
+
+        String selectStatement = 
+            "select region, count(country) from app.countries group by region";
+        enableXplainStyle(s);
+        enableXplainOnlyMode(s);
+	s.setCursorName("3");
+        JDBC.assertEmpty(s.executeQuery(selectStatement));
+
+        clearXplainOnlyMode(s);
+        disableXplainStyle(s);
+	//dumpStatements(s);
+        //dumpResultSets(s);
+
+        // This statement is executed as a PROJECTION with a child GROUPBY
+        // with a child PROJECTION with a child TABLESCAN. The TABLESCAN
+        // has a corresponding SCAN_PROPS row, the GROUPBY has a
+        // corresponding SORT_PROPS row. But since we're XPLAIN-ONLY, none
+	// of the actual processing did anything.
+        //
+        JDBC.assertSingleValueResultSet(s.executeQuery(
+            "select count(*) from xpltest.sysxplain_resultsets"), "4");
+        JDBC.assertFullResultSet(s.executeQuery(
+                    "select op_identifier from xpltest.sysxplain_resultsets " +
+                    "order by op_identifier"),
+            new String[][] {
+                {"GROUPBY"},{"PROJECTION"},{"PROJECTION"},{"TABLESCAN"} } );
+        JDBC.assertSingleValueResultSet(s.executeQuery(
+            "select count(*) from xpltest.sysxplain_resultsets " +
+            "where scan_rs_id is not null"), "1");
+        JDBC.assertSingleValueResultSet(s.executeQuery(
+            "select count(*) from xpltest.sysxplain_resultsets " +
+            "where sort_rs_id is not null"), "1");
+        JDBC.assertFullResultSet(s.executeQuery(
+                    "select s.stmt_text, rs.op_identifier," +
+                    " srt.no_input_rows, srt.no_output_rows " +
+                    " from xpltest.sysxplain_sort_props srt, " +
+                    " xpltest.sysxplain_resultsets rs, " +
+                    " xpltest.sysxplain_statements s " +
+                    " where rs.stmt_id = s.stmt_id and " +
+                    " rs.sort_rs_id = srt.sort_rs_id"),
+            new String[][] {
+                {selectStatement, "GROUPBY", "0", "0"} } );
+
+        JDBC.assertUnorderedResultSet(s.executeQuery(
+                    "select srt.sort_type, srt.no_input_rows, " +
+                    " srt.no_output_rows, srt.no_merge_runs, " +
+                    " srt.merge_run_details, srt.eliminate_duplicates, " +
+                    " srt.in_sort_order, srt.distinct_aggregate " +
+                    "from xpltest.sysxplain_sort_props srt " +
+                    "join xpltest.sysxplain_resultsets rs " +
+                    "on srt.sort_rs_id = rs.sort_rs_id " +
+                    "where rs.op_identifier='GROUPBY'"),
+                new String[][] {
+                    {"IN","0","0",null, null, null,"N","N"} } );
+    }
+
+    public void testXplainOnlyExecutePrepared() throws Exception
+    {
+        Statement s = createStatement();
+
+        String selectStatement = 
+            "select region, count(country) from app.countries group by region";
+        PreparedStatement ps = prepareStatement( selectStatement );
+        enableXplainStyle(s);
+        enableXplainOnlyMode(s);
+        JDBC.assertEmpty(ps.executeQuery());
+        clearXplainOnlyMode(s);
+        disableXplainStyle(s);
+	//dumpStatements(s);
+        //dumpResultSets(s);
+
+        // This statement is executed as a PROJECTION with a child GROUPBY
+        // with a child PROJECTION with a child TABLESCAN. The TABLESCAN
+        // has a corresponding SCAN_PROPS row, the GROUPBY has a
+        // corresponding SORT_PROPS row. But since we're XPLAIN-ONLY, none
+	// of the actual processing did anything.
+        //
+        JDBC.assertSingleValueResultSet(s.executeQuery(
+            "select count(*) from xpltest.sysxplain_resultsets"), "4");
+        JDBC.assertFullResultSet(s.executeQuery(
+                    "select op_identifier from xpltest.sysxplain_resultsets " +
+                    "order by op_identifier"),
+            new String[][] {
+                {"GROUPBY"},{"PROJECTION"},{"PROJECTION"},{"TABLESCAN"} } );
+        JDBC.assertSingleValueResultSet(s.executeQuery(
+            "select count(*) from xpltest.sysxplain_resultsets " +
+            "where scan_rs_id is not null"), "1");
+        JDBC.assertSingleValueResultSet(s.executeQuery(
+            "select count(*) from xpltest.sysxplain_resultsets " +
+            "where sort_rs_id is not null"), "1");
+        JDBC.assertFullResultSet(s.executeQuery(
+                    "select s.stmt_text, rs.op_identifier," +
+                    " srt.no_input_rows, srt.no_output_rows " +
+                    " from xpltest.sysxplain_sort_props srt, " +
+                    " xpltest.sysxplain_resultsets rs, " +
+                    " xpltest.sysxplain_statements s " +
+                    " where rs.stmt_id = s.stmt_id and " +
+                    " rs.sort_rs_id = srt.sort_rs_id"),
+            new String[][] {
+                {selectStatement, "GROUPBY", "0", "0"} } );
+
+        JDBC.assertUnorderedResultSet(s.executeQuery(
+                    "select srt.sort_type, srt.no_input_rows, " +
+                    " srt.no_output_rows, srt.no_merge_runs, " +
+                    " srt.merge_run_details, srt.eliminate_duplicates, " +
+                    " srt.in_sort_order, srt.distinct_aggregate " +
+                    "from xpltest.sysxplain_sort_props srt " +
+                    "join xpltest.sysxplain_resultsets rs " +
+                    "on srt.sort_rs_id = rs.sort_rs_id " +
+                    "where rs.op_identifier='GROUPBY'"),
+                new String[][] {
+                    {"IN","0","0",null, null, null,"N","N"} } );
+
+	
+	// Since now we're not in XplainOnly mode, the prepared statement
+	// returns the expected normal result set.
+
+        JDBC.assertUnorderedResultSet(ps.executeQuery(),
+            new String[][] { 
+                {"Africa", "19"}, {"Asia", "15"},
+                {"Australia and New Zealand", "2"}, {"Caribbean", "10"},
+                {"Central America", "6"}, {"Central Asia", "4"},
+                {"Europe", "29"}, {"Middle East", "7"},
+                {"North Africa", "5"}, {"North America", "3"},
+                {"Pacific Islands", "3"}, {"South America", "11"} } );
+
+	// And then back to empty again:
+        enableXplainStyle(s);
+        enableXplainOnlyMode(s);
+        JDBC.assertEmpty(ps.executeQuery());
+        clearXplainOnlyMode(s);
+        disableXplainStyle(s);
+        
+        // Verify that statistics were collected.
+        JDBC.assertDrainResults(
+                s.executeQuery("select * from xpltest.sysxplain_statements"),
+                1);
+    }
+    
+    public void testXplainOnlyPrepared() throws Exception
+    {
+        Statement s = createStatement();
+
+        String selectStatement = 
+            "select region, count(country) from app.countries group by region";
+
+        // Try preparing the statement while we're in xplain-only mode, then
+        // execute it normally.
+
+        enableXplainStyle(s);
+        enableXplainOnlyMode(s);
+        PreparedStatement ps2 = prepareStatement( selectStatement );
+        clearXplainOnlyMode(s);
+        JDBC.assertUnorderedResultSet(ps2.executeQuery(),
+            new String[][] { 
+                {"Africa", "19"}, {"Asia", "15"},
+                {"Australia and New Zealand", "2"}, {"Caribbean", "10"},
+                {"Central America", "6"}, {"Central Asia", "4"},
+                {"Europe", "29"}, {"Middle East", "7"},
+                {"North Africa", "5"}, {"North America", "3"},
+                {"Pacific Islands", "3"}, {"South America", "11"} } );
+        disableXplainStyle(s);
+	//dumpStatements(s);
+        //dumpResultSets(s);
+
+        // This statement is executed as a PROJECTION with a child GROUPBY
+        // with a child PROJECTION with a child TABLESCAN. The TABLESCAN
+        // has a corresponding SCAN_PROPS row, the GROUPBY has a
+        // corresponding SORT_PROPS row. But since we're XPLAIN-ONLY, none
+	// of the actual processing did anything.
+        //
+        JDBC.assertSingleValueResultSet(s.executeQuery(
+            "select count(*) from xpltest.sysxplain_resultsets"), "4");
+        JDBC.assertFullResultSet(s.executeQuery(
+                    "select op_identifier from xpltest.sysxplain_resultsets " +
+                    "order by op_identifier"),
+            new String[][] {
+                {"GROUPBY"},{"PROJECTION"},{"PROJECTION"},{"TABLESCAN"} } );
+        JDBC.assertSingleValueResultSet(s.executeQuery(
+            "select count(*) from xpltest.sysxplain_resultsets " +
+            "where scan_rs_id is not null"), "1");
+        JDBC.assertSingleValueResultSet(s.executeQuery(
+            "select count(*) from xpltest.sysxplain_resultsets " +
+            "where sort_rs_id is not null"), "1");
+        JDBC.assertFullResultSet(s.executeQuery(
+                    "select s.stmt_text, rs.op_identifier," +
+                    " srt.no_input_rows, srt.no_output_rows " +
+                    " from xpltest.sysxplain_sort_props srt, " +
+                    " xpltest.sysxplain_resultsets rs, " +
+                    " xpltest.sysxplain_statements s " +
+                    " where rs.stmt_id = s.stmt_id and " +
+                    " rs.sort_rs_id = srt.sort_rs_id"),
+            new String[][] {
+                {selectStatement, "GROUPBY", "114", "12"} } );
+
+        JDBC.assertUnorderedResultSet(s.executeQuery(
+                    "select srt.sort_type, srt.no_input_rows, " +
+                    " srt.no_output_rows, srt.no_merge_runs, " +
+                    " srt.merge_run_details, srt.eliminate_duplicates, " +
+                    " srt.in_sort_order, srt.distinct_aggregate " +
+                    "from xpltest.sysxplain_sort_props srt " +
+                    "join xpltest.sysxplain_resultsets rs " +
+                    "on srt.sort_rs_id = rs.sort_rs_id " +
+                    "where rs.op_identifier='GROUPBY'"),
+                new String[][] {
+                    {"IN","114","12",null, null, null,"N","N"} } );
+    }
     
     
     /**



Mime
View raw message