Skip to content

Adjust the log level and returned value when cacheableChecker check *ast.TableName nodes #46760

@zimulala

Description

@zimulala

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

  1. If calling TableByName encounters an error, we need to adjust the log level and supplement the error log. Because this error does not affect execution results.

func hasGeneratedCol(schema infoschema.InfoSchema, tn *ast.TableName) bool {
tb, err := schema.TableByName(tn.Schema, tn.Name)
if err != nil {
logutil.BgLogger().Error("Error occur in checking cacheable", zap.Error(err))
return false
}
for _, col := range tb.Cols() {
if col.IsGenerated() {
return true
}
}
return false
}
func getColType(schema infoschema.InfoSchema, tbl *ast.TableName, col *ast.ColumnName) (colType byte, found bool) {
if tbl == nil {
return 0, false
}
tb, err := schema.TableByName(tbl.Schema, tbl.Name)
if err != nil {
return 0, false
}
for _, c := range tb.Cols() {
if c.Name.L == col.Name.L {
return c.GetType(), true
}
}
return 0, false
}
func isTempTable(schema infoschema.InfoSchema, tn *ast.TableName) bool {
tb, err := schema.TableByName(tn.Schema, tn.Name)
if err != nil {
logutil.BgLogger().Error("Error occur in checking cacheable", zap.Error(err))
return false
}
if tb.Meta().TempTableType != model.TempTableNone {
return true
}
return false
}
func isPartitionTable(schema infoschema.InfoSchema, tn *ast.TableName) bool {
tb, err := schema.TableByName(tn.Schema, tn.Name)
if err != nil {
logutil.BgLogger().Error("Error occur in checking cacheable", zap.Error(err))
return false
}
if tb.Meta().GetPartitionInfo() != nil {
return true
}
return false
}

  1. Besides, if we encounter this error when calling TableByName, I think it makes sense to return true

2. What did you expect to see? (Required)

Change this log to a warning and add some info to check the cause of this error later.

3. What did you see instead (Required)

logutil.BgLogger().Error("Error occur in checking cacheable", zap.Error(err))

4. What is your TiDB version? (Required)

Release Version: v7.4.0-alpha-292-g5cbcc86e50
Edition: Community
Git Commit Hash: 5cbcc86

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions