Skip to content

SQL failed with "ERROR 1105 (HY000): runtime error: index out of range [1] with length 1" when tidb_enable_inl_join_inner_multi_pattern is ON #54535

@joechenrh

Description

@joechenrh

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

set GLOBAL tidb_enable_inl_join_inner_multi_pattern='ON';
create table ta(a1 int, a2 int, a3 int, index idx_a(a1));
create table tb(b1 int, b2 int, b3 int, index idx_b(b1));
explain SELECT /*+ inl_join(tmp) */ * FROM ta, (SELECT b1, COUNT(b3) AS cnt FROM tb GROUP BY b1, b2) as tmp where ta.a1 = tmp.b1;

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

Output physical plan like

+-----------------------------------+---------+-----------+---------------------------+-----------------------------------------------------------------------------------------------------------------+
| id                                | estRows | task      | access object             | operator info                                                                                                   |
+-----------------------------------+---------+-----------+---------------------------+-----------------------------------------------------------------------------------------------------------------+
| Projection_9                      | 3.00    | root      |                           | test.ta.a1, test.ta.a2, test.ta.a3, test.tb.b1, Column#9                                                        |
| └─IndexJoin_16                    | 3.00    | root      |                           | inner join, inner:HashAgg_14, outer key:test.ta.a1, inner key:test.tb.b1, equal cond:eq(test.ta.a1, test.tb.b1) |
|   ├─TableReader_43(Build)         | 3.00    | root      |                           | data:Selection_42                                                                                               |
|   │ └─Selection_42                | 3.00    | cop[tikv] |                           | not(isnull(test.ta.a1))                                                                                         |
|   │   └─TableFullScan_41          | 3.00    | cop[tikv] | table:ta                  | keep order:false, stats:pseudo                                                                                  |
|   └─HashAgg_14(Probe)             | 19.16   | root      |                           | group by:test.tb.b1, test.tb.b2, funcs:count(Column#11)->Column#9, funcs:firstrow(test.tb.b1)->test.tb.b1       |
|     └─IndexLookUp_15              | 19.16   | root      |                           |                                                                                                                 |
|       ├─Selection_12(Build)       | 3.00    | cop[tikv] |                           | not(isnull(test.tb.b1))                                                                                         |
|       │ └─IndexRangeScan_10       | 3.00    | cop[tikv] | table:tb, index:idx_b(b1) | range: decided by [eq(test.tb.b1, test.ta.a1)], keep order:false, stats:pseudo                                  |
|       └─HashAgg_13(Probe)         | 19.16   | cop[tikv] |                           | group by:test.tb.b1, test.tb.b2, funcs:count(test.tb.b3)->Column#11                                             |
|         └─TableRowIDScan_11       | 3.00    | cop[tikv] | table:tb                  | keep order:false, stats:pseudo                                                                                  |
+-----------------------------------+---------+-----------+---------------------------+-----------------------------------------------------------------------------------------------------------------+

3. What did you see instead (Required)

ERROR 1105 (HY000): runtime error: index out of range [1] with length 1

4. What is your TiDB version? (Required)

v8.2.0-alpha-557-g07bc0d09e8

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions