@@ -154,53 +154,53 @@ func TestIssue47881(t *testing.T) {
154
154
tk .MustExec ("create table t2(id int,name varchar(10),name1 varchar(10),name2 varchar(10),`date1` date);" )
155
155
tk .MustExec ("insert into t2 values(1,'tt','ttt','tttt','2099-12-31'),(2,'dd','ddd','dddd','2099-12-31');" )
156
156
rs := tk .MustQuery (`WITH bzzs AS (
157
- SELECT
158
- count(1) AS bzn
159
- FROM
157
+ SELECT
158
+ count(1) AS bzn
159
+ FROM
160
160
t c
161
- ),
161
+ ),
162
162
tmp1 AS (
163
- SELECT
164
- t1.*
165
- FROM
166
- t1
167
- LEFT JOIN bzzs ON 1 = 1
168
- WHERE
169
- name IN ('tt')
163
+ SELECT
164
+ t1.*
165
+ FROM
166
+ t1
167
+ LEFT JOIN bzzs ON 1 = 1
168
+ WHERE
169
+ name IN ('tt')
170
170
AND bzn <> 1
171
- ),
171
+ ),
172
172
tmp2 AS (
173
- SELECT
174
- tmp1.*,
175
- date('2099-12-31') AS endate
176
- FROM
173
+ SELECT
174
+ tmp1.*,
175
+ date('2099-12-31') AS endate
176
+ FROM
177
177
tmp1
178
- ),
178
+ ),
179
179
tmp3 AS (
180
- SELECT
181
- *
182
- FROM
183
- tmp2
184
- WHERE
185
- endate > CURRENT_DATE
186
- UNION ALL
187
- SELECT
188
- '1' AS id,
189
- 'ss' AS name,
190
- 'sss' AS name1,
191
- 'ssss' AS name2,
192
- date('2099-12-31') AS endate
193
- FROM
194
- bzzs t1
195
- WHERE
180
+ SELECT
181
+ *
182
+ FROM
183
+ tmp2
184
+ WHERE
185
+ endate > CURRENT_DATE
186
+ UNION ALL
187
+ SELECT
188
+ '1' AS id,
189
+ 'ss' AS name,
190
+ 'sss' AS name1,
191
+ 'ssss' AS name2,
192
+ date('2099-12-31') AS endate
193
+ FROM
194
+ bzzs t1
195
+ WHERE
196
196
bzn = 1
197
- )
198
- SELECT
199
- c2.id,
200
- c3.id
201
- FROM
202
- t2 db
203
- LEFT JOIN tmp3 c2 ON c2.id = '1'
197
+ )
198
+ SELECT
199
+ c2.id,
200
+ c3.id
201
+ FROM
202
+ t2 db
203
+ LEFT JOIN tmp3 c2 ON c2.id = '1'
204
204
LEFT JOIN tmp3 c3 ON c3.id = '1';` )
205
205
rs .Check (testkit .Rows ("1 1" , "1 1" ))
206
206
}
@@ -216,3 +216,35 @@ func TestIssue48969(t *testing.T) {
216
216
tk .MustExec ("update test2 set value=0 where test2.id in (select * from v1);" )
217
217
tk .MustQuery ("select * from test2" ).Check (testkit .Rows ("1 0" , "2 0" , "3 0" , "4 4" , "5 5" ))
218
218
}
219
+
220
+ func TestIssue50614 (t * testing.T ) {
221
+ store := testkit .CreateMockStore (t )
222
+ tk := testkit .NewTestKit (t , store )
223
+ tk .MustExec ("use test" )
224
+ tk .MustExec ("drop table if exists tt" )
225
+ tk .MustExec ("create table tt(a bigint, b bigint, c bigint, d bigint, e bigint, primary key(c,d));" )
226
+ tk .MustQuery ("explain format = brief " +
227
+ "update tt, (select 1 as c1 ,2 as c2 ,3 as c3, 4 as c4 union all select 2,3,4,5 union all select 3,4,5,6) tmp " +
228
+ "set tt.a=tmp.c1, tt.b=tmp.c2 " +
229
+ "where tt.c=tmp.c3 and tt.d=tmp.c4 and (tt.c,tt.d) in ((11,111),(22,222),(33,333),(44,444));" ).Check (
230
+ testkit .Rows (
231
+ "Update N/A root N/A" ,
232
+ "└─Projection 0.00 root test.tt.a, test.tt.b, test.tt.c, test.tt.d, test.tt.e, Column#18, Column#19, Column#20, Column#21" ,
233
+ " └─Projection 0.00 root test.tt.a, test.tt.b, test.tt.c, test.tt.d, test.tt.e, Column#18, Column#19, Column#20, Column#21" ,
234
+ " └─IndexJoin 0.00 root inner join, inner:TableReader, outer key:Column#20, Column#21, inner key:test.tt.c, test.tt.d, equal cond:eq(Column#20, test.tt.c), eq(Column#21, test.tt.d), other cond:or(or(and(eq(Column#20, 11), eq(test.tt.d, 111)), and(eq(Column#20, 22), eq(test.tt.d, 222))), or(and(eq(Column#20, 33), eq(test.tt.d, 333)), and(eq(Column#20, 44), eq(test.tt.d, 444)))), or(or(and(eq(test.tt.c, 11), eq(Column#21, 111)), and(eq(test.tt.c, 22), eq(Column#21, 222))), or(and(eq(test.tt.c, 33), eq(Column#21, 333)), and(eq(test.tt.c, 44), eq(Column#21, 444))))" ,
235
+ " ├─Union(Build) 0.00 root " ,
236
+ " │ ├─Projection 0.00 root Column#6, Column#7, Column#8, Column#9" ,
237
+ " │ │ └─Projection 0.00 root 1->Column#6, 2->Column#7, 3->Column#8, 4->Column#9" ,
238
+ " │ │ └─TableDual 0.00 root rows:0" ,
239
+ " │ ├─Projection 0.00 root Column#10, Column#11, Column#12, Column#13" ,
240
+ " │ │ └─Projection 0.00 root 2->Column#10, 3->Column#11, 4->Column#12, 5->Column#13" ,
241
+ " │ │ └─TableDual 0.00 root rows:0" ,
242
+ " │ └─Projection 0.00 root Column#14, Column#15, Column#16, Column#17" ,
243
+ " │ └─Projection 0.00 root 3->Column#14, 4->Column#15, 5->Column#16, 6->Column#17" ,
244
+ " │ └─TableDual 0.00 root rows:0" ,
245
+ " └─TableReader(Probe) 0.00 root data:Selection" ,
246
+ " └─Selection 0.00 cop[tikv] or(or(and(eq(test.tt.c, 11), eq(test.tt.d, 111)), and(eq(test.tt.c, 22), eq(test.tt.d, 222))), or(and(eq(test.tt.c, 33), eq(test.tt.d, 333)), and(eq(test.tt.c, 44), eq(test.tt.d, 444)))), or(or(eq(test.tt.c, 11), eq(test.tt.c, 22)), or(eq(test.tt.c, 33), eq(test.tt.c, 44))), or(or(eq(test.tt.d, 111), eq(test.tt.d, 222)), or(eq(test.tt.d, 333), eq(test.tt.d, 444)))" ,
247
+ " └─TableRangeScan 0.00 cop[tikv] table:tt range: decided by [eq(test.tt.c, Column#20) eq(test.tt.d, Column#21)], keep order:false, stats:pseudo" ,
248
+ ),
249
+ )
250
+ }
0 commit comments