public class DisposableIndexStatistics
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
private java.sql.Connection |
con |
private java.lang.String |
fktbl |
private DerbyVersion |
oldVersion |
private java.lang.String |
pktbl |
private static int |
ROW_COUNT
A row count currently chosen at will.
|
private java.lang.String |
tbl |
Constructor and Description |
---|
DisposableIndexStatistics(DerbyVersion oldVersion,
java.sql.Connection con,
java.lang.String tableName)
Creates a new helper instance using the given connection and table.
|
Modifier and Type | Method and Description |
---|---|
void |
assertStatsCount(boolean orphaned_disposedOf,
boolean notneeded_disposedOf)
Asserts the number of statistics entries for all relevant tables.
|
void |
createAndPopulateTables()
Creates and populates the test tables.
|
private int |
getAllRelevantStats(java.util.List<IndexStatsUtil.IdxStats> list)
Fetches all relevant statistics.
|
static int |
getNumNotNeededDisposableStats()
Number of disposable statistics entries.
|
static int |
getNumOrphanedDisposableStats() |
static int |
getNumTotalPossibleStats()
Total number of possible statistics entries.
|
private IndexStatsUtil.IdxStats[] |
getStatArray(java.util.List<IndexStatsUtil.IdxStats> list)
Converts the list of statistics to an array.
|
java.lang.String[] |
getTableNames()
Returns the names of the tables used by this test.
|
static boolean |
hasDerby5681Bug(DerbyVersion oldVersion)
Tells if the old version is affected by the DERBY-5681 bug.
|
private void |
insertData(java.sql.Connection con) |
private static final int ROW_COUNT
Note that if being used for testing the automatic istat daemon, the number of rows must be sufficiently high to trigger statistics creation, and likewise for the deltas when adding more rows to trigger an update.
private final DerbyVersion oldVersion
private final java.sql.Connection con
private final java.lang.String tbl
private final java.lang.String fktbl
private final java.lang.String pktbl
public DisposableIndexStatistics(DerbyVersion oldVersion, java.sql.Connection con, java.lang.String tableName)
con
- connectiontableName
- base table namepublic void createAndPopulateTables() throws java.sql.SQLException
java.sql.SQLException
private void insertData(java.sql.Connection con) throws java.sql.SQLException
java.sql.SQLException
public java.lang.String[] getTableNames()
public void assertStatsCount(boolean orphaned_disposedOf, boolean notneeded_disposedOf) throws java.sql.SQLException
orphaned_disposedOf
- tells if the orphaned disposable statistics
entries are expected to have been removed at this pointnotneeded_disposedOf
- tells if the unneeded statistics (like
single column unique key indexes) are expected to have been
removed at this pointjava.sql.SQLException
private IndexStatsUtil.IdxStats[] getStatArray(java.util.List<IndexStatsUtil.IdxStats> list)
private int getAllRelevantStats(java.util.List<IndexStatsUtil.IdxStats> list) throws java.sql.SQLException
list
- list to append statistics to (may be null
)java.sql.SQLException
- if something goes wrongpublic static int getNumTotalPossibleStats()
This number includes orphaned and unnecessary statistics, and these entries are expected to be purged out when running with the current/ newest version of Derby.
public static int getNumNotNeededDisposableStats()
public static int getNumOrphanedDisposableStats()
public static boolean hasDerby5681Bug(DerbyVersion oldVersion)
The bug is that Derby fails to drop a statistics entry for a foreign key constraint, leaving an orphaned and outdated entry behind.
oldVersion
- the old derbyVersion used in the testtrue
if the old version has the bug.Apache Derby V10.13 Internals - Copyright © 2004,2016 The Apache Software Foundation. All Rights Reserved.