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

add generated stored column problem. #9453

Closed
crazycs520 opened this issue Feb 25, 2019 · 4 comments
Closed

add generated stored column problem. #9453

crazycs520 opened this issue Feb 25, 2019 · 4 comments
Labels
help wanted Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines. type/new-feature

Comments

@crazycs520
Copy link
Contributor

Bug Report

Please answer these questions before submitting your issue. Thanks!

  1. What did you do?
    If possible, provide a recipe for reproducing the error.
mysql root@127.0.0.1:test> create table t (a int)
Query OK, 0 rows affected
Time: 0.005s
mysql root@127.0.0.1:test> insert into t set a=1
Query OK, 1 row affected
Time: 0.003s
mysql root@127.0.0.1:test> alter table t add column b int as (a+1) stored;
Query OK, 0 rows affected
Time: 0.015s
mysql root@127.0.0.1:test> alter table t add column c int as (a+1);
Query OK, 0 rows affected
Time: 0.015s
mysql root@127.0.0.1:test> select * from t;
+---+--------+---+
| a | b      | c |
+---+--------+---+
| 1 | <null> | 2 |
+---+--------+---+
1 row in set
Time: 0.006s
mysql root@127.0.0.1:test>
  1. What did you expect to see?
mysql root@127.0.0.1:test> select * from t;
+---+---+---+
| a | b | c |
+---+---+---+
| 1 | 2 | 2 |
+---+---+---+
1 row in set
  1. What did you see instead?
    mysql root@127.0.0.1:test> select * from t;
    +---+--------+---+
    | a | b | c |
    +---+--------+---+
    | 1 | | 2 |
    +---+--------+---+

  2. What version of TiDB are you using (tidb-server -V or run select tidb_version(); on TiDB)?

mysql root@127.0.0.1:test> select tidb_version();
+--------------------------------------------------------------------------+
| tidb_version()                                                           |
+--------------------------------------------------------------------------+
| Release Version: v3.0.0-beta-116-g9a8a0d88a                              |
| Git Commit Hash: 9a8a0d88a91c664398abfc2b0f93c40069a7adbe                |
| Git Branch: master                                                       |
| UTC Build Time: 2019-02-25 12:41:19                                      |
| GoVersion: go version go1.11.5 darwin/amd64                              |
| Race Enabled: false                                                      |
| TiKV Min Version: 2.1.0-alpha.1-ff3dd160846b7d1aed9079c389fc188f7f5ea13e |
| Check Table Before Drop: false                                           |
+--------------------------------------------------------------------------+
1 row in set
Time: 0.006s
@crazycs520 crazycs520 added help wanted Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines. type/bug The issue is confirmed as a bug. labels Feb 25, 2019
@zimulala
Copy link
Contributor

You cannot add the generated column in the storage type of STORED through ALTER TABLE.
You cannot create an index on the generated column through ALTER TABLE.

Refer to https://github.com/pingcap/docs/blob/master/sql/generated-columns.md#limitations
Related #9372

@zimulala zimulala added type/new-feature and removed type/bug The issue is confirmed as a bug. labels Feb 26, 2019
@crazycs520
Copy link
Contributor Author

May be we can simply return error when add the generated column in the storage type of STORED through ALTER TABLE.

Because currently TiDB don't support backfill column value when do add column ddl.

@bb7133
Copy link
Member

bb7133 commented May 6, 2019

duplicate with #9288

@crazycs520
Copy link
Contributor Author

fix in #10758.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines. type/new-feature
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants