Skip to content

The result of subquery with all is not correct #33083

Closed
@SeaRise

Description

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

create table t(a int);
create table t3(id int primary key,a int);
insert into t values(1),(null);
insert into t3 values(1,2),(2,2);
alter table t set tiflash replica 1;
alter table t3 set tiflash replica 1;
select * from t where a = all ( select a from t3 where t.a=t3.id);
/*
+-------------------------------------------+---------+-------------------+---------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| id                                        | estRows | task              | access object | operator info                                                                                                                                                            |
+-------------------------------------------+---------+-------------------+---------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Projection_11                             | 2.00    | root              |               | test.t.a                                                                                                                                                                 |
| └─Apply_13                                | 2.00    | root              |               | CARTESIAN inner join, other cond:or(and(le(Column#6, 1), and(eq(test.t.a, Column#5), if(ne(Column#7, 0), NULL, 1))), or(eq(Column#8, 0), if(isnull(test.t.a), NULL, 0))) |
|   ├─TableReader_15(Build)                 | 2.00    | root              |               | data:TableFullScan_14                                                                                                                                                    |
|   │ └─TableFullScan_14                    | 2.00    | cop[tiflash]      | table:t       | keep order:false, stats:pseudo                                                                                                                                           |
|   └─TableReader_32(Probe)                 | 1.00    | root              |               | data:ExchangeSender_31                                                                                                                                                   |
|     └─ExchangeSender_31                   | 1.00    | batchCop[tiflash] |               | ExchangeType: PassThrough                                                                                                                                                |
|       └─Projection_27                     | 1.00    | batchCop[tiflash] |               | Column#5, Column#6, Column#7, Column#8                                                                                                                                   |
|         └─HashAgg_28                      | 1.00    | batchCop[tiflash] |               | funcs:firstrow(Column#14)->Column#5, funcs:count(distinct test.t3.a)->Column#6, funcs:sum(Column#15)->Column#7, funcs:sum(Column#16)->Column#8                           |
|           └─ExchangeReceiver_30           | 1.00    | batchCop[tiflash] |               |                                                                                                                                                                          |
|             └─ExchangeSender_29           | 1.00    | batchCop[tiflash] |               | ExchangeType: PassThrough                                                                                                                                                |
|               └─HashAgg_18                | 1.00    | batchCop[tiflash] |               | group by:Column#22, funcs:firstrow(Column#20)->Column#14, funcs:sum(Column#21)->Column#15, funcs:count(1)->Column#16                                                     |
|                 └─Projection_34           | 1.00    | batchCop[tiflash] |               | test.t3.a, cast(isnull(test.t3.a), decimal(20,0) BINARY)->Column#21, test.t3.a                                                                                           |
|                   └─TableRangeScan_26     | 1.00    | batchCop[tiflash] | table:t3      | range: decided by [eq(test.t.a, test.t3.id)], keep order:false, stats:pseudo                                                                                             |
+-------------------------------------------+---------+-------------------+---------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
*/

2. What did you expect to see? (Required)

null

3. What did you see instead (Required)

empty result

4. What is your TiDB version? (Required)

master nightly

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions