You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-commits@db.apache.org by kr...@apache.org on 2012/05/21 14:50:46 UTC
svn commit: r1341002 -
/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/UpdateStatisticsTest.java
Author: kristwaa
Date: Mon May 21 12:50:45 2012
New Revision: 1341002
URL: http://svn.apache.org/viewvc?rev=1341002&view=rev
Log:
DERBY-5681: When a foreign key constraint on a table is dropped, the associated statistics row for the conglomerate is not removed
Made test less sensitive to statistics created by other tests.
Patch file: derby-5681-3a-test.diff
Modified:
db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/UpdateStatisticsTest.java
Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/UpdateStatisticsTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/UpdateStatisticsTest.java?rev=1341002&r1=1341001&r2=1341002&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/UpdateStatisticsTest.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/UpdateStatisticsTest.java Mon May 21 12:50:45 2012
@@ -69,36 +69,43 @@ public class UpdateStatisticsTest extend
* SYSCS_DROP_STATISTICS and SYSCS_UPDATE_STATISTICS
*/
public void testIndexAndColumnNamedStatistics() throws SQLException {
+ String tbl = "T1";
// Helper object to obtain information about index statistics.
IndexStatsUtil stats = new IndexStatsUtil(openDefaultConnection());
Statement s = createStatement();
+ // Get the initial count of statistics in the database.
+ int initialStatsCount = stats.getStats().length;
+
//Notice the name of one of the columns is STATISTICS
s.executeUpdate("CREATE TABLE t1 (c11 int, statistics int not null)");
//Notice that the name of the index is STATISTICS which is same as
// one of the column names
s.executeUpdate("CREATE INDEX statistIcs ON t1(c11)");
s.executeUpdate("INSERT INTO t1 VALUES(1,1)");
- stats.assertNoStats();
+ stats.assertNoStatsTable(tbl);
//Drop the column named STATISTICS and make sure parser doesn't
// throw an error
s.executeUpdate("ALTER TABLE t1 DROP statistics");
//Should still be able to call update/drop statistics on index
// STATISTICS
s.executeUpdate("CALL SYSCS_UTIL.SYSCS_UPDATE_STATISTICS('APP','T1','STATISTICS')");
- stats.assertStats(1);
+ stats.assertTableStats(tbl, 1);
s.executeUpdate("CALL SYSCS_UTIL.SYSCS_DROP_STATISTICS('APP','T1','STATISTICS')");
- stats.assertNoStats();
+ stats.assertNoStatsTable(tbl);
//Add the column named STATISTICS back
s.executeUpdate("ALTER TABLE t1 ADD COLUMN statistics int");
- stats.assertNoStats();
+ stats.assertNoStatsTable(tbl);
//Update or drop statistics for index named STATISTICS. Note that there
// is also a column named STATISTICS in the table
s.executeUpdate("CALL SYSCS_UTIL.SYSCS_DROP_STATISTICS('APP','T1','STATISTICS')");
- stats.assertNoStats();
+ stats.assertNoStatsTable(tbl);
s.executeUpdate("CALL SYSCS_UTIL.SYSCS_UPDATE_STATISTICS('APP','T1','STATISTICS')");
- stats.assertStats(1);
+ stats.assertTableStats(tbl, 1);
s.executeUpdate("DROP TABLE t1");
+
+ // Check that we haven't created some other statistics as a side-effect.
+ assertEquals(initialStatsCount, stats.getStats().length);
}
/**
@@ -111,6 +118,7 @@ public class UpdateStatisticsTest extend
//Calls to update and drop statistics below should fail because
// table APP.T1 does not exist
+ dropTable("T1");
assertStatementError("42Y55", s,
"CALL SYSCS_UTIL.SYSCS_DROP_STATISTICS('APP','T1',null)");
assertStatementError("42Y55", s,