Skip to content

TiDB incorrectly converts update statement to point get #47445

@0xPoe

Description

@0xPoe

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

CREATE TABLE golang1 (
`fcbpdt` CHAR (8) COLLATE utf8_general_ci NOT NULL,
`fcbpsq` VARCHAR (20) COLLATE utf8_general_ci NOT NULL,
`procst` char (4) COLLATE utf8_general_ci DEFAULT NULL,
`cipstx` VARCHAR (105) COLLATE utf8_general_ci DEFAULT NULL,
`cipsst` CHAR (4) COLLATE utf8_general_ci DEFAULT NULL,
`dyngtg` VARCHAR(4) COLLATE utf8_general_ci DEFAULT NULL,
`blncdt` VARCHAR (8) COLLATE utf8_general_ci DEFAULT NULL, PRIMARY KEY ( fcbpdt, fcbpsq ));
insert into golang1 values('20230925','12023092502158016','abc','','','','');
create table golang2 (
`sysgrp` varchar(20) NOT NULL,
`procst` varchar(8) NOT NULL,
`levlid` int(11) NOT NULL,PRIMARY key (procst));
insert into golang2 VALUES('COMMON','ACSC',90);
insert into golang2 VALUES('COMMON','abc',8);
insert into golang2 VALUES('COMMON','CH02',6);
UPDATE golang1 a
SET procst =(
CASE WHEN
( SELECT levlid FROM golang2 b WHERE b.sysgrp = 'COMMON' AND b.procst = 'ACSC' )
>
( SELECT levlid FROM golang2 c WHERE c.sysgrp = 'COMMON' AND c.procst = a.procst )
THEN 'ACSC' ELSE a.procst END
) ,
cipstx = 'CI010000',
cipsst = 'ACSC',
dyngtg = 'EAYT',
blncdt= '20230925'
WHERE
fcbpdt = '20230925'
AND fcbpsq = '12023092502158016';

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

Update success.

3. What did you see instead (Required)

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

4. What is your TiDB version? (Required)

mysql> select tidb_version();
+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| tidb_version()                                                                                                                                                                                                                                                                               |
+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Release Version: v6.5.1
Edition: Community
Git Commit Hash: 4084b077d615f9dc0a41cf2e30bc6e1a02332df2
Git Branch: heads/refs/tags/v6.5.1
UTC Build Time: 2023-03-07 16:04:14
GoVersion: go1.19.5
Race Enabled: false
TiKV Min Version: 6.2.0-alpha
Check Table Before Drop: false
Store: tikv |
+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)

Metadata

Metadata

Assignees

No one assigned

    Labels

    affects-5.4This bug affects the 5.4.x(LTS) versions.affects-6.1This bug affects the 6.1.x(LTS) versions.affects-6.5This bug affects the 6.5.x(LTS) versions.affects-7.1This bug affects the 7.1.x(LTS) versions.affects-7.5This bug affects the 7.5.x(LTS) versions.found/gsfound by gsreport/customerCustomers have encountered this bug.severity/majorsig/plannerSIG: Plannertype/bugThe issue is confirmed as a bug.type/regression

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions