ANALYZE TABLE fails after adding a virtual generated column on existing rows
- Dominant language
- Go
- Stars
- 40.5k
- Forks
- 6.2k
- PR merge metrics
- PR metrics pending
Description
## Bug Report
### Summary
A successful `ALTER TABLE ... ADD COLUMN ... VIRTUAL` can leave the table in a state where later `ANALYZE TABLE` fails on existing rows instead of handling the problematic generated column gracefully.
### Minimal Reproduction
```sql
use test;
drop table if exists repro_analyze_gc_overflow;
create table repro_analyze_gc_overflow (
a bigint unsigned not null
);
insert into repro_analyze_gc_overflow values
(18446744073709551615);
alter table repro_analyze_gc_overflow
add column b bigint unsigned generated always as (a + 1) virtual;
analyze table repro_analyze_gc_overflow;
```
### Actual Behavior
`ANALYZE TABLE` fails:
```text
ERROR 1690 (22003): BIGINT UNSIGNED value is out of range in '(test.repro_analyze_gc_overflow.a + 1)'
```
### Expected Behavior
`ANALYZE TABLE` should not fail the whole stats collection for this table after a successful DDL.
### Version
Observed on current nightly / master-based TiDB build.
Contributor guide
Assessment
This issue has not been assessed yet.