pingcap / pingcap/tidb

Please allow generated columns to be based on new columns in the same SQL statement

Open
#59,592 0 comments 0 reactions 0 assignees View on GitHub
component/ddl type/feature-request
Dominant language
Go
Stars
40.5k
Forks
6.2k
PR merge metrics
PR metrics pending

Description

## Feature Request

**Is your feature request related to a problem? Please describe:**

The following SQLs have no error in mysql, but report error in tidb

```sql
drop table if exists tb;

create table tb (id int primary key);

alter table tb add column a json null,
add column b varchar(255) generated always as (a->"$.b");
```
Error:
```sql
ERROR 1054 (42S22): Unknown column 'a' in 'generated column function'
```

**Describe the feature you'd like:**

Please allow generated columns to be based on new columns in the same SQL statement

**Describe alternatives you've considered:**

A paid customer has no alternative, because these SQLs are generated by 3rd application that runs on mysql

**Teachability, Documentation, Adoption, Migration Strategy:**

There is no such limitation documented in [Generated Columns](https://docs.pingcap.com/tidb/stable/generated-columns#limitations)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.