ProcessorPlan result = null;
switch (command.getType()) {
case Command.TYPE_UPDATE_PROCEDURE:
CreateUpdateProcedureCommand cupc = (CreateUpdateProcedureCommand)command;
if (cupc.isUpdateProcedure()) {
result = planProcedure(command, metadata, idGenerator, capFinder, analysisRecord, context);
} else {
StoredProcedure c = (StoredProcedure)cupc.getUserCommand();
Object pid = cupc.getVirtualGroup().getMetadataID();
if (c != null) {
pid = c.getProcedureID();
}
String fullName = metadata.getFullName(pid);
fullName = "procedure cache:" + fullName; //$NON-NLS-1$
PreparedPlan pp = context.getPlan(fullName);
if (pp == null) {
Determinism determinismLevel = context.resetDeterminismLevel();
CommandContext clone = context.clone();
ProcessorPlan plan = planProcedure(command, metadata, idGenerator, capFinder, analysisRecord, clone);
//note that this is not a full prepared plan. It is not usable by user queries.
if (pid instanceof Procedure) {
clone.accessedPlanningObject(pid);
}
pp = new PreparedPlan();
pp.setPlan(plan, clone);
context.putPlan(fullName, pp, context.getDeterminismLevel());
context.setDeterminismLevel(determinismLevel);
}
result = pp.getPlan().clone();
for (Object id : pp.getAccessInfo().getObjectsAccessed()) {
context.accessedPlanningObject(id);
}
}
// propagate procedure parameters to the plan to allow runtime type checking
ProcedureContainer container = (ProcedureContainer)cupc.getUserCommand();
ProcedurePlan plan = (ProcedurePlan)result;
if (container != null) {
LinkedHashMap<ElementSymbol, Expression> params = container.getProcedureParameters();
if (container instanceof StoredProcedure) {
plan.setRequiresTransaction(container.getUpdateCount() > 0);