db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mi...@apache.org
Subject svn commit: r541339 - in /db/derby/code/trunk/java: engine/org/apache/derby/impl/store/access/btree/ testing/org/apache/derbyTesting/functionTests/tests/lang/
Date Thu, 24 May 2007 15:51:50 GMT
Author: mikem
Date: Thu May 24 08:51:49 2007
New Revision: 541339

URL: http://svn.apache.org/viewvc?view=rev&rev=541339
Log:
DERBY-2537 (partial)

Some more test cases and adding CollationTest2 junit test to nightly suite.


Modified:
    db/derby/code/trunk/java/engine/org/apache/derby/impl/store/access/btree/OpenBTree.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/CollationTest2.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/_Suite.java

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/store/access/btree/OpenBTree.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/store/access/btree/OpenBTree.java?view=diff&rev=541339&r1=541338&r2=541339
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/store/access/btree/OpenBTree.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/store/access/btree/OpenBTree.java
Thu May 24 08:51:49 2007
@@ -520,12 +520,10 @@
             DataValueDescriptor[] template = 
                 this.init_conglomerate.createTemplate(getRawTran());
 
-            // RESOLVE - could just compare format id's rather than allocate
-            // objects.
-
             for (int i = 0; i < row.length; i++)
             {
-                // RESOLVE (mikem) - use format id's for more efficient test.
+                // Compare class's rather than format id's to pick up 
+                // different problems with wrong collation implementation.
 				if (!row[i].getClass().equals(template[i].getClass()))
                 {
                     SanityManager.THROWASSERT(

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/CollationTest2.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/CollationTest2.java?view=diff&rev=541339&r1=541338&r2=541339
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/CollationTest2.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/CollationTest2.java
Thu May 24 08:51:49 2007
@@ -259,7 +259,6 @@
             JDBC.assertFullResultSet(rs,expectedResult);
 
         s.close();
-        conn.commit();
     }
 
     private void checkOneParamQuery(
@@ -428,6 +427,89 @@
         }
     }
 
+    /**
+     * Check simple boolean compare of string constant to column value.
+     * <p>
+     * Check <, <=, =, >=, > of constant to column, ie. of the form
+     *     select * from table where col boolean constant
+     *
+     *
+     * @throws SQLException
+     **/
+    private void checkTwoPersistentCompare(
+    Connection  conn,
+    int[]       expected_order)
+        throws SQLException
+    {
+        Statement s  = conn.createStatement();
+
+        conn.commit();
+        s.execute(
+            "ALTER TABLE CUSTOMER ADD COLUMN TWO_CHECK_CHAR CHAR(40)");
+        s.execute(
+            "ALTER TABLE CUSTOMER ADD COLUMN TWO_CHECK_VARCHAR VARCHAR(400)");
+
+        // Set CHAR field to be third item im expected order array
+        PreparedStatement   ps = 
+            conn.prepareStatement("UPDATE CUSTOMER SET TWO_CHECK_CHAR = ?"); 
+        ps.setString(1, NAMES[expected_order[3]]);
+        ps.executeUpdate();
+
+        // Set VARCHAR field to be third item im expected order array
+        ps = 
+            conn.prepareStatement("UPDATE CUSTOMER SET TWO_CHECK_VARCHAR = ?"); 
+
+        ps.setString(1, NAMES[expected_order[3]]);
+        ps.executeUpdate();
+
+        // check persistent compared to persistent - VARCHAR TO CHAR, 
+        // should return rows bigger than 3rd in expected order.
+        checkLangBasedQuery(
+            conn, 
+            "SELECT ID, NAME FROM CUSTOMER WHERE NAME > TWO_CHECK_CHAR ORDER BY NAME",
+            full_row_set(
+                expected_order,
+                4, 
+                expected_order.length - 1,
+                true));
+
+        // check persistent compared to persistent - CHAR TO VARCHAR, 
+        // should return rows bigger than 3rd in expected order.
+        checkLangBasedQuery(
+            conn, 
+            "SELECT ID, NAME FROM CUSTOMER WHERE TWO_CHECK_CHAR < NAME ORDER BY NAME",
+            full_row_set(
+                expected_order,
+                4, 
+                expected_order.length - 1,
+                true));
+
+        // check persistent compared to persistent - VARCHAR TO VARCHAR, 
+        // should return rows bigger than 3rd in expected order.
+        checkLangBasedQuery(
+            conn, 
+            "SELECT ID, NAME FROM CUSTOMER WHERE NAME > TWO_CHECK_VARCHAR ORDER BY NAME",
+            full_row_set(
+                expected_order,
+                4, 
+                expected_order.length - 1,
+                true));
+
+        // check persistent compared to persistent - CHAR TO CHAR, 
+        // should return rows bigger than 3rd in expected order.
+        checkLangBasedQuery(
+            conn, 
+            "SELECT ID, NAME FROM CUSTOMER WHERE D3 > TWO_CHECK_CHAR ORDER BY NAME",
+            full_row_set(
+                expected_order,
+                4, 
+                expected_order.length - 1,
+                true));
+
+        // put back data the way it was on entry to test.
+        conn.rollback();
+    }
+
 
     private void setUpTable(Connection conn) throws SQLException 
     {
@@ -435,7 +517,7 @@
         s.execute(
             "CREATE TABLE CUSTOMER(" +
                 "D1 CHAR(200), D2 CHAR(200), D3 CHAR(200), D4 INT, " + 
-                "ID INT, NAME VARCHAR(40), NAME2 CHAR(40))");
+                "ID INT, NAME VARCHAR(40), NAME2 VARCHAR(40))");
 
         conn.setAutoCommit(false);
         PreparedStatement ps = 
@@ -514,6 +596,9 @@
         // Check <, <=, =, >=, > operators on constant vs. column
         checkSimpleCompare(conn, EXPECTED_NAME_ORDER[db_index]);
 
+        // Check compare of 2 persistent values, using join
+        checkTwoPersistentCompare(conn, EXPECTED_NAME_ORDER[db_index]);
+
         if (create_idx_qry != null)
             s.execute("DROP INDEX " + idx_name);
 
@@ -534,6 +619,7 @@
     {
         Statement s = conn.createStatement();
 
+        setUpTable(conn);
         conn.commit();
 
         s.execute("CREATE INDEX IDX1 ON CUSTOMER (NAME)");
@@ -566,6 +652,7 @@
 
         runQueries(conn, db_index, null, null);
 
+        dropTable(conn);
         conn.commit();
     }
 
@@ -586,6 +673,7 @@
     {
         Statement s = conn.createStatement();
 
+        setUpTable(conn);
         conn.commit();
 
         s.execute("ALTER TABLE CUSTOMER DROP COLUMN D1");
@@ -596,6 +684,7 @@
         runQueries(conn, db_index, null, null);
         conn.rollback();
 
+        dropTable(conn);
         conn.commit();
     }
 
@@ -616,6 +705,8 @@
     {
         Statement s = conn.createStatement();
 
+        setUpTable(conn);
+
         conn.commit();
 
         s.execute("ALTER TABLE CUSTOMER DROP COLUMN NAME");
@@ -625,7 +716,8 @@
 
         s.execute("CREATE INDEX IDX1 ON CUSTOMER (NAME)");
         runQueries(conn, db_index, null, null);
-        conn.rollback();
+
+        dropTable(conn);
 
         conn.commit();
     }
@@ -661,6 +753,7 @@
 
         setUpTable(conn);
 
+
         // run tests against base table no index, exercise heap path
         // Tests the following:
         // T0: Heap based compare using predicate pushing
@@ -694,13 +787,20 @@
             conn, db_index, 
             "CREATE UNIQUE INDEX IDX ON CUSTOMER (NAME, ID)", "IDX");
 
-        runAlterTableCompress(conn, db_index);
+        dropTable(conn);
+
+        // the following tests mess with column values and ddl, so they
+        // are going to drop and recreate the small test data table.
 
         runAlterTableAddColumn(conn, db_index);
 
+        runAlterTableCompress(conn, db_index);
+
+        /*
+        TODO -MIKEM, this test does not work yet.
         runAlterTableDropColumn(conn, db_index);
+        */
 
-        dropTable(conn);
 
         conn.commit();
         conn.close();

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/_Suite.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/_Suite.java?view=diff&rev=541339&r1=541338&r2=541339
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/_Suite.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/_Suite.java
Thu May 24 08:51:49 2007
@@ -100,6 +100,7 @@
         suite.addTest(ProcedureInTriggerTest.suite());
 	    suite.addTest(ForUpdateTest.suite());
         suite.addTest(CollationTest.suite());
+        suite.addTest(CollationTest2.suite());
         suite.addTest(ScrollCursors1Test.suite());
         suite.addTest(SimpleTest.suite());
         suite.addTest(GrantRevokeDDLTest.suite());



Mime
View raw message