hashAgg panic when UpdatePartialResult
- Dominant language
- Go
- Stars
- 40.5k
- Forks
- 6.2k
- PR merge metrics
- PR metrics pending
Description
## Bug Report
Please answer these questions before submitting your issue. Thanks!
### 1. Minimal reproduce step (Required)
``` SQL
CREATE TABLE `5aa6e0cc-1fa2-4625-b8ff-74c648ce3262` (
`b47ed459-807c-4e80-987f-87b96248ff05` float NOT NULL DEFAULT '1.4563651',
`681fd446-9ea1-4017-ab9f-590d9d4544e7` tinyint(4) NOT NULL DEFAULT '-21',
PRIMARY KEY (`b47ed459-807c-4e80-987f-87b96248ff05`,`681fd446-9ea1-4017-ab9f-590d9d4544e7`) /*T![clustered_index] CLUSTERED */
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_bin;
INSERT INTO `5aa6e0cc-1fa2-4625-b8ff-74c648ce3262` VALUES (6162.3276,0),(8178.5693,-27),(78.69162,-128),(5093.862,49),(2537.274,17),(9563.064,-44),(1878.5768,41);
select /*+ use_index_merge( `5aa6e0cc-1fa2-4625-b8ff-74c648ce3262` ) */ bit_length( `5aa6e0cc-1fa2-4625-b8ff-74c648ce3262`.`b47ed459-807c-4e80-987f-87b96248ff05` ) as r0 , avg( distinct `5aa6e0cc-1fa2-4625-b8ff-74c648ce3262`.`681fd446-9ea1-4017-ab9f-590d9d4544e7` ) as r1 from `5aa6e0cc-1fa2-4625-b8ff-74c648ce3262` where `5aa6e0cc-1fa2-4625-b8ff-74c648ce3262`.`b47ed459-807c-4e80-987f-87b96248ff05` > 1422.3551427171312 or IsNull( `5aa6e0cc-1fa2-4625-b8ff-74c648ce3262`.`681fd446-9ea1-4017-ab9f-590d9d4544e7` ) group by `5aa6e0cc-1fa2-4625-b8ff-74c648ce3262`.`b47ed459-807c-4e80-987f-87b96248ff05`;
```
### 2. What did you expect to see? (Required)
No error
### 3. What did you see instead (Required)
[err="runtime error: index out of range [0] with length 0\ngithub.com/pingcap/tidb/executor.recoveryProjection\n\t/Users/bba/pc/tidb/executor/projection.go:460\ngithub.com/pingcap/tidb/executor.(*projectionInputFetcher).run.func1\n\t/Users/bba/pc/tidb/executor/projection.go:360\nruntime.gopanic\n\t/Users/bba/.gvm/gos/go1.19/src/runtime/panic.go:884\nruntime.goPanicIndex\n\t/Users/bba/.gvm/gos/go1.19/src/runtime/panic.go:113\ngithub.com/pingcap/tidb/util/chunk.(*Column).IsNull\n\t/Users/bba/pc/tidb/util/chunk/column.go:169\ngithub.com/pingcap/tidb/util/chunk.Row.IsNull\n\t/Users/bba/pc/tidb/util/chunk/row.go:218\ngithub.com/pingcap/tidb/expression.(*Column).EvalReal\n\t/Users/bba/pc/tidb/expression/column.go:428\ngithub.com/pingcap/tidb/executor/aggfuncs.(*firstRow4Float32).UpdatePartialResult\n\t/Users/bba/pc/tidb/executor/aggfuncs/func_first_row.go:185\ngithub.com/pingcap/tidb/executor.(*HashAggExec).execute\n\t/Users/bba/pc/tidb/executor/aggregate.go:1044\ngithub.com/pingcap/tidb/executor.(*HashAggExec).unparallelExec\n\t/Users/bba/pc/tidb/executor/aggregate.go:966\ngithub.com/pingcap/tidb/executor.(*HashAggExec).Next\n\t/Users/bba/pc/tidb/executor/aggregate.go:785\ngithub.com/pingcap/tidb/executor.Next\n\t/Users/bba/pc/tidb/executor/executor.go:328\ngithub.com/pingcap/tidb/executor.(*projectionInputFetcher).run\n\t/Users/bba/pc/tidb/executor/projection.go:384\nruntime.goexit\n\t/Users/bba/.gvm/gos/go1.19/src/runtime/asm_arm64.s:1165"]
If remove the index merge hint, we got:
```
ERROR 1105 (HY000): should ensure all columns have the same length, expect 2, but got 0
```
### 4. What is your TiDB version? (Required)
master
Contributor guide
Assessment
This issue has not been assessed yet.