Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions pkg/executor/infoschema_reader_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -552,6 +552,15 @@ func TestTablesTable(t *testing.T) {
testkit.Rows())
tk.MustQuery(fmt.Sprintf("select table_schema, table_name, tidb_table_id from information_schema.tables where table_schema = 'db1' and table_name = 't1' and tidb_table_id in (%s,%s)", tableMetas[0].id, tableMetas[1].id)).Check(
testkit.Rows(toString(tableMetas[0])))

selectTables, err := strconv.Atoi(tk.MustQuery("select count(*) from information_schema.tables where upper(table_name) = 'T1'").Rows()[0][0].(string))
require.NoError(t, err)
totalTables, err := strconv.Atoi(tk.MustQuery("select count(*) from information_schema.tables").Rows()[0][0].(string))
require.NoError(t, err)
remainTables, err := strconv.Atoi(tk.MustQuery("select count(*) from information_schema.tables where upper(table_name) != 'T1'").Rows()[0][0].(string))
require.NoError(t, err)
require.Equal(t, 2, selectTables)
require.Equal(t, totalTables, remainTables+selectTables)
}

func TestColumnTable(t *testing.T) {
Expand Down
9 changes: 9 additions & 0 deletions pkg/planner/core/memtable_infoschema_extractor.go
Original file line number Diff line number Diff line change
Expand Up @@ -260,8 +260,17 @@ func (e *InfoSchemaBaseExtractor) filter(colName string, val string) bool {
return true
}
}

toLower := false
if e.extractLowerString != nil {
toLower = e.extractLowerString[colName]
}

predVals, ok := e.ColPredicates[colName]
if ok && len(predVals) > 0 {
if toLower {
return !predVals.Exist(strings.ToLower(val))
}
fn, ok := e.pushedDownFuncs[colName]
if ok {
return !predVals.Exist(fn(val))
Expand Down
8 changes: 8 additions & 0 deletions pkg/planner/core/memtable_predicate_extractor.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ import (
type extractHelper struct {
enableScalarPushDown bool
pushedDownFuncs map[string]func(string) string

// Store whether the extracted strings for a specific column are converted to lower case
extractLowerString map[string]bool
}

func (extractHelper) extractColInConsExpr(ctx base.PlanContext, extractCols map[int64]*types.FieldName, expr *expression.ScalarFunction) (string, []types.Datum) {
Expand Down Expand Up @@ -342,6 +345,11 @@ func (helper *extractHelper) extractCol(
break
}
}

if helper.extractLowerString == nil {
helper.extractLowerString = make(map[string]bool)
}
helper.extractLowerString[extractColName] = valueToLower
return
}

Expand Down