[teiid-commits] teiid SVN: r2346 - in trunk: build/kits/jboss-container and 3 other directories.

teiid-commits at lists.jboss.org teiid-commits at lists.jboss.org
Wed Jul 14 17:00:00 EDT 2010


Author: shawkins
Date: 2010-07-14 16:59:59 -0400 (Wed, 14 Jul 2010)
New Revision: 2346

Removed:
   trunk/client-jdbc30/
Modified:
   trunk/build/kits/jboss-container/teiid-releasenotes.html
   trunk/client/src/main/java/org/teiid/jdbc/ConnectionImpl.java
   trunk/client/src/main/java/org/teiid/jdbc/JDBCURL.java
   trunk/client/src/main/java/org/teiid/jdbc/StatementImpl.java
   trunk/client/src/test/java/org/teiid/jdbc/TestStatement.java
   trunk/documentation/client-developers-guide/src/main/docbook/en-US/content/jdbc-extensions.xml
   trunk/pom.xml
Log:
TEIID-908 minor cleanups, updating release notes and docs on the show statement and ensuring that the set/show commands only affect execution properties.

Modified: trunk/build/kits/jboss-container/teiid-releasenotes.html
===================================================================
--- trunk/build/kits/jboss-container/teiid-releasenotes.html	2010-07-14 18:36:07 UTC (rev 2345)
+++ trunk/build/kits/jboss-container/teiid-releasenotes.html	2010-07-14 20:59:59 UTC (rev 2346)
@@ -35,6 +35,7 @@
            <li>Changed named procedure syntax to accept param=>value, rather than param=value.
         </ul>
     <LI><B>Parallel Source Queries</B> - reestablished parallel execution of source queries within a query plan along with a prioritized work system to help prevent resource contention.
+    <LI><B>SHOW Statement</B> - added client handling for the SHOW statement to retrieve query plan information and see parameter values.
 </UL>
 
 <h2><a name="Compatibility">Compatibility Issues</a></h2>

Modified: trunk/client/src/main/java/org/teiid/jdbc/ConnectionImpl.java
===================================================================
--- trunk/client/src/main/java/org/teiid/jdbc/ConnectionImpl.java	2010-07-14 18:36:07 UTC (rev 2345)
+++ trunk/client/src/main/java/org/teiid/jdbc/ConnectionImpl.java	2010-07-14 20:59:59 UTC (rev 2346)
@@ -65,9 +65,9 @@
 import org.teiid.net.TeiidURL;
 import org.teiid.net.socket.SocketServerConnection;
 
-
-
-
+/**
+ * Teiid's Connection implementation.
+ */
 public class ConnectionImpl extends WrapperImpl implements Connection {
 	private static Logger logger = Logger.getLogger("org.teiid.jdbc"); //$NON-NLS-1$
 
@@ -118,52 +118,60 @@
     	this.serverConn = serverConn;
         this.url = url;
         this.dqp = serverConn.getService(DQP.class);
+        
+        logger.fine(JDBCPlugin.Util.getString("MMConnection.Session_success")); //$NON-NLS-1$
+        logConnectionProperties(url, info);
+        
+        setExecutionProperties(info);
         
-        // set default properties if not overridden
+        this.disableLocalTransactions = Boolean.valueOf(this.propInfo.getProperty(ExecutionProperties.DISABLE_LOCAL_TRANSACTIONS)).booleanValue();
+    }
+
+	private void setExecutionProperties(Properties info) {
+		this.propInfo = new Properties();
+        
         String overrideProp = info.getProperty(ExecutionProperties.PROP_TXN_AUTO_WRAP);
         if ( overrideProp == null || overrideProp.trim().length() == 0 ) {
-            info.put(ExecutionProperties.PROP_TXN_AUTO_WRAP, ExecutionProperties.TXN_WRAP_DETECT);
+        	propInfo.put(ExecutionProperties.PROP_TXN_AUTO_WRAP, ExecutionProperties.TXN_WRAP_DETECT);
         }
 
-        // Get default fetch size
         String defaultFetchSize = info.getProperty(ExecutionProperties.PROP_FETCH_SIZE);
         if (defaultFetchSize != null) {
-            info.put(ExecutionProperties.PROP_FETCH_SIZE, defaultFetchSize);
+        	propInfo.put(ExecutionProperties.PROP_FETCH_SIZE, defaultFetchSize);
         } else {
-            info.put(ExecutionProperties.PROP_FETCH_SIZE, ""+BaseDataSource.DEFAULT_FETCH_SIZE); //$NON-NLS-1$
+        	propInfo.put(ExecutionProperties.PROP_FETCH_SIZE, String.valueOf(BaseDataSource.DEFAULT_FETCH_SIZE)); 
         }
 
-        // Get partial results mode
         String partialResultsMode = info.getProperty(ExecutionProperties.PROP_PARTIAL_RESULTS_MODE);
         if (partialResultsMode != null) {
-            info.put(ExecutionProperties.PROP_PARTIAL_RESULTS_MODE, partialResultsMode);
+        	propInfo.put(ExecutionProperties.PROP_PARTIAL_RESULTS_MODE, partialResultsMode);
         } else {
-            info.put(ExecutionProperties.PROP_PARTIAL_RESULTS_MODE, BaseDataSource.DEFAULT_PARTIAL_RESULTS_MODE);
+        	propInfo.put(ExecutionProperties.PROP_PARTIAL_RESULTS_MODE, BaseDataSource.DEFAULT_PARTIAL_RESULTS_MODE);
         }
         
-        // Get result set cache mode
         String resultSetCacheMode = info.getProperty(ExecutionProperties.RESULT_SET_CACHE_MODE);
         if (resultSetCacheMode != null) {
-            info.put(ExecutionProperties.RESULT_SET_CACHE_MODE, resultSetCacheMode);
+        	propInfo.put(ExecutionProperties.RESULT_SET_CACHE_MODE, resultSetCacheMode);
         } else {
-            info.put(ExecutionProperties.RESULT_SET_CACHE_MODE, BaseDataSource.DEFAULT_RESULT_SET_CACHE_MODE);
+        	propInfo.put(ExecutionProperties.RESULT_SET_CACHE_MODE, BaseDataSource.DEFAULT_RESULT_SET_CACHE_MODE);
         }
 
         String ansiQuotes = info.getProperty(ExecutionProperties.ANSI_QUOTED_IDENTIFIERS);
         if (ansiQuotes != null) {
-            info.put(ExecutionProperties.ANSI_QUOTED_IDENTIFIERS, ansiQuotes);
+        	propInfo.put(ExecutionProperties.ANSI_QUOTED_IDENTIFIERS, ansiQuotes);
         } else {
-            info.put(ExecutionProperties.ANSI_QUOTED_IDENTIFIERS, Boolean.TRUE.toString());
+        	propInfo.put(ExecutionProperties.ANSI_QUOTED_IDENTIFIERS, Boolean.TRUE.toString());
         }
-                
-        logger.fine(JDBCPlugin.Util.getString("MMConnection.Session_success")); //$NON-NLS-1$
-        logConnectionProperties(url, info);
-                
-        // properties object used in obtaining connection
-        this.propInfo = info;
-        
-        this.disableLocalTransactions = Boolean.valueOf(this.propInfo.getProperty(ExecutionProperties.DISABLE_LOCAL_TRANSACTIONS)).booleanValue();
-    }
+                                
+        for (String key : info.stringPropertyNames()) {
+        	for (String prop : JDBCURL.EXECUTION_PROPERTIES) {
+        		if (prop.equalsIgnoreCase(key)) {
+            		propInfo.setProperty(key, info.getProperty(key));
+            		break;
+        		}
+        	}
+		}
+	}
     
     public Collection<Annotation> getAnnotations() {
 		return annotations;
@@ -189,7 +197,7 @@
 		this.currentPlanDescription = currentPlanDescription;
 	}
     
-    protected Properties getConnectionProperties() {
+    protected Properties getExecutionProperties() {
         return this.propInfo;
     }
     

Modified: trunk/client/src/main/java/org/teiid/jdbc/JDBCURL.java
===================================================================
--- trunk/client/src/main/java/org/teiid/jdbc/JDBCURL.java	2010-07-14 18:36:07 UTC (rev 2345)
+++ trunk/client/src/main/java/org/teiid/jdbc/JDBCURL.java	2010-07-14 20:59:59 UTC (rev 2346)
@@ -24,10 +24,14 @@
 
 import java.io.UnsupportedEncodingException;
 import java.net.URLDecoder;
+import java.util.Arrays;
+import java.util.Collections;
 import java.util.Enumeration;
+import java.util.HashSet;
 import java.util.Iterator;
 import java.util.Map;
 import java.util.Properties;
+import java.util.Set;
 
 import org.teiid.net.TeiidURL;
 
@@ -43,27 +47,34 @@
     private static final String UTF_8 = "UTF-8"; //$NON-NLS-1$
     public static final String JDBC_PROTOCOL = "jdbc:teiid:"; //$NON-NLS-1$
     private static final String OLD_JDBC_PROTOCOL = "jdbc:metamatrix:"; //$NON-NLS-1$
+
+    public static final Set<String> EXECUTION_PROPERTIES = Collections.unmodifiableSet(new HashSet<String>(Arrays.asList(
+            ExecutionProperties.PROP_TXN_AUTO_WRAP,
+            ExecutionProperties.PROP_PARTIAL_RESULTS_MODE,
+            ExecutionProperties.RESULT_SET_CACHE_MODE,
+            ExecutionProperties.ANSI_QUOTED_IDENTIFIERS,
+            ExecutionProperties.SQL_OPTION_SHOWPLAN,
+            ExecutionProperties.NOEXEC,
+            ExecutionProperties.PROP_FETCH_SIZE,
+            ExecutionProperties.PROP_XML_FORMAT,
+            ExecutionProperties.PROP_XML_VALIDATION,
+            ExecutionProperties.DISABLE_LOCAL_TRANSACTIONS)));
     
-    public static final String[] KNOWN_PROPERTIES = {
-        BaseDataSource.APP_NAME,
-        BaseDataSource.VDB_NAME,
-        BaseDataSource.VERSION,
-        BaseDataSource.VDB_VERSION,
-        BaseDataSource.USER_NAME,
-        BaseDataSource.PASSWORD,
-        ExecutionProperties.PROP_TXN_AUTO_WRAP,
-        ExecutionProperties.PROP_PARTIAL_RESULTS_MODE,
-        ExecutionProperties.RESULT_SET_CACHE_MODE,
-        ExecutionProperties.ANSI_QUOTED_IDENTIFIERS,
-        ExecutionProperties.SQL_OPTION_SHOWPLAN,
-        ExecutionProperties.NOEXEC,
-        ExecutionProperties.PROP_FETCH_SIZE,
-        ExecutionProperties.PROP_XML_FORMAT,
-        ExecutionProperties.PROP_XML_VALIDATION,
-        ExecutionProperties.DISABLE_LOCAL_TRANSACTIONS,
-        TeiidURL.CONNECTION.AUTO_FAILOVER,
-        TeiidURL.CONNECTION.DISCOVERY_STRATEGY
-    };
+    public static final Set<String> KNOWN_PROPERTIES = getKnownProperties();
+    
+    private static Set<String> getKnownProperties() {
+    	Set<String> props = new HashSet<String>(Arrays.asList(
+    	        BaseDataSource.APP_NAME,
+    	        BaseDataSource.VDB_NAME,
+    	        BaseDataSource.VERSION,
+    	        BaseDataSource.VDB_VERSION,
+    	        BaseDataSource.USER_NAME,
+    	        BaseDataSource.PASSWORD,
+    	        TeiidURL.CONNECTION.AUTO_FAILOVER,
+    	        TeiidURL.CONNECTION.DISCOVERY_STRATEGY));
+    	props.addAll(EXECUTION_PROPERTIES);
+    	return Collections.unmodifiableSet(props);
+    }
     
     private String vdbName;
     private String connectionURL;
@@ -290,15 +301,14 @@
         // now add the normalized key and value into the properties object.
         target.put(validKey, value);
     }
-
-    public static String getValidKey(String key) {
-        // figure out the valid key based on its case
-        for (int i = 0; i < KNOWN_PROPERTIES.length; i++) {
-            if (key.equalsIgnoreCase(KNOWN_PROPERTIES[i])) {
-                return KNOWN_PROPERTIES[i];
-            }
-        }
-        return key;
+
+    public static String getValidKey(String key) {
+    	for (String prop : KNOWN_PROPERTIES) {
+    		if (prop.equalsIgnoreCase(key)) {
+    			return prop;
+    		}
+        }
+    	return key;
     }
     
     private static Object getValidValue(Object value) {

Modified: trunk/client/src/main/java/org/teiid/jdbc/StatementImpl.java
===================================================================
--- trunk/client/src/main/java/org/teiid/jdbc/StatementImpl.java	2010-07-14 18:36:07 UTC (rev 2345)
+++ trunk/client/src/main/java/org/teiid/jdbc/StatementImpl.java	2010-07-14 20:59:59 UTC (rev 2346)
@@ -166,7 +166,7 @@
         this.driverConnection = driverConnection;
         this.resultSetType = resultSetType;
         this.resultSetConcurrency = resultSetConcurrency;
-        this.execProps = new Properties(this.driverConnection.getConnectionProperties());
+        this.execProps = new Properties(this.driverConnection.getExecutionProperties());
         
         // Set initial fetch size
         String fetchSizeStr = this.execProps.getProperty(ExecutionProperties.PROP_FETCH_SIZE);
@@ -395,7 +395,7 @@
         		}
         		String key = match.group(1);
         		String value = match.group(2);
-        		JDBCURL.addNormalizedProperty(key, value, this.driverConnection.getConnectionProperties());
+        		JDBCURL.addNormalizedProperty(key, value, this.driverConnection.getExecutionProperties());
         		this.updateCounts = new int[] {0};
         		return;
         	}
@@ -436,17 +436,17 @@
         		}
         		if (show.equalsIgnoreCase("ALL")) { //$NON-NLS-1$
         			List<ArrayList<Object>> records = new ArrayList<ArrayList<Object>>(1);
-        			for (String key : driverConnection.getConnectionProperties().stringPropertyNames()) {
+        			for (String key : driverConnection.getExecutionProperties().stringPropertyNames()) {
         				ArrayList<Object> row = new ArrayList<Object>(4);
             			row.add(key);
-            			row.add(driverConnection.getConnectionProperties().get(key));
+            			row.add(driverConnection.getExecutionProperties().get(key));
         				records.add(row);
         			}
         			createResultSet(records, new String[] {"NAME", "VALUE"}, //$NON-NLS-1$ //$NON-NLS-2$
         					new String[] {JDBCSQLTypeInfo.STRING, JDBCSQLTypeInfo.STRING});
             		return;
         		}
-        		List<List<String>> records = Collections.singletonList(Collections.singletonList(driverConnection.getConnectionProperties().getProperty(JDBCURL.getValidKey(show))));
+        		List<List<String>> records = Collections.singletonList(Collections.singletonList(driverConnection.getExecutionProperties().getProperty(JDBCURL.getValidKey(show))));
     			createResultSet(records, new String[] {show}, new String[] {JDBCSQLTypeInfo.STRING});
         		return;
         	}
@@ -948,12 +948,6 @@
         return this.annotations;
     }
     
-    public void setPartialResults(boolean isPartialResults){
-        if(isPartialResults){
-            this.execProps.put(ExecutionProperties.PROP_PARTIAL_RESULTS_MODE, "true"); //$NON-NLS-1$
-        }
-    }
-
     public String getRequestIdentifier() {
         if(this.currentRequestID >= 0) {
             return Long.toString(this.currentRequestID);

Modified: trunk/client/src/test/java/org/teiid/jdbc/TestStatement.java
===================================================================
--- trunk/client/src/test/java/org/teiid/jdbc/TestStatement.java	2010-07-14 18:36:07 UTC (rev 2345)
+++ trunk/client/src/test/java/org/teiid/jdbc/TestStatement.java	2010-07-14 20:59:59 UTC (rev 2346)
@@ -66,7 +66,7 @@
 	@Test public void testSetStatement() throws Exception {
 		ConnectionImpl conn = Mockito.mock(ConnectionImpl.class);
 		Properties p = new Properties();
-		Mockito.stub(conn.getConnectionProperties()).toReturn(p);
+		Mockito.stub(conn.getExecutionProperties()).toReturn(p);
 		StatementImpl statement = new StatementImpl(conn, ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY);
 		assertFalse(statement.execute("set foo bar")); //$NON-NLS-1$
 		assertEquals("bar", p.get("foo")); //$NON-NLS-1$ //$NON-NLS-2$
@@ -76,7 +76,7 @@
 		ConnectionImpl conn = Mockito.mock(ConnectionImpl.class);
 		Properties p = new Properties();
 		p.setProperty(ExecutionProperties.ANSI_QUOTED_IDENTIFIERS, Boolean.TRUE.toString());
-		Mockito.stub(conn.getConnectionProperties()).toReturn(p);
+		Mockito.stub(conn.getExecutionProperties()).toReturn(p);
 		StatementImpl statement = new StatementImpl(conn, ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY);
 		assertEquals(Boolean.TRUE.toString(), statement.getExecutionProperty(ExecutionProperties.ANSI_QUOTED_IDENTIFIERS));
 		statement.setExecutionProperty(ExecutionProperties.ANSI_QUOTED_IDENTIFIERS, Boolean.FALSE.toString());

Modified: trunk/documentation/client-developers-guide/src/main/docbook/en-US/content/jdbc-extensions.xml
===================================================================
--- trunk/documentation/client-developers-guide/src/main/docbook/en-US/content/jdbc-extensions.xml	2010-07-14 18:36:07 UTC (rev 2345)
+++ trunk/documentation/client-developers-guide/src/main/docbook/en-US/content/jdbc-extensions.xml	2010-07-14 20:59:59 UTC (rev 2346)
@@ -175,7 +175,7 @@
        </sect1>    
        
        <sect1 id="set_statement">
-        <title>Set Statement</title>
+        <title>SET Statement</title>
         
         <para>Execution properties may also be set on the connection by using the SET statement.  
         The SET statement is not yet a language feature of Teiid and is handled only in the JDBC client.</para>
@@ -208,18 +208,51 @@
             </listitem>
         </itemizedlist>        
         
-        <example>
+        <example id="plan_debug">
         	<title>Enabling Plan Debug</title>
         	<programlisting>Statement s = connection.createStatement();
 s.execute("SET SHOWPLAN DEBUG");
 ...
 Statement s1 = connection.createStatement();
 ResultSet rs = s1.executeQuery("select col from table");
-TeiidStatement ts = s1.unwrap(TeiidStatement.class);
-String debugLog = ts.getDebugLog();        	
+
+ResultSet planRs = s1.exeuteQuery("SHOW PLAN");
+planRs.next();
+String debugLog = planRs.getString("DEBUG_LOG"); 
         	</programlisting>
         </example>
        </sect1>
+
+       <sect1 id="show_statement">
+        <title>SHOW Statement</title>
+        
+        <para>The SHOW statement can be used to see a varitey of information.  
+        The SHOW statement is not yet a language feature of Teiid and is handled only in the JDBC client.</para>
+        
+        <itemizedlist>
+            <para>SHOW Usage:
+            </para>
+            <listitem>
+                <para>SHOW <emphasis>PLAN</emphasis> - returns a resultset with a clob column PLAN_TEXT, an xml column PLAN_XML, and a clob column DEBUG_LOG with a row containing the values from the previously executed query.  
+                If SHOWPLAN is OFF or no plan is available, no rows are returned.  If SHOWPLAN is not set to DEBUG, then DEBUG_LOG will return a null value.
+                </para>
+            </listitem>
+            <listitem>
+                <para>SHOW <emphasis>ANNOTATIONS</emphasis> - returns a resultset with string columns CATEGORY, PRIORITY, ANNOTATION, RESOLUTION and a row for each annotation on the previously executed query.  
+                If SHOWPLAN is OFF or no plan is available, no rows are returned.
+                </para>
+            </listitem>
+            <listitem>
+                <para>SHOW property - the inverse of SET, shows the property value for the given property, returns a resultset with a single string column with a name matching the property key.
+                </para>
+            </listitem>
+            <listitem>
+                <para>SHOW <emphasis>ALL</emphasis> - returns a resultset with a NAME string column and a VALUE string column with a row entry for every property value.
+                </para>
+            </listitem>
+        </itemizedlist>
+        <para>The SHOW statement is most commonly used to retrieve the query plan, see the plan <link linkend="plan_debug">debug example</link>.</para>        
+       </sect1>
                             
        <sect1 id="partial_results">
         <title>Partial Results Mode</title>

Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml	2010-07-14 18:36:07 UTC (rev 2345)
+++ trunk/pom.xml	2010-07-14 20:59:59 UTC (rev 2346)
@@ -469,11 +469,6 @@
               <scope>provided</scope>
             </dependency>            
 			<dependency>
-				<groupId>beanshell</groupId>
-				<artifactId>bsh</artifactId>
-				<version>2.0b4</version>
-			</dependency>
-			<dependency>
 				<groupId>net.sourceforge.saxon</groupId>
 				<artifactId>saxon</artifactId>
 				<version>9.1.0.8</version>



More information about the teiid-commits mailing list