Skip to content

Commit 6659b61

Browse files
committed
fix
Signed-off-by: Weizhen Wang <[email protected]>
1 parent 38c6fa9 commit 6659b61

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

pkg/statistics/handle/syncload/BUILD.bazel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ go_library(
1414
"//pkg/parser/mysql",
1515
"//pkg/sessionctx",
1616
"//pkg/sessionctx/stmtctx",
17+
"//pkg/sessionctx/variable",
1718
"//pkg/statistics",
1819
"//pkg/statistics/handle/storage",
1920
"//pkg/statistics/handle/types",

pkg/statistics/handle/syncload/stats_syncload.go

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -307,11 +307,14 @@ func (s *statsSyncLoad) handleOneItemTask(task *statstypes.NeededItemTask) (err
307307
s.statsHandle.SPool().Destroy(se)
308308
}
309309
}()
310+
var skipTypes map[string]struct{}
310311
val, err := sctx.GetSessionVars().GlobalVarsAccessor.GetGlobalSysVar(variable.TiDBAnalyzeSkipColumnTypes)
311312
if err != nil {
312313
logutil.BgLogger().Warn("failed to get global variable", zap.Error(err))
314+
} else {
315+
skipTypes = variable.ParseAnalyzeSkipColumnTypes(val)
313316
}
314-
skipTypes := variable.ParseAnalyzeSkipColumnTypes(val)
317+
315318
item := task.Item.TableItemID
316319
statsTbl, ok := s.statsHandle.Get(item.TableID)
317320

@@ -348,10 +351,13 @@ func (s *statsSyncLoad) handleOneItemTask(task *statstypes.NeededItemTask) (err
348351
// so we have to get the column info from the domain.
349352
wrapper.colInfo = tblInfo.GetColumnByID(item.ID)
350353
}
351-
_, skip := skipTypes[types.TypeToStr(wrapper.colInfo.FieldType.GetType(), wrapper.colInfo.FieldType.GetCharset())]
352-
if skip {
353-
return nil
354+
if skipTypes != nil {
355+
_, skip := skipTypes[types.TypeToStr(wrapper.colInfo.FieldType.GetType(), wrapper.colInfo.FieldType.GetCharset())]
356+
if skip {
357+
return nil
358+
}
354359
}
360+
355361
// If this column is not analyzed yet and we don't have it in memory.
356362
// We create a fake one for the pseudo estimation.
357363
// Otherwise, it will trigger the sync/async load again, even if the column has not been analyzed.

0 commit comments

Comments
 (0)