Skip to content

Commit caaf8c0

Browse files
committed
This is an automated cherry-pick of pingcap#61608
Signed-off-by: ti-chi-bot <[email protected]>
1 parent 1bce83c commit caaf8c0

File tree

3 files changed

+8
-0
lines changed

3 files changed

+8
-0
lines changed

pkg/planner/core/plan_cost_ver1.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import (
2929
"github.com/pingcap/tidb/pkg/planner/util/optimizetrace"
3030
"github.com/pingcap/tidb/pkg/sessionctx/variable"
3131
"github.com/pingcap/tidb/pkg/statistics"
32+
"github.com/pingcap/tidb/pkg/util/intest"
3233
"github.com/pingcap/tidb/pkg/util/paging"
3334
)
3435

@@ -87,6 +88,7 @@ func (p *PhysicalProjection) GetCost(count float64) float64 {
8788

8889
// GetPlanCostVer1 calculates the cost of the plan if it has not been calculated yet and returns the cost.
8990
func (p *PhysicalProjection) GetPlanCostVer1(taskType property.TaskType, option *optimizetrace.PlanCostOption) (float64, error) {
91+
intest.Assert(p.SCtx().GetSessionVars().CostModelVersion != 0)
9092
costFlag := option.CostFlag
9193
if p.PlanCostInit && !hasCostFlag(costFlag, costusage.CostFlagRecalculate) {
9294
return p.PlanCost, nil

pkg/sessionctx/variable/session.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2226,6 +2226,7 @@ func NewSessionVars(hctx HookContext) *SessionVars {
22262226
EnableRedactLog: DefTiDBRedactLog,
22272227
EnableWindowFunction: DefEnableWindowFunction,
22282228
OptOrderingIdxSelRatio: DefTiDBOptOrderingIdxSelRatio,
2229+
CostModelVersion: DefTiDBCostModelVer,
22292230
}
22302231
vars.status.Store(uint32(mysql.ServerStatusAutocommit))
22312232
vars.StmtCtx.ResourceGroupName = resourcegroup.DefaultResourceGroupName

pkg/util/mock/context.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -668,9 +668,14 @@ func newContext() *Context {
668668
vars.StmtCtx.MemTracker.AttachTo(vars.MemTracker)
669669
vars.StmtCtx.DiskTracker.AttachTo(vars.DiskTracker)
670670
vars.GlobalVarsAccessor = variable.NewMockGlobalAccessor()
671+
<<<<<<< HEAD
671672
vars.EnablePaging = variable.DefTiDBEnablePaging
672673
vars.MinPagingSize = variable.DefMinPagingSize
673674
vars.CostModelVersion = variable.DefTiDBCostModelVer
675+
=======
676+
vars.EnablePaging = vardef.DefTiDBEnablePaging
677+
vars.MinPagingSize = vardef.DefMinPagingSize
678+
>>>>>>> 1ef4c269cd7 (planner: set the default of the tidb_cost_model_version correctly (#61608))
674679
vars.EnableChunkRPC = true
675680
vars.DivPrecisionIncrement = variable.DefDivPrecisionIncrement
676681
if err := sctx.GetSessionVars().SetSystemVar(variable.MaxAllowedPacket, "67108864"); err != nil {

0 commit comments

Comments
 (0)