@Override
public PostgresStatement finishGenerating(PostgresServerSession server, String sql, StatementNode stmt,
List<ParameterNode> params, int[] paramTypes) {
this.schema = compiler.getSchema();
ExplainPlanContext context = new ExplainPlanContext(compiler, new PostgresQueryContext(server, this.schema));
ExplainStatementNode explainStmt = (ExplainStatementNode)stmt;
StatementNode innerStmt = explainStmt.getStatement();
if (params == null)
params = new ParameterFinder().find(innerStmt);
Explainable explainable;
if (innerStmt instanceof CallStatementNode) {
explainable = PostgresCallStatementGenerator.explainable(server, (CallStatementNode)innerStmt, params, paramTypes);
}
else {
BasePlannable result = compiler.compile((DMLStatementNode)innerStmt, params, context);
explainable = result.getPlannable();
}
List<String> explain;
if (compiler instanceof PostgresJsonCompiler) {
JsonFormatter f = new JsonFormatter();
explain = Collections.singletonList(f.format(explainable.getExplainer(context.getExplainContext())));
}
else {
DefaultFormatter.LevelOfDetail detail;
switch (explainStmt.getDetail()) {
case BRIEF:
detail = DefaultFormatter.LevelOfDetail.BRIEF;
break;
default:
case NORMAL: