public OInsertExecutionPlan createExecutionPlan(OCommandContext ctx, boolean enableProfiling) {
OInsertExecutionPlan result = new OInsertExecutionPlan(ctx);
if (targetIndex != null) {
result.chain(new InsertIntoIndexStep(targetIndex, insertBody, ctx, enableProfiling));
} else {
if (selectStatement != null) {
handleInsertSelect(result, this.selectStatement, ctx, enableProfiling);
} else {
handleCreateRecord(result, this.insertBody, ctx, enableProfiling);
}
handleTargetClass(result, targetClass, ctx, enableProfiling);
handleSetFields(result, insertBody, ctx, enableProfiling);
if (targetCluster != null) {
String name = targetCluster.getClusterName();
if (name == null) {
name = ctx.getDatabase().getClusterNameById(targetCluster.getClusterNumber());
}
handleSave(result, new OIdentifier(name), ctx, enableProfiling);
} else {
handleSave(result, targetClusterName, ctx, enableProfiling);
}
handleReturn(result, returnStatement, ctx, enableProfiling);
}
return result;
}