db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d..@apache.org
Subject svn commit: r553598 - in /db/derby/code/branches/10.3/java: engine/org/apache/derby/iapi/services/classfile/ engine/org/apache/derby/iapi/sql/compile/ engine/org/apache/derby/impl/sql/compile/ testing/org/apache/derbyTesting/functionTests/tests/lang/ t...
Date Thu, 05 Jul 2007 18:22:35 GMT
Author: djd
Date: Thu Jul  5 11:22:33 2007
New Revision: 553598

URL: http://svn.apache.org/viewvc?view=rev&rev=553598
Log:
Merge 552999,553004,553006,553008 from trunk.
Cleanup for CollationTest
Remove a couple of old query tree node names
Allow ClassHolder to work with new versions of the class file.

Modified:
    db/derby/code/branches/10.3/java/engine/org/apache/derby/iapi/services/classfile/ClassHolder.java
    db/derby/code/branches/10.3/java/engine/org/apache/derby/iapi/services/classfile/ClassInvestigator.java
    db/derby/code/branches/10.3/java/engine/org/apache/derby/iapi/sql/compile/C_NodeTypes.java
    db/derby/code/branches/10.3/java/engine/org/apache/derby/impl/sql/compile/C_NodeNames.java
    db/derby/code/branches/10.3/java/engine/org/apache/derby/impl/sql/compile/NodeFactoryImpl.java
    db/derby/code/branches/10.3/java/testing/org/apache/derbyTesting/functionTests/tests/lang/CollationTest.java
    db/derby/code/branches/10.3/java/testing/org/apache/derbyTesting/junit/Decorator.java
    db/derby/code/branches/10.3/java/testing/org/apache/derbyTesting/junit/JDBC.java

Modified: db/derby/code/branches/10.3/java/engine/org/apache/derby/iapi/services/classfile/ClassHolder.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.3/java/engine/org/apache/derby/iapi/services/classfile/ClassHolder.java?view=diff&rev=553598&r1=553597&r2=553598
==============================================================================
--- db/derby/code/branches/10.3/java/engine/org/apache/derby/iapi/services/classfile/ClassHolder.java
(original)
+++ db/derby/code/branches/10.3/java/engine/org/apache/derby/iapi/services/classfile/ClassHolder.java
Thu Jul  5 11:22:33 2007
@@ -57,7 +57,26 @@
 	/*
 	** Fields
 	*/
-
+    
+    /**
+     * Minor class format number defaults to 
+     * VMDescriptor.JAVA_CLASS_FORMAT_MINOR_VERSION
+     * which currently corresponds to a really old (JDK 1.0.2) setting.
+     * The default major and minor value is used by the generated code for Derby's
+     * SQL statements. Currently there is no need to bump the version
+     * number as the generated code does not take advantage of any of the
+     * new elements in the class file format. If such a need exists then
+     * this can be bumped. One issue is that the change in format numbers
+     * is not well documented.
+     */
+    protected int minor_version = VMDescriptor.JAVA_CLASS_FORMAT_MINOR_VERSION;
+
+    /**
+     * Minor class format number defaults to 
+     * VMDescriptor.JAVA_CLASS_FORMAT_MAJOR_VERSION
+     */
+    protected int major_version = VMDescriptor.JAVA_CLASS_FORMAT_MAJOR_VERSION;
+    
 	protected int access_flags;
 	protected int this_class;
 	protected int super_class;
@@ -118,8 +137,8 @@
 
 		/* Write out the header */
 		out.putU4(VMDescriptor.JAVA_CLASS_FORMAT_MAGIC);
-		out.putU2(VMDescriptor.JAVA_CLASS_FORMAT_MINOR_VERSION);
-		out.putU2(VMDescriptor.JAVA_CLASS_FORMAT_MAJOR_VERSION);
+		out.putU2(minor_version);
+		out.putU2(major_version);
 
 		// special case checking that the number of constant
 		// pool entries does not exceed the limit of 65535

Modified: db/derby/code/branches/10.3/java/engine/org/apache/derby/iapi/services/classfile/ClassInvestigator.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.3/java/engine/org/apache/derby/iapi/services/classfile/ClassInvestigator.java?view=diff&rev=553598&r1=553597&r2=553598
==============================================================================
--- db/derby/code/branches/10.3/java/engine/org/apache/derby/iapi/services/classfile/ClassInvestigator.java
(original)
+++ db/derby/code/branches/10.3/java/engine/org/apache/derby/iapi/services/classfile/ClassInvestigator.java
Thu Jul  5 11:22:33 2007
@@ -49,12 +49,21 @@
 		ClassInput classInput = new ClassInput(is);
 
 		// Check the header
-		checkHeader(classInput);
+        int magic = classInput.getU4();
+        int minor_version = classInput.getU2();
+        int major_version = classInput.getU2();
+
+        if (magic != VMDescriptor.JAVA_CLASS_FORMAT_MAGIC)
+               throw new ClassFormatError();
 
 		//	Read in the Constant Pool
 		int constantPoolCount = classInput.getU2();
 
 		ClassInvestigator ci = new ClassInvestigator(constantPoolCount);
+        
+        ci.minor_version = minor_version;
+        ci.major_version = major_version;      
+        
 		// Yes, index starts at 1, The '0'th constant pool entry
 		// is reserved for the JVM and is not present in the class file.
 		for (int i = 1; i < constantPoolCount; ) {
@@ -451,25 +460,13 @@
 		CONSTANT_Utf8_info newCpe = new CONSTANT_Utf8_info(newName);
 
 		cptHashTable.remove(cpe.getKey());
-		cptHashTable.put(cpe.getKey(), cpe);
+		cptHashTable.put(newCpe.getKey(), newCpe);
 
 		newCpe.index = index;
 
 		cptEntries.setElementAt(newCpe, index);
 	}
 
-	/*
-	**
-	*/
-	static private void checkHeader(ClassInput in) throws IOException {
-		int magic = in.getU4();
-		int minor_version = in.getU2();
-		int major_version = in.getU2();
-
-
-		if (magic != VMDescriptor.JAVA_CLASS_FORMAT_MAGIC)
-			   throw new ClassFormatError();
-   	}
 	private static ConstantPoolEntry getConstant(ClassInput in)
 		throws IOException {
 

Modified: db/derby/code/branches/10.3/java/engine/org/apache/derby/iapi/sql/compile/C_NodeTypes.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.3/java/engine/org/apache/derby/iapi/sql/compile/C_NodeTypes.java?view=diff&rev=553598&r1=553597&r2=553598
==============================================================================
--- db/derby/code/branches/10.3/java/engine/org/apache/derby/iapi/sql/compile/C_NodeTypes.java
(original)
+++ db/derby/code/branches/10.3/java/engine/org/apache/derby/iapi/sql/compile/C_NodeTypes.java
Thu Jul  5 11:22:33 2007
@@ -96,7 +96,7 @@
 	static final int DROP_INDEX_NODE = 63;
 	// 64 available;
 	static final int DROP_TRIGGER_NODE = 65;
-	static final int READ_CURSOR_NODE = 66;
+	// 66 available;
 	static final int DECIMAL_CONSTANT_NODE = 67;
 	static final int DOUBLE_CONSTANT_NODE = 68;
 	static final int FLOAT_CONSTANT_NODE = 69;

Modified: db/derby/code/branches/10.3/java/engine/org/apache/derby/impl/sql/compile/C_NodeNames.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.3/java/engine/org/apache/derby/impl/sql/compile/C_NodeNames.java?view=diff&rev=553598&r1=553597&r2=553598
==============================================================================
--- db/derby/code/branches/10.3/java/engine/org/apache/derby/impl/sql/compile/C_NodeNames.java
(original)
+++ db/derby/code/branches/10.3/java/engine/org/apache/derby/impl/sql/compile/C_NodeNames.java
Thu Jul  5 11:22:33 2007
@@ -208,8 +208,6 @@
 
 	static final String PROJECT_RESTRICT_NODE_NAME = "org.apache.derby.impl.sql.compile.ProjectRestrictNode";
 
-	static final String READ_CURSOR_NODE_NAME = "org.apache.derby.impl.sql.compile.ReadCursorNode";
-
 	static final String RENAME_NODE_NAME = "org.apache.derby.impl.sql.compile.RenameNode";
 
 	static final String RESULT_COLUMN_NAME = "org.apache.derby.impl.sql.compile.ResultColumn";
@@ -231,8 +229,6 @@
 	static final String SET_SCHEMA_NODE_NAME = "org.apache.derby.impl.sql.compile.SetSchemaNode";
 
 	static final String SET_TRANSACTION_ISOLATION_NODE_NAME = "org.apache.derby.impl.sql.compile.SetTransactionIsolationNode";
-
-	static final String SET_TRIGGERS_NODE_NAME = "org.apache.derby.impl.sql.compile.SetTriggersNode";
 
 	static final String SIMPLE_STRING_OPERATOR_NODE_NAME = "org.apache.derby.impl.sql.compile.SimpleStringOperatorNode";
 

Modified: db/derby/code/branches/10.3/java/engine/org/apache/derby/impl/sql/compile/NodeFactoryImpl.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.3/java/engine/org/apache/derby/impl/sql/compile/NodeFactoryImpl.java?view=diff&rev=553598&r1=553597&r2=553598
==============================================================================
--- db/derby/code/branches/10.3/java/engine/org/apache/derby/impl/sql/compile/NodeFactoryImpl.java
(original)
+++ db/derby/code/branches/10.3/java/engine/org/apache/derby/impl/sql/compile/NodeFactoryImpl.java
Thu Jul  5 11:22:33 2007
@@ -342,9 +342,6 @@
 		  case C_NodeTypes.DROP_TRIGGER_NODE:
 		  	return C_NodeNames.DROP_TRIGGER_NODE_NAME;
 
-		  case C_NodeTypes.READ_CURSOR_NODE:
-		  	return C_NodeNames.READ_CURSOR_NODE_NAME;
-
 		  case C_NodeTypes.TINYINT_CONSTANT_NODE:
 		  case C_NodeTypes.SMALLINT_CONSTANT_NODE:
 		  case C_NodeTypes.INT_CONSTANT_NODE:

Modified: db/derby/code/branches/10.3/java/testing/org/apache/derbyTesting/functionTests/tests/lang/CollationTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.3/java/testing/org/apache/derbyTesting/functionTests/tests/lang/CollationTest.java?view=diff&rev=553598&r1=553597&r2=553598
==============================================================================
--- db/derby/code/branches/10.3/java/testing/org/apache/derbyTesting/functionTests/tests/lang/CollationTest.java
(original)
+++ db/derby/code/branches/10.3/java/testing/org/apache/derbyTesting/functionTests/tests/lang/CollationTest.java
Thu Jul  5 11:22:33 2007
@@ -31,10 +31,14 @@
 import javax.sql.DataSource;
 
 import junit.framework.Test;
+import junit.framework.TestSuite;
 
+import org.apache.derbyTesting.functionTests.tests.jdbcapi.DatabaseMetaDataTest;
 import org.apache.derbyTesting.junit.XML;
 //import org.apache.derby.iapi.types.XML;
 import org.apache.derbyTesting.junit.BaseJDBCTestCase;
+import org.apache.derbyTesting.junit.CleanDatabaseTestSetup;
+import org.apache.derbyTesting.junit.Decorator;
 import org.apache.derbyTesting.junit.JDBC;
 import org.apache.derbyTesting.junit.JDBCDataSource;
 import org.apache.derbyTesting.junit.TestConfiguration;
@@ -88,14 +92,9 @@
    * @throws SQLException
    */
 public void testDefaultCollation() throws SQLException {
-      DataSource ds = JDBCDataSource.getDataSourceLogical("defaultdb");
-      JDBCDataSource.setBeanProperty(ds, "connectionAttributes", 
-                  "create=true");
 
-      
-      Connection conn = ds.getConnection();
-      conn.setAutoCommit(false);
-      Statement s = conn.createStatement();
+      getConnection().setAutoCommit(false);
+      Statement s = createStatement();
       PreparedStatement ps;
       ResultSet rs;
       
@@ -231,7 +230,7 @@
       //Since all schemas (ie user and system) have the same collation, the 
       //following test won't fail.
       s.executeUpdate("set schema APP");
-      ps = conn.prepareStatement("SELECT TABLENAME FROM SYS.SYSTABLES WHERE " +
+      ps = prepareStatement("SELECT TABLENAME FROM SYS.SYSTABLES WHERE " +
       		" ? = TABLENAME");
       ps.setString(1, "SYSCOLUMNS");
       rs = ps.executeQuery();
@@ -239,7 +238,7 @@
 
       //Since all schemas (ie user and system) have the same collation, the 
       //following test won't fail.
-      ps = conn.prepareStatement("SELECT TABLENAME FROM SYS.SYSTABLES WHERE " +
+      ps = prepareStatement("SELECT TABLENAME FROM SYS.SYSTABLES WHERE " +
 		" SUBSTR(?,2) = TABLENAME");
       ps.setString(1, " SYSCOLUMNS");
       rs = ps.executeQuery();
@@ -247,12 +246,12 @@
 
       //Since all schemas (ie user and system) have the same collation, the 
       //following test won't fail.
-      ps = conn.prepareStatement("SELECT TABLENAME FROM SYS.SYSTABLES WHERE " +
+      ps = prepareStatement("SELECT TABLENAME FROM SYS.SYSTABLES WHERE " +
 		" LTRIM(?) = TABLENAME");
       ps.setString(1, " SYSCOLUMNS");
       rs = ps.executeQuery();
       JDBC.assertFullResultSet(rs,new String[][] {{"SYSCOLUMNS"}});
-      ps = conn.prepareStatement("SELECT TABLENAME FROM SYS.SYSTABLES WHERE " +
+      ps = prepareStatement("SELECT TABLENAME FROM SYS.SYSTABLES WHERE " +
 		" RTRIM(?) = TABLENAME");
       ps.setString(1, "SYSCOLUMNS  ");
       rs = ps.executeQuery();
@@ -260,18 +259,14 @@
 
       //Since all schemas (ie user and system) have the same collation, the 
       //following test won't fail.
-      ps = conn.prepareStatement("SELECT COUNT(*) FROM CUSTOMER WHERE " + 
+      ps = prepareStatement("SELECT COUNT(*) FROM CUSTOMER WHERE " + 
       		" ? IN (SELECT TABLENAME FROM SYS.SYSTABLES)");
       ps.setString(1, "SYSCOLUMNS");
       rs = ps.executeQuery();
       JDBC.assertFullResultSet(rs,new String[][] {{"7"}});
       //End of parameter testing
       
-      conn.commit();
-
-      dropTable(s);
       s.close();
-      conn.close();
       }
       
   /**
@@ -279,16 +274,9 @@
    * @throws SQLException
    */
 public void testPolishCollation() throws SQLException {
-      DataSource ds = JDBCDataSource.getDataSourceLogical("poldb");
-      JDBCDataSource.setBeanProperty(ds, "connectionAttributes", 
-                  "create=true;territory=pl;collation=TERRITORY_BASED");
 
-      
-      Connection conn = ds.getConnection();
-      conn.setAutoCommit(false);
-      PreparedStatement ps;
-      ResultSet rs;
-      Statement s = conn.createStatement();
+      getConnection().setAutoCommit(false);
+      Statement s = createStatement();
       
       setUpTable(s);
 
@@ -341,11 +329,7 @@
       		new String[][] {{"aacorn"}});   
 
       commonTestingForTerritoryBasedDB(s);
-
-      conn.commit();
-      dropTable(s);
-      conn.close();
-      
+    
       }    
   
 
@@ -355,16 +339,10 @@
    * @throws SQLException
    */
 public void testNorwayCollation() throws SQLException {
-      DataSource ds = JDBCDataSource.getDataSourceLogical("nordb");
-      JDBCDataSource.setBeanProperty(ds, "connectionAttributes", 
-                  "create=true;territory=no;collation=TERRITORY_BASED");
 
-      
-      Connection conn = ds.getConnection();
-      conn.setAutoCommit(false);
-      Statement s = conn.createStatement();
-      PreparedStatement ps;
-      ResultSet rs;
+      getConnection().setAutoCommit(false);
+      Statement s = createStatement();
+
       setUpTable(s);
 
       //The collation should be TERRITORY_BASED for this database
@@ -414,11 +392,8 @@
 
       commonTestingForTerritoryBasedDB(s);
 
-      conn.commit();
-
-      dropTable(s);
       s.close();
-      conn.close();
+
       }
   
 
@@ -428,15 +403,9 @@
   * @throws SQLException
   */
 public void testEnglishCollation() throws SQLException {
-      DataSource ds = JDBCDataSource.getDataSourceLogical("endb");
-      JDBCDataSource.setBeanProperty(ds, "connectionAttributes", 
-                  "create=true;territory=en;collation=TERRITORY_BASED");
-      
-      Connection conn = ds.getConnection();
-      conn.setAutoCommit(false);
-      Statement s = conn.createStatement();
-      PreparedStatement ps;
-      ResultSet rs;
+
+      getConnection().setAutoCommit(false);
+      Statement s = createStatement();
       setUpTable(s);
 
       //The collation should be TERRITORY_BASED for this database
@@ -489,11 +458,7 @@
 
       commonTestingForTerritoryBasedDB(s);
 
-      conn.commit();
-      
-      dropTable(s);
       s.close();
-      conn.close();
       }
 
 private void commonTestingForTerritoryBasedDB(Statement s) throws SQLException{
@@ -1006,13 +971,33 @@
    * is a server side operation.
    */
   public static Test suite() {
+      
+      TestSuite suite = new TestSuite("CollationTest");
 
-        Test test =  TestConfiguration.embeddedSuite(CollationTest.class);
-        test = TestConfiguration.additionalDatabaseDecorator(test, "defaultdb");
-        test = TestConfiguration.additionalDatabaseDecorator(test, "endb");
-        test = TestConfiguration.additionalDatabaseDecorator(test, "nordb");
-        test = TestConfiguration.additionalDatabaseDecorator(test, "poldb");
-        return test;
+        suite.addTest(new CleanDatabaseTestSetup(
+                new CollationTest("testDefaultCollation")));
+        suite.addTest(collatedSuite("en", "testEnglishCollation"));
+        suite.addTest(collatedSuite("no", "testNorwayCollation"));
+        suite.addTest(collatedSuite("pl", "testPolishCollation"));
+        return suite;
     }
+  
+  /**
+   * Return a suite that uses a single use database with
+   * a primary fixture from this test plus potentially other
+   * fixtures.
+   * @param locale Locale to use for the database
+   * @param baseFixture Base fixture from this test.
+   * @return
+   */
+  private static Test collatedSuite(String locale, String baseFixture)
+  {
+      TestSuite suite = new TestSuite("CollationTest:territory="+locale);
+      suite.addTest(new CollationTest(baseFixture));
+      
+      // DERBY-2986 - DMD.getTables() fails
+      // suite.addTest(DatabaseMetaDataTest.suite());
+      return Decorator.territoryCollatedDatabase(suite, locale);
+  }
 
 }

Modified: db/derby/code/branches/10.3/java/testing/org/apache/derbyTesting/junit/Decorator.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.3/java/testing/org/apache/derbyTesting/junit/Decorator.java?view=diff&rev=553598&r1=553597&r2=553598
==============================================================================
--- db/derby/code/branches/10.3/java/testing/org/apache/derbyTesting/junit/Decorator.java
(original)
+++ db/derby/code/branches/10.3/java/testing/org/apache/derbyTesting/junit/Decorator.java
Thu Jul  5 11:22:33 2007
@@ -108,29 +108,14 @@
      */
     public static Test encryptedDatabase(Test test, final String algorithm)
     {
-        test = new BaseTestSetup(test) {
-            
-            /**
-             * Create an encrypted database using a
-             * JDBC data source.
-             */
-            protected void setUp() throws SQLException
-            {
-                String bootPhrase = getBootPhrase(64);
-                DataSource ds = JDBCDataSource.getDataSource();
-                        
-                JDBCDataSource.setBeanProperty(ds,
-                        "createDatabase", "create");
-                JDBCDataSource.setBeanProperty(ds,
-                        "connectionAttributes",
-                        "dataEncryption=true;bootPassword=" + bootPhrase +
-                        ";encryptionAlgorithm=" + algorithm);
-                
-                ds.getConnection().close();
-            }
-        };
+        String bootPhrase = getBootPhrase(64);
+        
+        String attributes =
+            "dataEncryption=true;bootPassword=" + bootPhrase +
+             ";encryptionAlgorithm=" + algorithm;
+
+        return attributesDatabase(attributes, test);
         
-        return TestConfiguration.singleUseDatabaseDecorator(test);
     }
     
     private static String getBootPhrase(int length)
@@ -147,5 +132,56 @@
         }
         
         return new String(bp);
+    }
+    
+    /**
+     * Decorate a set of tests to use an single
+     * use database with TERRITORY_BASED collation
+     * set to the passed in locale. Database is created
+     * on by the setUp method of the decorator.
+     */
+    public static Test territoryCollatedDatabase(Test test, final String locale)
+    {
+        
+        String attributes = "collation=TERRITORY_BASED;territory=" + locale;
+        
+        return attributesDatabase(attributes, test);
+    }
+    
+    /**
+     * Decorate a test (or suite of tests) to use a single use database
+     * as the default database. The database is created by the setUp
+     * method of the decorator. The database will be created using
+     * a JDBC data source with createDatabase set to create and
+     * connectionAttributes set to the passed in attributes.
+     * 
+     * 
+     * @param attributes Value to set connectionAttributes to when creating
+     * the database.
+     * @param test Test to decorate
+     * @return Decorated test
+     */
+    private static Test attributesDatabase(final String attributes, Test test)
+    {
+        test = new BaseTestSetup(test) {
+            
+            /**
+             * Create a  database
+             * using a JDBC data source with connectionAttributes set.
+             */
+            protected void setUp() throws SQLException
+            {
+                DataSource ds = JDBCDataSource.getDataSource();
+                               
+                JDBCDataSource.setBeanProperty(ds,
+                        "createDatabase", "create");
+                JDBCDataSource.setBeanProperty(ds,
+                        "connectionAttributes", attributes);
+                                
+                ds.getConnection().close();
+            }
+        };
+        
+        return TestConfiguration.singleUseDatabaseDecorator(test);
     }
 }

Modified: db/derby/code/branches/10.3/java/testing/org/apache/derbyTesting/junit/JDBC.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.3/java/testing/org/apache/derbyTesting/junit/JDBC.java?view=diff&rev=553598&r1=553597&r2=553598
==============================================================================
--- db/derby/code/branches/10.3/java/testing/org/apache/derbyTesting/junit/JDBC.java (original)
+++ db/derby/code/branches/10.3/java/testing/org/apache/derbyTesting/junit/JDBC.java Thu Jul
 5 11:22:33 2007
@@ -207,10 +207,12 @@
 		Statement s = dmd.getConnection().createStatement();
         
         // Functions - not supported by JDBC meta data until JDBC 4
+        // Need to use the CHAR() function on A.ALIASTYPE
+        // so that the compare will work in any schema.
         PreparedStatement psf = conn.prepareStatement(
                 "SELECT ALIAS FROM SYS.SYSALIASES A, SYS.SYSSCHEMAS S" +
                 " WHERE A.SCHEMAID = S.SCHEMAID " +
-                " AND A.ALIASTYPE = 'F' " +
+                " AND CHAR(A.ALIASTYPE) = 'F' " +
                 " AND S.SCHEMANAME = ?");
         psf.setString(1, schema);
         ResultSet rs = psf.executeQuery();



Mime
View raw message