public class InListMultiProbeTest extends BaseJDBCTestCase
Modifier and Type | Class and Description |
---|---|
private static class |
InListMultiProbeTest.DataRow
Helper class: An instance of DataRow represents a single row
in DATA_TABLE.
|
(package private) class |
InListMultiProbeTest.LiteralsStrategy
"Literals" strategy, in which we execute a single query
with a single IN list having all literal values:
"...WHERE column IN ('literal1', ..., 'literalN')
|
(package private) class |
InListMultiProbeTest.MarkersStrategy
"Markers" strategy, in which we execute a single query with
a single IN list having all parameter markers:
"...
|
(package private) class |
InListMultiProbeTest.MixedIdsStrategy
"MixedIds" strategy, in which we execute as single query with
a single IN list having a mix of parameter markers and literal
values:
"...
|
(package private) class |
InListMultiProbeTest.QueryStrategy
Helper class.
|
Modifier and Type | Field and Description |
---|---|
protected java.lang.String[] |
allIds |
private static java.lang.String |
COLUMN_NAMES |
private static java.lang.String |
CREATE_DATA_TABLE |
private static java.lang.String |
CREATE_DERBY_6045_DATA_TABLE |
private static java.lang.String |
CREATE_DERBY_6045_DATA_TABLE2 |
private static java.lang.String |
DATA_TABLE |
private static java.lang.String[] |
DERBY_3603_Objects |
private static java.lang.String |
DERBY_6045_DATA_TABLE |
private static java.lang.String |
DERBY_6045_DATA_TABLE2 |
protected java.util.TreeMap<java.lang.String,java.util.List<InListMultiProbeTest.DataRow>> |
foreignIdToRowsMap |
private static java.lang.String |
GET_RUNTIME_STATS_QUERY |
private static int |
NUM_ROWS |
private static java.lang.String |
ORDER_BY |
private static java.lang.String |
RUNTIME_STATS_OFF_QUERY |
private static java.lang.String |
RUNTIME_STATS_ON_QUERY |
private static java.lang.String |
SELECT_ALL |
private static java.lang.String |
SELECT_ALL_WHERE_IN |
private static char[] |
uuid_chars |
DEFAULT_DB_DIR, DERBY_LOG, ERRORSTACKTRACEFILE
Constructor and Description |
---|
InListMultiProbeTest(java.lang.String name)
Public constructor required for running test as standalone JUnit.
|
Modifier and Type | Method and Description |
---|---|
private void |
assertResultsAndQueryPlan(java.sql.ResultSet rs,
java.lang.String[][] expRS,
java.sql.Statement st)
Assert that the received ResultSet matches the expected results,
and then make sure the optimizer actually chose to do multi-
probing.
|
private boolean |
checkMultiProbeQueryPlan(java.sql.ResultSet rStat,
int expRowCount)
Take the received ResultSet, which is assumed to hold runtime
statistics from the most recently-executed query, and verify
that the optimizer chose to do index multi-probing.
|
(package private) void |
deleteRows(boolean runUpdateStatistics,
boolean useParameterMarkers) |
private static java.lang.String |
genUUIDValue(java.util.Random random)
Generate a "fake" UUID value (i.e. the real database we work with has
UUIDs stored in CHAR(23) fields, so lets generate a random 23 character
string here).
|
void |
helperDerby6045(int numberOfRows,
boolean updateStatistics,
boolean useParameterMarkers) |
private static void |
insertNDataRows(java.sql.Connection conn,
int numRows,
java.util.Random random)
Insert the received number of rows into DATA_TABLE via
batch processing.
|
private void |
readAllRows(java.sql.Statement stmt)
Select all rows from DATA_TABLE and store them into an in-memory
map of "foreign_uuid -> rows".
|
private void |
runThreeQueries(int numOfWhiteSpace,
boolean useParameterMarkers) |
static junit.framework.Test |
suite()
Return a suite that runs the relevant multi-probing tests.
|
protected void |
tearDown()
Tear down this fixture, sub-classes should call
super.tearDown().
|
void |
testDerby3603() |
void |
testDerby4376()
Statements with {@code X IN (?
|
void |
testDerby6045() |
void |
testDerby6045DeleteTest() |
void |
testDerby6045InsertAllRows() |
void |
testDerby6045InsertAllRowsAdditionalUniqueIndex() |
void |
testDerby6045WithoutUpdateStatistics() |
void |
testDerby6045WithoutUpdateStatisticsAndWithParams() |
void |
testDerby6045WithUpdateStatistics() |
void |
testDerby6045WithUpdateStatisticsAndParams() |
void |
testDuplicateParameters()
Test case that exercises an otherwise untested code path through
MultiProbeTableScanResultSet.getNextProbeValue() , as suggested
in DERBY-4378. |
void |
testInListProbingWithOrderBy()
When IN list multi-probing occurs, the rows from the underlying
table are returned in the order of the values in the *IN list*,
instead of in the order of the rows as they are returned from
the index scan.
|
void |
testMultipleStartStopPreds()
Make sure that we get the correct results when the optimizer chooses
to do index multi-probing *and* there are multiple start/stop preds.
|
void |
testMultiProbing()
Executes three different types of queries ("strategies") repeatedly
with an increasing number of values in the IN list.
|
private void |
testOneSize(java.util.List<InListMultiProbeTest.QueryStrategy> strategies,
int cnt)
Iterates through the received list of query strategies and executes
a single SELECT statement with an IN list of size "cnt" for each
strategy.
|
void |
testProbePredPushedIntoSelectThenReverted()
Test the scenario in which Derby creates an IN-list probe
predicate, remaps its left operand to point to a nested
SELECT query, and then decides to *not* use the probe
predicate in the final plan.
|
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, 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, setUp, toString
private static final java.lang.String DATA_TABLE
private static final java.lang.String COLUMN_NAMES
private static final java.lang.String DERBY_6045_DATA_TABLE
private static final java.lang.String CREATE_DERBY_6045_DATA_TABLE
private static final java.lang.String DERBY_6045_DATA_TABLE2
private static final java.lang.String CREATE_DERBY_6045_DATA_TABLE2
private static final java.lang.String CREATE_DATA_TABLE
private static final java.lang.String SELECT_ALL
private static final java.lang.String SELECT_ALL_WHERE_IN
private static final java.lang.String ORDER_BY
private static final java.lang.String RUNTIME_STATS_ON_QUERY
private static final java.lang.String RUNTIME_STATS_OFF_QUERY
private static final java.lang.String GET_RUNTIME_STATS_QUERY
private static char[] uuid_chars
private static final int NUM_ROWS
protected java.lang.String[] allIds
protected java.util.TreeMap<java.lang.String,java.util.List<InListMultiProbeTest.DataRow>> foreignIdToRowsMap
private static java.lang.String[] DERBY_3603_Objects
public InListMultiProbeTest(java.lang.String name)
protected void tearDown() throws java.lang.Exception
BaseJDBCTestCase
tearDown
in class BaseJDBCTestCase
java.lang.Exception
public static junit.framework.Test suite()
public void testDerby6045DeleteTest() throws java.sql.SQLException
java.sql.SQLException
void deleteRows(boolean runUpdateStatistics, boolean useParameterMarkers) throws java.sql.SQLException
java.sql.SQLException
public void testMultiProbing() throws java.lang.Exception
java.lang.Exception
public void testMultipleStartStopPreds() throws java.lang.Exception
java.lang.Exception
public void testProbePredPushedIntoSelectThenReverted() throws java.lang.Exception
java.lang.Exception
public void testInListProbingWithOrderBy() throws java.sql.SQLException
java.sql.SQLException
public void testDerby6045WithUpdateStatistics() throws java.sql.SQLException
java.sql.SQLException
public void testDerby6045WithoutUpdateStatistics() throws java.sql.SQLException
java.sql.SQLException
public void testDerby6045WithUpdateStatisticsAndParams() throws java.sql.SQLException
java.sql.SQLException
public void testDerby6045WithoutUpdateStatisticsAndWithParams() throws java.sql.SQLException
java.sql.SQLException
public void helperDerby6045(int numberOfRows, boolean updateStatistics, boolean useParameterMarkers) throws java.sql.SQLException
java.sql.SQLException
public void testDerby6045() throws java.sql.SQLException
java.sql.SQLException
public void testDerby6045InsertAllRowsAdditionalUniqueIndex() throws java.sql.SQLException
java.sql.SQLException
public void testDerby6045InsertAllRows() throws java.sql.SQLException
java.sql.SQLException
private void runThreeQueries(int numOfWhiteSpace, boolean useParameterMarkers) throws java.sql.SQLException
java.sql.SQLException
public void testDerby3603() throws java.sql.SQLException
java.sql.SQLException
public void testDerby4376() throws java.sql.SQLException
X IN (?,?)
used to go into an infinite loop if
the first parameter was NULL and there was an index on X (DERBY-4376).java.sql.SQLException
public void testDuplicateParameters() throws java.sql.SQLException
MultiProbeTableScanResultSet.getNextProbeValue()
, as suggested
in DERBY-4378. The code path is taken if the highest value in the
IN list is duplicated. Since duplicate literals are removed during
compilation, the values must be non-literals for the path to be taken.java.sql.SQLException
private static void insertNDataRows(java.sql.Connection conn, int numRows, java.util.Random random) throws java.sql.SQLException
java.sql.SQLException
private void testOneSize(java.util.List<InListMultiProbeTest.QueryStrategy> strategies, int cnt) throws java.sql.SQLException
strategies
- Different query strategies to executecnt
- Size of the IN list with which to query.java.sql.SQLException
private void readAllRows(java.sql.Statement stmt) throws java.sql.SQLException
java.sql.SQLException
private static java.lang.String genUUIDValue(java.util.Random random)
private void assertResultsAndQueryPlan(java.sql.ResultSet rs, java.lang.String[][] expRS, java.sql.Statement st) throws java.sql.SQLException
java.sql.SQLException
private boolean checkMultiProbeQueryPlan(java.sql.ResultSet rStat, int expRowCount) throws java.sql.SQLException
java.sql.SQLException
Apache Derby V10.13 Internals - Copyright © 2004,2016 The Apache Software Foundation. All Rights Reserved.