Closed JZuming closed 2 years ago
Do you mean there is a UnionScan
executor? if so, that's expected.
Inside transaction, we use a UnionScan
to combine the data from TiKV snapshot and transaction's in-memory buffer.
All the changes are buffered in the transaction before it commit. Without UnionScan
, you can't read what you write, so the plan is different. @JZuming
Quite strange. Here is another test case
BEGIN OPTIMISTIC;
insert into t_vwvgdc (wkey, pkey, c_rdsfbc) values (155, 228000, 99.50);
select pkey from t_vwvgdc where 0 <> 0; --- output empty set
select pkey from t_vwvgdc; --- output 30 rows
select pkey from t_vwvgdc where 0 <> 0
union
select pkey from t_vwvgdc; --- output empty set
commit;
The first SELECT outputs an empty set, and the second SELECT outputs a set with 30 rows. It is quite strange that the third SELECT (first SELECT union second SELECT) outputs an empty set.
Bug Report
Please answer these questions before submitting your issue. Thanks!
1. Minimal reproduce step (Required)
Setup the environment:
mysql_bk.sql: mysql_bk.txt
Testcase 1
Testcase 2
2. What did you expect to see? (Required)
The execution result of SELECT statements in Testcase 1 and Testcase 2 are same.
3. What did you see instead (Required)
Output of SELECT statement in Testcase 1
Output of SELECT statement in Testcase 2
Their results are different.
4. What is your TiDB version? (Required)