// hijack necessary internals
FarragoJdbcEngineConnection farragoConnection =
(FarragoJdbcEngineConnection) connection;
FarragoDbSession session =
(FarragoDbSession) farragoConnection.getSession();
final FarragoDefaultSessionPersonality personality =
(FarragoDefaultSessionPersonality) session.getPersonality();
// guarantee release of any resources we allocate on the way
FarragoCompoundAllocation allocations = new FarragoCompoundAllocation();
FarragoReposTxnContext reposTxn = repos.newTxnContext(true);
try {
reposTxn.beginReadTxn();
// create a private code cache: don't pollute the real
// database code cache
FarragoObjectCache objCache =
new FarragoObjectCache(
allocations,
0,
new FarragoLruVictimPolicy());
// FarragoPreparingStmt does most of the work for us
FarragoSessionStmtValidator stmtValidator =
session.newStmtValidator(
objCache, objCache);
allocations.addAllocation(stmtValidator);
FarragoPreparingStmt stmt =
(FarragoPreparingStmt) personality.newPreparingStmtForTesting(
explainQuery, stmtValidator);
initPlanner(stmt);
// add any additional rules needed in the planner