db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kmars...@apache.org
Subject svn commit: r351776 - in /db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang: copyfiles.ant largeCodeGen.java largeCodeGen_app.properties
Date Fri, 02 Dec 2005 17:24:04 GMT
Author: kmarsden
Date: Fri Dec  2 09:23:56 2005
New Revision: 351776

URL: http://svn.apache.org/viewcvs?rev=351776&view=rev
Log:
Add tests and cleanup largeCodeGen test in preparation for DERBY-739 fix.


Added:
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/largeCodeGen_app.properties
  (with props)
Modified:
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/copyfiles.ant
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/largeCodeGen.java

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/copyfiles.ant
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/copyfiles.ant?rev=351776&r1=351775&r2=351776&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/copyfiles.ant
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/copyfiles.ant
Fri Dec  2 09:23:56 2005
@@ -125,6 +125,7 @@
 joinDeadlock_derby.properties
 joins.sql
 joins_app.properties
+largeCodeGen_app.properties
 langUnitTests.sql
 langUnitTests_derby.properties
 LOBDB2compatibility_app.properties

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/largeCodeGen.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/largeCodeGen.java?rev=351776&r1=351775&r2=351776&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/largeCodeGen.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/largeCodeGen.java
Fri Dec  2 09:23:56 2005
@@ -1,27 +1,95 @@
 package org.apache.derbyTesting.functionTests.tests.lang;
 
-import java.sql.DriverManager;
 import java.sql.Connection;
 import java.sql.*;
 
-import java.util.Properties;
 import org.apache.derby.tools.ij;
 
 
 // This test tries to push byte code generation to the limit.
-// the variable numUnions can be changed to push up the byte code generated
-// It has to be run with a large amount of memory. if numUnions is set high e.g.
-//  java -Djvmflags=-Xmx512M org.apache.derbyTesting.harness.RunTest lang/largeCodeGen
-// This is but one code path other areas need to be tested such as large in clauses, etc.
+// It has to be run with a large amount of memory which is set with jvmflags in 
+// largeCodeGen_app.properties
+// There are only a few types of cases now. Other areas need to be tested such as large in
clauses, etc.
+// 
 
 public class largeCodeGen
 {
 
+	
     public static void main(String argv[]) 
        throws Exception
     {
-        Statement stmt = null;
+    	ij.getPropertyArg(argv); 
+        Connection con = ij.startJBMS();
+        con.setAutoCommit(false);
+        testParamsInWhereClause(con);
+        testUnions(con);
+        con.commit();
+        con.close();
+    }
+    
+    private static void createTestTable(Connection con) throws SQLException
+    {
+    	 Statement stmt = null;		
+    	 stmt = con.createStatement();
+    	 try {
+			stmt.executeUpdate("drop table t0 ");
+		}catch (SQLException se)
+		{
+			// drop error ok.
+			if (!se.getSQLState().equals("42Y55"))
+				throw se;
+		}	
+		
+		String createSQL = 	"create table t0 " +
+		"(si smallint,i int, bi bigint, r real, f float, d double precision, n5_2 numeric(5,2),
dec10_3 decimal(10,3), ch20 char(3),vc varchar(20), lvc long varchar)";
+		stmt.executeUpdate(createSQL);	
+		stmt.executeUpdate("insert into t0 values(2,3,4,5.3,5.3,5.3,31.13,123456.123, 'one','one','one')");
+    }
+    
+    /**
+     * Test many parameters in the where clause
+     * e.g. 
+	 * @param con  
+	 */
+	private static void testParamsInWhereClause(Connection con)  throws SQLException {
+		 createTestTable(con);
+		 testWhereParams(con, 200);
+		 testWhereParams(con, 400);
+	}
+
+	
+	/**
+	 * Tests numParam parameter markers in a where clause
+	 * 
+	 * @param con          
+	 * @param  numparams  
+	 */
+	private static void testWhereParams(Connection con, int numParams) throws SQLException {
+		PreparedStatement ps  = null;
+		String pred = "(si = ? AND i = ? )";
+		String testName = "WHERE clause with " + numParams + " parameters";
+		StringBuffer sqlBuffer = new StringBuffer("DELETE FROM T0 WHERE " + pred );
+		for (int i = 2; i < numParams; i+=2)
+		{
+			sqlBuffer.append(" OR (si = ? AND i = ? ) ");
+		}
+		try {
+			ps = con.prepareStatement(sqlBuffer.toString());
+			System.out.println("PASS: " + testName);
+		 
+		}catch (Exception e)
+		{
+			reportFailure(testName, e);
+			
+		}
+	}
+
+	private static void testUnions(Connection con) throws Exception
+	{
+		Statement stmt = null;
         PreparedStatement pstmt = null; 
+        createTestTable(con);
 		//int numUnions = 4000;
 		//int numUnions = 2000;
 		/*
@@ -31,24 +99,11 @@
 		  (class: db2j/exe/ac601a400fx0102xc673xe3e9x000000163ac04, method: 
 		  execute signature: ()Lcom/ibm/db2j/protocol/Database/Language/Interface/ResultSet;) Illegal
target of jump or branch". My fix affects generated method "fillResultSet". With size 10000
largeCodeGen gets Java exception: 'java.io.IOException: constant_pool(70796 > 65535)'.
 		*/
-
-		String tableName = "t0";		
+		
 		String viewName = "v0";		
-
-		ij.getPropertyArg(argv); 
-	        Connection con = ij.startJBMS();        
-
-		con.setAutoCommit(false);
 		stmt = con.createStatement();
- 	       System.out.println("connected");
 
-		// Create table
-		try {
-			stmt.executeUpdate("drop table " + tableName);
-		}catch (SQLException se)
-		{
-			// drop error ok.
-		}
+		
 		try {
 			stmt.executeUpdate("drop view " + viewName);
 		}catch (SQLException se)
@@ -56,35 +111,32 @@
 			// drop error ok.
 		}
 
-		String createSQL = 	"create table " +
-			tableName +
-			"(si smallint,i int, bi bigint, r real, f float, d double precision, n5_2 numeric(5,2),
dec10_3 decimal(10,3), ch20 char(3),vc varchar(20), lvc long varchar)";
-		stmt.executeUpdate(createSQL);
-		stmt.executeUpdate("insert into " + tableName + " values(2,3,4,5.3,5.3,5.3,31.13,123456.123,
'one','one','one')");
-		
-		System.out.println("Building view 100 unions");  
+				  
 		StringBuffer createView = new StringBuffer("create view " + viewName + 
-												   " as select * from " + 
-												   tableName);
+												   " as select * from t0 " );
 		for (int i = 1; i < 100; i ++)
 		{
-			createView.append(" UNION ALL (SELECT * FROM " + tableName + ")");
+			createView.append(" UNION ALL (SELECT * FROM t0 )");
 		}
 		String createViewString = createView.toString();
 		//System.out.println(createViewString);
 		stmt.executeUpdate(createView.toString());
 		
+		
 		// 2000 unions caused method too big error in verifier
 		largeUnionSelect(con, viewName, 2000);
 
 		// 10000 unions overflows the number of constant pool entries
-		largeUnionSelect(con, viewName, 10000);		
+		largeUnionSelect(con, viewName, 10000);
+
     }
     
     private static void largeUnionSelect(Connection con, String viewName,
     		int numUnions) throws Exception
 	{
 
+    	// There are 100 unions in each view so round to the nearest 100
+    	String testName = "SELECT with " + numUnions/100 * 100 + " unions";
 		StringBuffer selectSQLBuffer  = new StringBuffer("select * from t0 ") ;
 		for (int i = 1; i < numUnions/100;i++)
 		{
@@ -95,7 +147,6 @@
 		// Ready to execute the problematic query 
 		String selectSQL = selectSQLBuffer.toString();
 		//System.out.println(selectSQL);
-		System.out.println("SELECT with " + numUnions/100 * 100 + " unions");
         PreparedStatement pstmt = con.prepareStatement(selectSQL);
         ResultSet rs = pstmt.executeQuery();
 		int numRowsExpected = (numUnions/100 * 100);
@@ -106,17 +157,14 @@
 			if ((numRows % 100) == 0)
 			checkRowData(rs);
 		}
-		System.out.println("PASS: Row data check ok");
+		System.out.println("PASS: " + testName + " Row data check ok");
         con.commit();
         pstmt.close();
-        con.close();
+     
 		} catch (SQLException sqle)
 		{
-			System.out.println("FAILED QUERY");
-			do {
-				System.out.println(sqle.getSQLState() + ":" + sqle.getMessage());
-				sqle = sqle.getNextException();
-			} while (sqle != null);
+			reportFailure(testName, sqle);
+			
 		}
 
       }
@@ -138,6 +186,25 @@
 		}
 	}
 
+	/**
+	 * Show failure message and exception stack trace
+	 * @param testName
+	 * @param e
+	 */
+	private static void reportFailure(String testName, Exception e)
+	{
+		System.out.print("FAILED QUERY: " + testName +". ");
+		if (e instanceof SQLException)
+		{
+			SQLException se = (SQLException) e;
+			while (se != null)
+			{
+				se.printStackTrace(System.out);
+				se = se.getNextException();
+			}
+		}	
+		else e.printStackTrace();
+	
+	}
+	
 }
-
-

Added: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/largeCodeGen_app.properties
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/largeCodeGen_app.properties?rev=351776&view=auto
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/largeCodeGen_app.properties
(added)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/largeCodeGen_app.properties
Fri Dec  2 09:23:56 2005
@@ -0,0 +1,2 @@
+usedefaults=true
+jvmflags=-Xmx512M -Xms512M

Propchange: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/largeCodeGen_app.properties
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message