@@ -154,6 +154,44 @@ func TestNormalizedPlan(t *testing.T) {
154
154
}
155
155
}
156
156
157
+ func TestIssue47634 (t * testing.T ) {
158
+ store := testkit .CreateMockStore (t )
159
+ tk := testkit .NewTestKit (t , store )
160
+ tk .MustExec ("use test" )
161
+ tk .MustExec ("drop table if exists t3,t4" )
162
+ tk .MustExec ("create table t3(a int, b int, c int);" )
163
+ tk .MustExec ("create table t4(a int, b int, c int, primary key (a, b) clustered);" )
164
+ tk .MustExec ("create table t5(a int, b int, c int, key idx_a_b (a, b));" )
165
+ tk .Session ().GetSessionVars ().PlanID .Store (0 )
166
+ queriesGroup1 := []string {
167
+ "explain select /*+ inl_join(t4) */ * from t3 join t4 on t3.b = t4.b where t4.a = 1;" ,
168
+ "explain select /*+ inl_join(t5) */ * from t3 join t5 on t3.b = t5.b where t5.a = 1;" ,
169
+ }
170
+ queriesGroup2 := []string {
171
+ "explain select /*+ inl_join(t4) */ * from t3 join t4 on t3.b = t4.b where t4.a = 2;" ,
172
+ "explain select /*+ inl_join(t5) */ * from t3 join t5 on t3.b = t5.b where t5.a = 2;" ,
173
+ }
174
+ for i := 0 ; i < len (queriesGroup1 ); i ++ {
175
+ query1 := queriesGroup1 [i ]
176
+ query2 := queriesGroup2 [i ]
177
+ t .Run (query1 + " vs " + query2 , func (t * testing.T ) {
178
+ tk .MustExec (query1 )
179
+ info1 := tk .Session ().ShowProcess ()
180
+ require .NotNil (t , info1 )
181
+ p1 , ok := info1 .Plan .(core.Plan )
182
+ require .True (t , ok )
183
+ _ , digest1 := core .NormalizePlan (p1 )
184
+ tk .MustExec (query2 )
185
+ info2 := tk .Session ().ShowProcess ()
186
+ require .NotNil (t , info2 )
187
+ p2 , ok := info2 .Plan .(core.Plan )
188
+ require .True (t , ok )
189
+ _ , digest2 := core .NormalizePlan (p2 )
190
+ require .Equal (t , digest1 , digest2 )
191
+ })
192
+ }
193
+ }
194
+
157
195
func TestNormalizedPlanForDiffStore (t * testing.T ) {
158
196
store , dom := testkit .CreateMockStoreAndDomain (t )
159
197
tk := testkit .NewTestKit (t , store )
0 commit comments