public class XplainStatisticsTest extends BaseJDBCTestCase
Modifier and Type | Class and Description |
---|---|
private static class |
XplainStatisticsTest.AbstractMTThread
Abstract class for a thread executing a database action (i.e. a query).
|
private static class |
XplainStatisticsTest.MTSimpleInvalidate
Thread for invalidating the COUNTRIES table in a loop.
|
private static class |
XplainStatisticsTest.MTSimpleSelect
Thread for selecting from the COUNTRIES table in a loop, with the XPLAIN-
functionality enabled.
|
Modifier and Type | Field and Description |
---|---|
private static java.lang.String[] |
tableNames |
private static long |
timeSuiteStarted |
DEFAULT_DB_DIR, DERBY_LOG, ERRORSTACKTRACEFILE
Constructor and Description |
---|
XplainStatisticsTest(java.lang.String name) |
Modifier and Type | Method and Description |
---|---|
private static void |
clearXplainOnlyMode(java.sql.Statement s) |
private int |
countNode(java.lang.String file)
Added by DERBY-4587
count the # of <node> elements
|
private static void |
createSchemaObjects(java.sql.Statement st)
Creates a variety of tables used by the various tests.
|
private static void |
disableXplainStyle(java.sql.Statement s,
boolean exportPlan) |
private void |
dumpResultSets(java.sql.Statement s) |
private void |
dumpStatements(java.sql.Statement s) |
private static void |
enableXplainOnlyMode(java.sql.Statement s) |
private static void |
enableXplainStyle(java.sql.Statement s) |
private static void |
enableXplainStyleWithTiming(java.sql.Statement s) |
private java.lang.Object |
getADocument(java.lang.String file)
Added by DERBY-4587
|
private java.lang.String |
getNodeAttribute(java.lang.String file,
java.lang.String attribute,
int node)
Added by DERBY-4587
gets attributes other than "name"
|
private java.lang.String |
getNodeName(java.lang.String file)
Added by DERBY-4587
gets the "name" attributes of all nodes separated by a "|"
|
private long |
getNonNegativeLong(java.sql.ResultSet rs,
java.lang.String cName) |
private java.sql.Timestamp |
getNonNullTimestamp(java.sql.ResultSet rs,
java.lang.String cName) |
private java.lang.String |
getStmtID(java.sql.Statement s)
Added by DERBY-4587
Returns the stmt_id for this particular statement
|
private java.lang.String[] |
getStmtIDArray(java.sql.Statement s,
int length)
Added by DERBY-4587
Returns the stmt_id for this particular statement
|
private java.lang.String |
getStmtIDByName(java.sql.Statement s,
java.lang.String sName) |
private static boolean |
hasTable(java.sql.Statement s,
java.lang.String schemaName,
java.lang.String tableName) |
private static java.lang.String |
invokePlanExporterTool(java.lang.String... args)
Invoke the PlanExporter tool.
|
private java.lang.String |
readStatement(java.lang.String file)
Added by DERBY-4587
gets the <statement> element from the XML
|
protected void |
setUp() |
static junit.framework.Test |
suite() |
void |
testAggregationResultSet()
A simple test of an AGGREGATION result set.
|
void |
testAlwaysEmptyResultSet()
Test that run-time statistics are recorded even if the query has a
predicate that always evaluates to false.
|
void |
testConstraintScan()
Verify XPLAIN style handling of a CONSTRAINT scan.
|
void |
testDDLCreateTable()
A simple test of capturing statistics for a DDL statement.
|
void |
testDeleteResultSet()
A simple test of an DELETE result set.
|
void |
testDistinctAggregateSortProps()
Verify XPLAIN style handling of DISTINCT_AGGREGATE sort properties.
|
void |
testGroupBySortProps()
Verify XPLAIN style handling of sort properties.
|
void |
testIndexScan()
Verify XPLAIN style handling of an INDEX scan.
|
void |
testInsertResultSet()
A simple test of an INSERT result set.
|
void |
testMaxFromIndex()
A simple test of the INDEX_KEY_OPT special situation.
|
void |
testOuterJoin()
A simple test of a LEFT OUTER JOIN and EMPTY_RIGHT_ROWS values.
|
void |
testPlanExporterEncoding()
Test that queries that contain non-ASCII characters are not garbled
by the plan exporter tool.
|
void |
testPlanExporterHandlingSpecialCharacters()
Test that queries that contain characters with a special meaning in
XML are not garbled by the plan exporter tool.
|
void |
testPlanExporterIllegalFileAccess() |
void |
testPlanExporterSchemaExistence() |
void |
testPlanExporterSpecialCharactersInSchema()
Verify that the plan exporter doesn't choke on special characters in
the name of the XPLAIN schema.
|
void |
testScanDeletedRows()
A simple test of a non-zero value for numDeletedRowsVisited.
|
void |
testScanPositions()
A simple test to verify that startPosition and stopPosition work.
|
void |
testSimpleQuery()
Verify that XPLAIN style captures basic statistics and timings.
|
void |
testSimpleQueryMultiWithInvalidation()
Tests that invalidation of a statement after compile-time doesn't result
in duplicate entries in the XPLAIN-table(s).
|
void |
testSimpleXplainOnly() |
void |
testSortResultSet()
A simple test of a SORT result set.
|
void |
testTableNotValid()
A simple test of table with the wrong 'shape'.
|
void |
testUnionQuery()
A simple test of a UNION query.
|
void |
testUpdateResultSet()
A simple test of an UPDATE result set.
|
void |
testXplainOnlyExecutePrepared() |
void |
testXplainOnlyPrepared() |
private void |
verifyNonNullDRDA_ID(java.sql.Statement s) |
private void |
verifySensibleResultSetTimings(java.sql.Statement s)
Make some basic first-order checks on the RESULTSET_TIMINGS rows.
|
private void |
verifySensibleStatementTimings(java.sql.Statement s)
Make some basic first-order checks on the STATEMENT_TIMINGS rows.
|
private static void |
verifyXplainUnset(java.sql.Statement s) |
assertCallError, assertCheckTable, assertCommitError, assertCompileError, assertEquals, assertEquals, assertEquals, assertEquivalentDataType, assertErrorCode, assertGetIntError, assertNextError, assertPreparedStatementError, assertResults, assertResults, assertSQLExceptionEquals, assertSQLState, assertSQLState, assertStatementError, assertStatementError, assertStatementError, assertStatementError, assertStatementErrorUnordered, assertTableRowCount, assertUpdateCount, assertUpdateCount, assertWarning, chattyPrepare, chattyPrepareCall, checkAllConsistency, checkEstimatedRowCount, closeStatement, commit, createStatement, createStatement, createStatement, dropTable, dropTable, dropView, dropView, dumpRs, dumpRs, emptyStatementCache, executeQuery, expectCompilationError, expectCompilationError, expectExecutionError, getClientTransactionID, getConnection, getDatabaseProperty, getLastSQLException, goodStatement, goodUpdate, initializeConnection, openConnection, openDefaultConnection, openDefaultConnection, openDefaultConnection, openUserConnection, prepareCall, prepareCall, prepareCall, prepareStatement, prepareStatement, prepareStatement, prepareStatement, prepareStatement, prepareStatement, rollback, runBare, runBareOverridable, runScript, runScript, runSQLCommands, setAutoCommit, tearDown, usingDB2Client, usingDerbyNetClient, usingEmbedded
alarm, assertDirectoryDeleted, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertExecJavaCmdAsExpected, assertLaunchedJUnitTestMethod, assertLaunchedJUnitTestMethod, assertSameNullness, assertSecurityManager, assertThrowableEquals, currentDirectory, execJavaCmd, execJavaCmd, execJavaCmd, fail, getClassVersionMajor, getEmmaJar, getFailureFolder, getFilesWith, getJavaExecutableName, getSystemProperty, getTestConfiguration, getTestResource, hasInterruptibleIO, isCVM, isIBMJVM, isJ9Platform, isJava5, isJava7, isPhoneME, isPlatform, isSunJVM, isWindowsPlatform, newAssertionFailedError, openTestResource, println, printStackTrace, readProcessOutput, removeDirectory, removeDirectory, removeFiles, removeSystemProperty, runsWithEmma, runsWithJaCoCo, setSystemErr, setSystemOut, setSystemProperty, sleep, sleepAtLeastOneTick, traceit, vmAtLeast
assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertFalse, assertFalse, assertNotNull, assertNotNull, assertNotSame, assertNotSame, assertNull, assertNull, assertSame, assertSame, assertTrue, assertTrue, countTestCases, createResult, fail, fail, failNotEquals, failNotSame, failSame, format, getName, run, run, runTest, setName, toString
private static long timeSuiteStarted
private static java.lang.String[] tableNames
public static junit.framework.Test suite()
protected void setUp() throws java.sql.SQLException
setUp
in class junit.framework.TestCase
java.sql.SQLException
private static void createSchemaObjects(java.sql.Statement st) throws java.sql.SQLException
java.sql.SQLException
private static boolean hasTable(java.sql.Statement s, java.lang.String schemaName, java.lang.String tableName) throws java.sql.SQLException
java.sql.SQLException
private static void enableXplainStyle(java.sql.Statement s) throws java.sql.SQLException
java.sql.SQLException
private static void enableXplainStyleWithTiming(java.sql.Statement s) throws java.sql.SQLException
java.sql.SQLException
private static void enableXplainOnlyMode(java.sql.Statement s) throws java.sql.SQLException
java.sql.SQLException
private static void clearXplainOnlyMode(java.sql.Statement s) throws java.sql.SQLException
java.sql.SQLException
private static void disableXplainStyle(java.sql.Statement s, boolean exportPlan) throws java.lang.Exception
s
- exportPlan
- whether or not the PlanExporter tool should be used
to export the plan of the recorded statementsjava.lang.Exception
private static void verifyXplainUnset(java.sql.Statement s) throws java.sql.SQLException
java.sql.SQLException
private void verifyNonNullDRDA_ID(java.sql.Statement s) throws java.sql.SQLException
java.sql.SQLException
private static java.lang.String invokePlanExporterTool(java.lang.String... args)
args
- the command line arguments to pass to the toolprivate void dumpResultSets(java.sql.Statement s) throws java.sql.SQLException
java.sql.SQLException
private void dumpStatements(java.sql.Statement s) throws java.sql.SQLException
java.sql.SQLException
private java.lang.String getStmtID(java.sql.Statement s) throws java.sql.SQLException
s
- Statementjava.sql.SQLException
private java.lang.String[] getStmtIDArray(java.sql.Statement s, int length) throws java.sql.SQLException
s
- Statementjava.sql.SQLException
private java.lang.Object getADocument(java.lang.String file) throws java.lang.Exception
file
- name of the XML file - without extensionjava.lang.Exception
private java.lang.String readStatement(java.lang.String file) throws java.lang.Exception
file
- XML filejava.lang.Exception
private int countNode(java.lang.String file) throws java.lang.Exception
file
- XML filejava.lang.Exception
private java.lang.String getNodeName(java.lang.String file) throws java.lang.Exception
file
- XML filejava.lang.Exception
private java.lang.String getNodeAttribute(java.lang.String file, java.lang.String attribute, int node) throws java.lang.Exception
file
- XML fileattribute
- name of the attributenode
- node which this attribute belongs tojava.lang.Exception
public void testPlanExporterSchemaExistence() throws java.lang.Exception
java.lang.Exception
public void testPlanExporterIllegalFileAccess() throws java.lang.Exception
java.lang.Exception
public void testPlanExporterSpecialCharactersInSchema() throws java.lang.Exception
java.lang.Exception
public void testSimpleQueryMultiWithInvalidation() throws java.lang.Exception
This test is timing-dependent, and may not trigger the bug under all circumstances.
See DERBY-4849.
java.lang.Exception
- if something goes wrongpublic void testSimpleQuery() throws java.lang.Exception
java.io.IOException
java.security.PrivilegedActionException
java.net.MalformedURLException
java.lang.Exception
private java.lang.String getStmtIDByName(java.sql.Statement s, java.lang.String sName) throws java.sql.SQLException
java.sql.SQLException
public void testSimpleXplainOnly() throws java.lang.Exception
java.lang.Exception
public void testXplainOnlyExecutePrepared() throws java.lang.Exception
java.lang.Exception
public void testXplainOnlyPrepared() throws java.lang.Exception
java.lang.Exception
private void verifySensibleStatementTimings(java.sql.Statement s) throws java.sql.SQLException
java.sql.SQLException
private void verifySensibleResultSetTimings(java.sql.Statement s) throws java.sql.SQLException
java.sql.SQLException
private long getNonNegativeLong(java.sql.ResultSet rs, java.lang.String cName) throws java.sql.SQLException
java.sql.SQLException
private java.sql.Timestamp getNonNullTimestamp(java.sql.ResultSet rs, java.lang.String cName) throws java.sql.SQLException
java.sql.SQLException
public void testIndexScan() throws java.lang.Exception
java.lang.Exception
public void testConstraintScan() throws java.lang.Exception
java.lang.Exception
public void testGroupBySortProps() throws java.lang.Exception
java.lang.Exception
public void testDistinctAggregateSortProps() throws java.lang.Exception
java.lang.Exception
public void testAggregationResultSet() throws java.lang.Exception
java.lang.Exception
public void testInsertResultSet() throws java.lang.Exception
java.lang.Exception
public void testUpdateResultSet() throws java.lang.Exception
java.lang.Exception
public void testDeleteResultSet() throws java.lang.Exception
java.lang.Exception
public void testSortResultSet() throws java.lang.Exception
java.lang.Exception
public void testUnionQuery() throws java.lang.Exception
java.lang.Exception
public void testDDLCreateTable() throws java.lang.Exception
java.lang.Exception
public void testMaxFromIndex() throws java.lang.Exception
java.lang.Exception
public void testOuterJoin() throws java.lang.Exception
java.lang.Exception
public void testScanPositions() throws java.lang.Exception
java.lang.Exception
public void testScanDeletedRows() throws java.lang.Exception
java.lang.Exception
public void testAlwaysEmptyResultSet() throws java.lang.Exception
java.lang.Exception
public void testTableNotValid() throws java.sql.SQLException
java.sql.SQLException
public void testPlanExporterEncoding() throws java.lang.Exception
java.lang.Exception
public void testPlanExporterHandlingSpecialCharacters() throws java.lang.Exception
java.lang.Exception
Apache Derby V10.13 Internals - Copyright © 2004,2016 The Apache Software Foundation. All Rights Reserved.