MCPcopy
hub / github.com/pingcap/tidb / TestMakeExprContextStatic

Function TestMakeExprContextStatic

pkg/expression/exprstatic/exprctx_test.go:164–202  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

162}
163
164func TestMakeExprContextStatic(t *testing.T) {
165 evalCtx := NewEvalContext()
166 planCacheTracker := contextutil.NewPlanCacheTracker(evalCtx.warnHandler)
167 obj := NewExprContext(
168 WithEvalCtx(evalCtx),
169 WithCharset("a", "b"),
170 WithDefaultCollationForUTF8MB4("c"),
171 WithBlockEncryptionMode("d"),
172 WithSysDateIsNow(true),
173 WithNoopFuncsMode(1),
174 WithRng(mathutil.NewWithSeed(12345678)),
175 WithPlanCacheTracker(&planCacheTracker),
176 WithColumnIDAllocator(exprctx.NewSimplePlanColumnIDAllocator(1)),
177 WithConnectionID(1),
178 WithWindowingUseHighPrecision(false),
179 WithGroupConcatMaxLen(1),
180 )
181
182 ignorePath := []string{
183 "$.exprCtxState.evalCtx**",
184 }
185 deeptest.AssertRecursivelyNotEqual(t, obj, NewExprContext(),
186 deeptest.WithIgnorePath(ignorePath),
187 deeptest.WithPointerComparePath([]string{
188 "$.exprCtxState.rng",
189 "$.exprCtxState.planCacheTracker",
190 }),
191 )
192
193 staticObj := MakeExprContextStatic(obj)
194 deeptest.AssertDeepClonedEqual(t, obj, staticObj,
195 deeptest.WithIgnorePath(ignorePath),
196 deeptest.WithPointerComparePath([]string{
197 "$.exprCtxState.rng",
198 "$.exprCtxState.planCacheTracker",
199 }))
200
201 require.NotSame(t, obj.GetEvalCtx(), staticObj.GetEvalCtx())
202}
203
204func TestExprCtxLoadSystemVars(t *testing.T) {
205 vars := []struct {

Callers

nothing calls this directly

Calls 15

GetEvalCtxMethod · 0.95
NewWithSeedFunction · 0.92
WithIgnorePathFunction · 0.92
WithPointerComparePathFunction · 0.92
AssertDeepClonedEqualFunction · 0.92
WithEvalCtxFunction · 0.85
WithCharsetFunction · 0.85
WithBlockEncryptionModeFunction · 0.85
WithSysDateIsNowFunction · 0.85

Tested by

no test coverage detected