Skip to content

Commit

Permalink
[BugFix] fix enable_plan_analyzer session var when adding stmt to pla…
Browse files Browse the repository at this point in the history
…n advisor (#53392)

Signed-off-by: stephen <[email protected]>
  • Loading branch information
stephen-shelby authored Dec 2, 2024
1 parent 4a6b03b commit 1d478bd
Showing 1 changed file with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,11 @@ public static final class PlanAdvisorExecutorVisitor implements AstVisitor<ShowR

@Override
public ShowResultSet visitAddPlanAdvisorStatement(AddPlanAdvisorStmt stmt, ConnectContext context) {
boolean enablePlanAnalyzer = context.getSessionVariable().isEnablePlanAnalyzer();
try {
context.getSessionVariable().setEnablePlanAnalyzer(true);
if (!enablePlanAnalyzer) {
context.getSessionVariable().setEnablePlanAnalyzer(true);
}
StmtExecutor executor = new StmtExecutor(context, stmt.getQueryStmt());
executor.execute();
String result;
Expand All @@ -74,7 +77,7 @@ public ShowResultSet visitAddPlanAdvisorStatement(AddPlanAdvisorStmt stmt, Conne
throw new RuntimeException(e);
} finally {
context.getState().reset();
context.getSessionVariable().setEnablePlanAnalyzer(false);
context.getSessionVariable().setEnablePlanAnalyzer(enablePlanAnalyzer);
}
}

Expand Down

0 comments on commit 1d478bd

Please sign in to comment.