Author: shawkins
Date: 2010-04-07 11:52:07 -0400 (Wed, 07 Apr 2010)
New Revision: 2033
Added:
trunk/test-integration/common/src/test/java/org/teiid/jdbc/TestQueryPlans.java
Modified:
trunk/client/src/main/java/org/teiid/jdbc/BaseDataSource.java
trunk/client/src/main/java/org/teiid/jdbc/JDBCURL.java
trunk/client/src/main/java/org/teiid/jdbc/ResultSetImpl.java
trunk/client/src/main/java/org/teiid/jdbc/StatementImpl.java
trunk/engine/src/main/java/com/metamatrix/query/analysis/AnalysisRecord.java
trunk/engine/src/main/java/org/teiid/dqp/internal/process/Request.java
trunk/engine/src/main/java/org/teiid/dqp/internal/process/RequestWorkItem.java
Log:
TEIID-908 TEIID-1040 refining the plannode logic and moving option debug, showplan, and
planonly to be set commands
Modified: trunk/client/src/main/java/org/teiid/jdbc/BaseDataSource.java
===================================================================
--- trunk/client/src/main/java/org/teiid/jdbc/BaseDataSource.java 2010-04-07 14:57:01 UTC
(rev 2032)
+++ trunk/client/src/main/java/org/teiid/jdbc/BaseDataSource.java 2010-04-07 15:52:07 UTC
(rev 2033)
@@ -153,7 +153,7 @@
// Default execution property constants
protected static final int DEFAULT_FETCH_SIZE = RequestMessage.DEFAULT_FETCH_SIZE;
protected static final String DEFAULT_PARTIAL_RESULTS_MODE = "FALSE";
//$NON-NLS-1$
- protected static final String DEFAULT_RESULT_SET_CACHE_MODE = "TRUE";
//$NON-NLS-1$
+ protected static final String DEFAULT_RESULT_SET_CACHE_MODE = "FALSE";
//$NON-NLS-1$
/**
* Transaction auto wrap constant - never wrap a command execution in a transaction
Modified: trunk/client/src/main/java/org/teiid/jdbc/JDBCURL.java
===================================================================
--- trunk/client/src/main/java/org/teiid/jdbc/JDBCURL.java 2010-04-07 14:57:01 UTC (rev
2032)
+++ trunk/client/src/main/java/org/teiid/jdbc/JDBCURL.java 2010-04-07 15:52:07 UTC (rev
2033)
@@ -284,7 +284,7 @@
}
}
- private static void addNormalizedProperty(String key, Object value, Properties
target) {
+ public static void addNormalizedProperty(String key, Object value, Properties target)
{
String validKey = getValidKey(key);
// now add the normalized key and value into the properties object.
Modified: trunk/client/src/main/java/org/teiid/jdbc/ResultSetImpl.java
===================================================================
--- trunk/client/src/main/java/org/teiid/jdbc/ResultSetImpl.java 2010-04-07 14:57:01 UTC
(rev 2032)
+++ trunk/client/src/main/java/org/teiid/jdbc/ResultSetImpl.java 2010-04-07 15:52:07 UTC
(rev 2033)
@@ -371,7 +371,6 @@
}
ResultsMessage currentResultMsg = results.get(timeoutSeconds,
TimeUnit.SECONDS);
this.accumulateWarnings(currentResultMsg);
- this.updatedPlanDescription = currentResultMsg.getPlanDescription();
return getCurrentBatch(currentResultMsg);
} catch (MetaMatrixProcessingException e) {
throw TeiidSQLException.create(e);
@@ -385,6 +384,7 @@
}
private Batch getCurrentBatch(ResultsMessage currentResultMsg) {
+ this.updatedPlanDescription = currentResultMsg.getPlanDescription();
boolean isLast = currentResultMsg.getResults().length == 0 ||
currentResultMsg.getFinalRow() == currentResultMsg.getLastRow();
return new Batch(currentResultMsg.getResults(), currentResultMsg.getFirstRow(),
currentResultMsg.getLastRow(), isLast);
}
Modified: trunk/client/src/main/java/org/teiid/jdbc/StatementImpl.java
===================================================================
--- trunk/client/src/main/java/org/teiid/jdbc/StatementImpl.java 2010-04-07 14:57:01 UTC
(rev 2032)
+++ trunk/client/src/main/java/org/teiid/jdbc/StatementImpl.java 2010-04-07 15:52:07 UTC
(rev 2033)
@@ -402,7 +402,7 @@
if (match.matches()) {
String key = match.group(1);
String value = match.group(2);
- this.driverConnection.getConnectionProperties().setProperty(key, value);
+ JDBCURL.addNormalizedProperty(key, value,
this.driverConnection.getConnectionProperties());
this.updateCounts = new int[] {0};
return;
}
@@ -745,7 +745,7 @@
String showPlan = getExecutionProperty(ExecutionProperties.SQL_OPTION_SHOWPLAN);
if (showPlan != null) {
try {
- res.setShowPlan(ShowPlan.valueOf(showPlan));
+ res.setShowPlan(ShowPlan.valueOf(showPlan.toUpperCase()));
} catch (IllegalArgumentException e) {
}
@@ -887,14 +887,6 @@
this.styleSheet = null;
}
- void setPlanDescription(PlanNode planDescription) {
- this.currentPlanDescription = planDescription;
- }
-
- void setDebugLog(String debugLog) {
- this.debugLog = debugLog;
- }
-
/**
* Get Query plan description.
* If the Statement has a resultSet, we get the plan description from the result set
@@ -905,7 +897,6 @@
* @return Query plan description, if it exists, otherwise null
*/
public PlanNode getPlanDescription() {
- Map planDescription = null;
if(this.resultSet != null) {
return this.resultSet.getUpdatedPlanDescription();
}
Modified: trunk/engine/src/main/java/com/metamatrix/query/analysis/AnalysisRecord.java
===================================================================
---
trunk/engine/src/main/java/com/metamatrix/query/analysis/AnalysisRecord.java 2010-04-07
14:57:01 UTC (rev 2032)
+++
trunk/engine/src/main/java/com/metamatrix/query/analysis/AnalysisRecord.java 2010-04-07
15:52:07 UTC (rev 2033)
@@ -105,7 +105,6 @@
// Flags regarding what should be recorded
private boolean recordQueryPlan;
private boolean recordDebug;
- private boolean logDebug;
// Query plan
private PlanNode queryPlan;
@@ -118,8 +117,7 @@
private PrintWriter debugWriter; // public
public AnalysisRecord(boolean recordQueryPlan, boolean recordDebug) {
- this.recordQueryPlan = recordQueryPlan |
LogManager.isMessageToBeRecorded(LogConstants.CTX_QUERY_PLANNER, MessageLevel.DETAIL);
- this.logDebug = recordDebug;
+ this.recordQueryPlan = recordQueryPlan |
LogManager.isMessageToBeRecorded(LogConstants.CTX_QUERY_PLANNER, MessageLevel.DETAIL);
this.recordDebug = recordDebug |
LogManager.isMessageToBeRecorded(LogConstants.CTX_QUERY_PLANNER, MessageLevel.TRACE);
if(this.recordQueryPlan) {
@@ -132,10 +130,6 @@
}
}
- public boolean logDebug() {
- return logDebug;
- }
-
public static AnalysisRecord createNonRecordingRecord() {
return new AnalysisRecord(false, false);
}
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/process/Request.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/process/Request.java 2010-04-07
14:57:01 UTC (rev 2032)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/Request.java 2010-04-07
15:52:07 UTC (rev 2033)
@@ -437,7 +437,7 @@
} finally {
String debugLog = analysisRecord.getDebugLog();
if(debugLog != null && debugLog.length() > 0) {
-
LogManager.log(analysisRecord.logDebug()?MessageLevel.INFO:MessageLevel.TRACE,
LogConstants.CTX_QUERY_PLANNER, debugLog);
+
LogManager.log(requestMsg.getShowPlan()==ShowPlan.DEBUG?MessageLevel.INFO:MessageLevel.TRACE,
LogConstants.CTX_QUERY_PLANNER, debugLog);
}
if (analysisRecord.recordAnnotations() &&
analysisRecord.getAnnotations() != null &&
!analysisRecord.getAnnotations().isEmpty()) {
LogManager.logDetail(LogConstants.CTX_QUERY_PLANNER,
analysisRecord.getAnnotations());
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/process/RequestWorkItem.java
===================================================================
---
trunk/engine/src/main/java/org/teiid/dqp/internal/process/RequestWorkItem.java 2010-04-07
14:57:01 UTC (rev 2032)
+++
trunk/engine/src/main/java/org/teiid/dqp/internal/process/RequestWorkItem.java 2010-04-07
15:52:07 UTC (rev 2033)
@@ -33,6 +33,7 @@
import org.teiid.client.RequestMessage;
import org.teiid.client.ResultsMessage;
import org.teiid.client.SourceWarning;
+import org.teiid.client.RequestMessage.ShowPlan;
import org.teiid.client.lob.LobChunk;
import org.teiid.client.metadata.ParameterInfo;
import org.teiid.client.util.ResultsReceiver;
@@ -489,15 +490,19 @@
}
ResultsMessage result = new ResultsMessage(message, batch, columnNames,
dataTypes);
- setAnalysisRecords(result, analysisRecord);
+ setAnalysisRecords(message, result, analysisRecord);
return result;
}
- private static void setAnalysisRecords(ResultsMessage response, AnalysisRecord
analysisRecord) {
+ private static void setAnalysisRecords(RequestMessage requestMsg, ResultsMessage
response, AnalysisRecord analysisRecord) {
if(analysisRecord != null) {
- response.setPlanDescription(analysisRecord.getQueryPlan());
- response.setDebugLog(analysisRecord.getDebugLog());
- response.setAnnotations(analysisRecord.getAnnotations());
+ if (requestMsg.getShowPlan() != ShowPlan.OFF) {
+ response.setPlanDescription(analysisRecord.getQueryPlan());
+ response.setAnnotations(analysisRecord.getAnnotations());
+ }
+ if (requestMsg.getShowPlan() == ShowPlan.DEBUG) {
+ response.setDebugLog(analysisRecord.getDebugLog());
+ }
}
}
@@ -511,7 +516,7 @@
LogManager.logDetail(LogConstants.CTX_DQP, processingException, "Sending error to
client", requestID); //$NON-NLS-1$
ResultsMessage response = new ResultsMessage(requestMsg);
response.setException(processingException);
- setAnalysisRecords(response, analysisRecord);
+ setAnalysisRecords(this.requestMsg, response, analysisRecord);
resultsReceiver.receiveResults(response);
}
Added: trunk/test-integration/common/src/test/java/org/teiid/jdbc/TestQueryPlans.java
===================================================================
--- trunk/test-integration/common/src/test/java/org/teiid/jdbc/TestQueryPlans.java
(rev 0)
+++
trunk/test-integration/common/src/test/java/org/teiid/jdbc/TestQueryPlans.java 2010-04-07
15:52:07 UTC (rev 2033)
@@ -0,0 +1,70 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package org.teiid.jdbc;
+
+import static org.junit.Assert.*;
+
+import java.sql.Connection;
+import java.sql.ResultSet;
+import java.sql.Statement;
+
+import org.junit.Before;
+import org.junit.Test;
+
+import com.metamatrix.core.util.UnitTestUtil;
+
+@SuppressWarnings("nls")
+public class TestQueryPlans {
+
+ private Connection conn;
+
+ @Before public void setUp() throws Exception {
+ conn = TestMMDatabaseMetaData.createConnection("jdbc:teiid:test",
UnitTestUtil.getTestDataPath() + "/TestCase3473/test.vdb"); //$NON-NLS-1$
//$NON-NLS-2$
+ }
+
+ @Test public void testNoExec() throws Exception {
+ Statement s = conn.createStatement();
+ s.execute("set noexec on");
+ ResultSet rs = s.executeQuery("select * from all_tables");
+ assertFalse(rs.next());
+ s.execute("SET NOEXEC off");
+ rs = s.executeQuery("select * from all_tables");
+ assertTrue(rs.next());
+ }
+
+ @Test public void testShowPlan() throws Exception {
+ Statement s = conn.createStatement();
+ s.execute("set showplan on");
+ ResultSet rs = s.executeQuery("select * from all_tables");
+ assertNotNull(s.unwrap(TeiidStatement.class).getPlanDescription());
+ assertNull(s.unwrap(TeiidStatement.class).getDebugLog());
+ s.execute("SET showplan debug");
+ rs = s.executeQuery("select * from all_tables");
+ assertNotNull(s.unwrap(TeiidStatement.class).getDebugLog());
+ s.execute("SET showplan off");
+ rs = s.executeQuery("select * from all_tables");
+ assertNull(s.unwrap(TeiidStatement.class).getPlanDescription());
+ assertTrue(rs.next());
+ }
+
+}
Property changes on:
trunk/test-integration/common/src/test/java/org/teiid/jdbc/TestQueryPlans.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain