Skip to content

Commit

Permalink
test maybe
Browse files Browse the repository at this point in the history
Signed-off-by: Weizhen Wang <[email protected]>
  • Loading branch information
hawkingrei committed Jul 16, 2024
1 parent 1c8c067 commit 37e7209
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 12 deletions.
4 changes: 0 additions & 4 deletions pkg/executor/analyze.go
Original file line number Diff line number Diff line change
Expand Up @@ -469,10 +469,6 @@ func (e *AnalyzeExec) handleResultsErrorWithConcurrency(ctx context.Context, sta
panicCnt := 0
var err error
for panicCnt < statsConcurrency {
if err := e.Ctx().GetSessionVars().SQLKiller.HandleSignal(); err != nil {
close(saveResultsCh)
return err
}
results, ok := <-resultsCh
if !ok {
break
Expand Down
7 changes: 6 additions & 1 deletion pkg/planner/core/exhaust_physical_plans.go
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,9 @@ func GetMergeJoin(p *LogicalJoin, prop *property.PhysicalProperty, schema *expre
p.SCtx().GetSessionVars().StmtCtx.SetHintWarning(
"Some MERGE_JOIN and NO_MERGE_JOIN hints conflict, NO_MERGE_JOIN is ignored")
}

if !p.SCtx().GetSessionVars().InRestrictedSQL {
fmt.Println("check here")
}
// If TiDB_SMJ hint is existed, it should consider enforce merge join,
// because we can't trust lhsChildProperty completely.
if (p.PreferJoinType&h.PreferMergeJoin) > 0 ||
Expand Down Expand Up @@ -2437,6 +2439,9 @@ func (p *LogicalJoin) ExhaustPhysicalPlans(prop *property.PhysicalProperty) ([]b
}

if !p.isNAAJ() {
if !p.SCtx().GetSessionVars().InRestrictedSQL {
fmt.Println("wwz")
}
logutil.BgLogger().Info("fuckfuck")
// naaj refuse merge join and index join.
mergeJoins := GetMergeJoin(p, prop, p.Schema(), p.StatsInfo(), p.Children()[0].StatsInfo(), p.Children()[1].StatsInfo())
Expand Down
26 changes: 19 additions & 7 deletions pkg/planner/core/find_best_task.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,13 @@ func enumeratePhysicalPlans4Task(
for _, pp := range physicalPlans {
timeStampNow := p.GetLogicalTS4TaskMap()
savedPlanID := p.SCtx().GetSessionVars().PlanID.Load()

if !p.SCtx().GetSessionVars().InRestrictedSQL {
if len(childTasks) == 1 && childTasks[0] == nil {
logutil.BgLogger().Info("before fuck enumeratePhysicalPlans4Task", zap.Int("len child task", len(childTasks)))
} else {
logutil.BgLogger().Info("before fuck enumeratePhysicalPlans4Task ok", zap.Int("len child task", len(childTasks)))
}
}
childTasks, curCntPlan, childCnts, err = iteration(p, pp, childTasks, childCnts, prop, opt)
if err != nil {
return nil, 0, err
Expand All @@ -200,11 +206,9 @@ func enumeratePhysicalPlans4Task(
continue
}
if !p.SCtx().GetSessionVars().InRestrictedSQL {
var bug bool
if len(childTasks) == 1 && childTasks[0] == nil {
bug = true
logutil.BgLogger().Info("fuck enumeratePhysicalPlans4Task", zap.Int("len child task", len(childTasks)))
}
logutil.BgLogger().Info("fuck enumeratePhysicalPlans4Task", zap.Int("len child task", len(childTasks)), zap.Bool("bug", bug))
}
// If the target plan can be found in this physicalPlan(pp), rebuild childTasks to build the corresponding combination.
if planCounter.IsForce() && int64(*planCounter) <= curCntPlan {
Expand Down Expand Up @@ -290,19 +294,24 @@ func iteratePhysicalPlan4BaseLogical(
if !p.SCtx().GetSessionVars().InRestrictedSQL {
logutil.BgLogger().Info("fuck child", zap.String("child.ExplainInfo()", child.ExplainInfo()))
}

if _, ok := child.(*LogicalCTETable); ok {
fmt.Println("here")
}
childTask, cnt, err := child.FindBestTask(childProp, &PlanCounterDisabled, opt)
childCnts[j] = cnt
if err != nil {
return nil, 0, childCnts, err
}
if childTask == nil {
fmt.Println("???????")
}
curCntPlan = curCntPlan * cnt
if childTask != nil && childTask.Invalid() {
return nil, 0, childCnts, nil
}
childTasks = append(childTasks, childTask)
}
if len(childTasks) == 0 && childTasks[0] == nil {
if len(childTasks) == 1 && childTasks[0] == nil {
logutil.BgLogger().Info("iteratePhysicalPlan4BaseLogical meet bug")
}
// This check makes sure that there is no invalid child task.
Expand Down Expand Up @@ -556,6 +565,9 @@ func findBestTask(lp base.LogicalPlan, prop *property.PhysicalProperty, planCoun
var hintWorksWithProp bool
// Maybe the plan can satisfy the required property,
// so we try to get the task without the enforced sort first.
if !lp.SCtx().GetSessionVars().InRestrictedSQL {
fmt.Println("here")
}
plansFitsProp, hintWorksWithProp, err = p.Self().ExhaustPhysicalPlans(newProp)
if err != nil {
return nil, 0, err
Expand Down Expand Up @@ -2945,7 +2957,7 @@ func findBestTask4LogicalCTE(p *LogicalCTE, prop *property.PhysicalProperty, cou

func findBestTask4LogicalCTETable(p *LogicalCTETable, prop *property.PhysicalProperty, _ *base.PlanCounterTp, _ *optimizetrace.PhysicalOptimizeOp) (t base.Task, cntPlan int64, err error) {
if !prop.IsSortItemEmpty() {
return nil, 1, nil
return base.InvalidTask, 1, nil
}

pcteTable := PhysicalCTETable{IDForStorage: p.IDForStorage}.Init(p.SCtx(), p.StatsInfo())
Expand Down

0 comments on commit 37e7209

Please sign in to comment.