Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
jackysp opened this issue Jan 2, 2024 · 5 comments · Fixed by #50002
Closed

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

jackysp opened this issue Jan 2, 2024 · 5 comments · Fixed by #50002
Assignees
Labels
affects-6.5 This bug affects the 6.5.x(LTS) versions. affects-7.1 This bug affects the 7.1.x(LTS) versions. affects-7.5 This bug affects the 7.5.x(LTS) versions. found/gs found by gs report/community The community has encountered this bug. report/customer Customers have encountered this bug. severity/moderate sig/planner SIG: Planner type/bug The issue is confirmed as a bug. type/regression

Comments

@jackysp
Copy link
Member

jackysp commented Jan 2, 2024

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

create table if not exists ast (i varchar(20));
create table if not exists acc (j varchar(20), k varchar(20), l varchar(20), m varchar(20));

explain with t as(
select i,
    (case
        when b.j = '20001' then b.l
        else b.k
    end) an
from
    ast a
inner join acc b on
(a.i = b.m)
and a.i = 'astp2019121731703151'),
t1 as (select i, group_concat(an order by an separator '; ') an from t group by i)
select * from t1;

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

No error.

3. What did you see instead (Required)

Panicked.

4. What is your TiDB version? (Required)

= v6.5.3
Actually panic starts from v6.5.6, it returns an error [2024/01/02 20:39:19.509 +08:00] [WARN] [session.go:2207] ["compile SQL failed"] [conn=2199023255955] [error="Can't find column Column#31 in schema Column: [test.ast.i,test.acc.j,test.acc.k,test.acc.l] Unique key: []"] [SQL="explain with t as(\nselect i,\n (case\n when b.j = '20001' then b.l\n else b.k\n end) an\nfrom\n ast a\ninner join acc b on\n(a.i = b.m)\nand a.i = 'astp2019121731703151'),\nt1 as (select i, group_concat(an order by an separator '; ') an from t group by i)\nselect * from t1"] on v6.5.3

@kennedy8312
Copy link

/type regression

@kennedy8312
Copy link

Regression Analysis
PR caused this regression: 46419

@seiya-annie
Copy link

/found customer

@ti-chi-bot ti-chi-bot bot added the report/customer Customers have encountered this bug. label Jun 4, 2024
@seiya-annie
Copy link

/found community

@ti-chi-bot ti-chi-bot bot added the report/community The community has encountered this bug. label Jun 4, 2024
@Rustin170506
Copy link
Member

A workaround:

WITH RECURSIVE t AS (
    SELECT a.i,
           CASE WHEN b.j = '20001' THEN b.l ELSE b.k END AS an,
           ROW_NUMBER() OVER (PARTITION BY a.i ORDER BY CASE WHEN b.j = '20001' THEN b.l ELSE b.k END) AS rn,
           (SELECT COUNT(*) FROM acc WHERE m = 'astp2019121731703151') AS total_count
    FROM ast a
    INNER JOIN acc b ON a.i = b.m
    WHERE a.i = 'astp2019121731703151'
),
t1 AS (
    SELECT i, an, rn, total_count, CAST(an AS CHAR(1000)) AS concatenated
    FROM t
    WHERE rn = 1
    UNION ALL
    SELECT t.i, t.an, t.rn, t.total_count, CONCAT(t1.concatenated, '; ', t.an)
    FROM t
    INNER JOIN t1 ON t.i = t1.i AND t.rn = t1.rn + 1
),
final AS (
    SELECT i, concatenated AS an
    FROM t1
    WHERE rn = total_count
)
SELECT * FROM final;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
affects-6.5 This bug affects the 6.5.x(LTS) versions. affects-7.1 This bug affects the 7.1.x(LTS) versions. affects-7.5 This bug affects the 7.5.x(LTS) versions. found/gs found by gs report/community The community has encountered this bug. report/customer Customers have encountered this bug. severity/moderate sig/planner SIG: Planner type/bug The issue is confirmed as a bug. type/regression
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants