diff --git a/pkg/apiserver/slowquery/service.go b/pkg/apiserver/slowquery/service.go index 0a12411b1..e614336cb 100644 --- a/pkg/apiserver/slowquery/service.go +++ b/pkg/apiserver/slowquery/service.go @@ -109,13 +109,15 @@ func (s *Service) getDetails(c *gin.Context) { // See: https://github.com/pingcap/tidb-dashboard/issues/1515 if result.BinaryPlan != "" { // may failed but it's ok - result.BinaryPlanText, _ = utils.GenerateBinaryPlanText(db, result.BinaryPlan) + result.BinaryPlanText, err = utils.GenerateBinaryPlanText(db, result.BinaryPlan) // may failed but it's ok result.BinaryPlanJSON, _ = utils.GenerateBinaryPlanJSON(result.BinaryPlan) - // reduce response size - result.BinaryPlan = "" - result.Plan = "" + if err == nil { + // reduce response size + result.BinaryPlan = "" + result.Plan = "" + } } c.JSON(http.StatusOK, *result) diff --git a/pkg/apiserver/statement/service.go b/pkg/apiserver/statement/service.go index 64169b724..8f1a36044 100644 --- a/pkg/apiserver/statement/service.go +++ b/pkg/apiserver/statement/service.go @@ -237,13 +237,15 @@ func (s *Service) planDetailHandler(c *gin.Context) { if result.AggBinaryPlan != "" { // may failed but it's ok - result.BinaryPlanText, _ = utils.GenerateBinaryPlanText(db, result.AggBinaryPlan) + result.BinaryPlanText, err = utils.GenerateBinaryPlanText(db, result.AggBinaryPlan) // may failed but it's ok result.BinaryPlanJSON, _ = utils.GenerateBinaryPlanJSON(result.AggBinaryPlan) - // reduce response size - result.AggBinaryPlan = "" - result.AggPlan = "" + if err == nil { + // reduce response size + result.AggBinaryPlan = "" + result.AggPlan = "" + } } c.JSON(http.StatusOK, result) diff --git a/ui/packages/tidb-dashboard-lib/src/apps/SlowQuery/pages/Detail/index.tsx b/ui/packages/tidb-dashboard-lib/src/apps/SlowQuery/pages/Detail/index.tsx index 6636213c7..5bf1d8715 100644 --- a/ui/packages/tidb-dashboard-lib/src/apps/SlowQuery/pages/Detail/index.tsx +++ b/ui/packages/tidb-dashboard-lib/src/apps/SlowQuery/pages/Detail/index.tsx @@ -173,7 +173,7 @@ function DetailPage() { ) })()} - {(binaryPlanObj || !!data.plan) && ( + {(!!data.binary_plan_text || !!data.plan) && ( <> {t('slow_query.detail.plan.title')} diff --git a/ui/packages/tidb-dashboard-lib/src/apps/Statement/pages/Detail/PlanDetail.tsx b/ui/packages/tidb-dashboard-lib/src/apps/Statement/pages/Detail/PlanDetail.tsx index 0e9c47b62..bfce9df82 100644 --- a/ui/packages/tidb-dashboard-lib/src/apps/Statement/pages/Detail/PlanDetail.tsx +++ b/ui/packages/tidb-dashboard-lib/src/apps/Statement/pages/Detail/PlanDetail.tsx @@ -175,7 +175,7 @@ function PlanDetail({ query }: IPlanDetailProps) { ) : null} - {(binaryPlanObj || !!data.plan) && ( + {(!!data.binary_plan_text || !!data.plan) && ( <> {t('statement.pages.detail.desc.plans.execution.title')}