Skip to content

Commit 54d64c6

Browse files
hawkingreiti-chi-bot
authored andcommitted
This is an automated cherry-pick of pingcap#61608
Signed-off-by: ti-chi-bot <[email protected]>
1 parent f43a133 commit 54d64c6

File tree

3 files changed

+14
-0
lines changed

3 files changed

+14
-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: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2186,9 +2186,16 @@ func NewSessionVars(hctx HookContext) *SessionVars {
21862186
TiFlashComputeDispatchPolicy: tiflashcompute.DispatchPolicyConsistentHash,
21872187
ResourceGroupName: resourcegroup.DefaultResourceGroupName,
21882188
DefaultCollationForUTF8MB4: mysql.DefaultCollationName,
2189+
<<<<<<< HEAD
21892190
GroupConcatMaxLen: DefGroupConcatMaxLen,
21902191
EnableRedactLog: DefTiDBRedactLog,
21912192
EnableWindowFunction: DefEnableWindowFunction,
2193+
=======
2194+
GroupConcatMaxLen: vardef.DefGroupConcatMaxLen,
2195+
EnableRedactLog: vardef.DefTiDBRedactLog,
2196+
EnableWindowFunction: vardef.DefEnableWindowFunction,
2197+
CostModelVersion: vardef.DefTiDBCostModelVer,
2198+
>>>>>>> 1ef4c269cd7 (planner: set the default of the tidb_cost_model_version correctly (#61608))
21922199
}
21932200
vars.status.Store(uint32(mysql.ServerStatusAutocommit))
21942201
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)