From daf546f5e75fab8bd6145958238961792b8398ae Mon Sep 17 00:00:00 2001 From: Song Gao Date: Fri, 2 Sep 2022 11:36:24 +0800 Subject: [PATCH] planner: fix index merge hint case sensitive (#37534) close pingcap/tidb#37273 --- planner/core/stats.go | 2 +- planner/core/testdata/integration_suite_in.json | 1 + planner/core/testdata/integration_suite_out.json | 9 +++++++++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/planner/core/stats.go b/planner/core/stats.go index 7d92b6565c723..74081fe39ff31 100644 --- a/planner/core/stats.go +++ b/planner/core/stats.go @@ -622,7 +622,7 @@ func (ds *DataSource) isInIndexMergeHints(name string) bool { return true } for _, hintName := range hint.indexHint.IndexNames { - if name == hintName.String() { + if strings.EqualFold(strings.ToLower(name), strings.ToLower(hintName.String())) { return true } } diff --git a/planner/core/testdata/integration_suite_in.json b/planner/core/testdata/integration_suite_in.json index 78ec1c3131ab8..5facc127d1885 100644 --- a/planner/core/testdata/integration_suite_in.json +++ b/planner/core/testdata/integration_suite_in.json @@ -83,6 +83,7 @@ "name": "TestIndexMerge", "cases": [ "explain format = 'brief' select /*+ USE_INDEX_MERGE(t, a, b) */ * from t where a = 1 or b = 2", + "explain format = 'brief' select /*+ USE_INDEX_MERGE(t, A, B) */ * from t where a = 1 or b = 2", "explain format = 'brief' select /*+ USE_INDEX_MERGE(t, primary) */ * from t where 1 or t.c", "explain format = 'brief' select /*+ USE_INDEX_MERGE(t, a, b, c) */ * from t where 1 or t.a = 1 or t.b = 2" ] diff --git a/planner/core/testdata/integration_suite_out.json b/planner/core/testdata/integration_suite_out.json index ed929da9b5f34..2cb21337a32b6 100644 --- a/planner/core/testdata/integration_suite_out.json +++ b/planner/core/testdata/integration_suite_out.json @@ -344,6 +344,15 @@ "└─TableRowIDScan(Probe) 2.00 cop[tikv] table:t keep order:false, stats:pseudo" ] }, + { + "SQL": "explain format = 'brief' select /*+ USE_INDEX_MERGE(t, A, B) */ * from t where a = 1 or b = 2", + "Plan": [ + "IndexMerge 2.00 root ", + "├─IndexRangeScan(Build) 1.00 cop[tikv] table:t, index:a(a) range:[1,1], keep order:false, stats:pseudo", + "├─IndexRangeScan(Build) 1.00 cop[tikv] table:t, index:b(b) range:[2,2], keep order:false, stats:pseudo", + "└─TableRowIDScan(Probe) 2.00 cop[tikv] table:t keep order:false, stats:pseudo" + ] + }, { "SQL": "explain format = 'brief' select /*+ USE_INDEX_MERGE(t, primary) */ * from t where 1 or t.c", "Plan": [