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

bug of select on general column when add generated column first. #11365

Closed
crazycs520 opened this issue Jul 22, 2019 · 0 comments
Closed

bug of select on general column when add generated column first. #11365

crazycs520 opened this issue Jul 22, 2019 · 0 comments
Assignees
Labels
type/bug This issue is a bug.

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.
create table t (a int, b int as (a + 1), c int as (b + 1))
insert into t set a=1;
alter table t add column e int as (c + 1) first;  -- this will get error in mysql: 'Generated column can refer only to generated columns defined prior to it.'
select * from t
+--------+---+---+---+
| e      | a | b | c |
+--------+---+---+---+
| <null> | 1 | 2 | 3 |                      
+--------+---+---+---+
1 row in set
desc select * from t;
+-----------------+----------+------+-------------------------------------------------------------------------------------------------------------------+
| id              | count    | task | operator info                                                                                                     |
+-----------------+----------+------+-------------------------------------------------------------------------------------------------------------------+
| Projection_5    | 10000.00 | root | cast(plus(cast(plus(test.t.b, 1)), 1)), test.t.a, cast(plus(test.t.a, 1)), cast(plus(cast(plus(test.t.a, 1)), 1)) |
| └─TableReader_7 | 10000.00 | root | data:TableScan_6                                                                                                  |
|   └─TableScan_6 | 10000.00 | cop  | table:t, range:[-inf,+inf], keep order:false, stats:pseudo                                                        |
+-----------------+----------+------+-------------------------------------------------------------------------------------------------------------------+
  1. What did you expect to see?
mysql>alter table t add column e int as (c + 1) first;
(3107, u'Generated column can refer only to generated columns defined prior to it.')
  1. What did you see instead?
alter table t add column e int as (c + 1) first; 
--success
select * from t
+--------+---+---+---+
| e      | a | b | c |
+--------+---+---+---+
| <null> | 1 | 2 | 3 |                          -- the result of e should not null.
+--------+---+---+---+
  1. What version of TiDB are you using (tidb-server -V or run select tidb_version(); on TiDB)?
▶ bin/tidb-server -V
Release Version: v3.0.0-rc.1-360-g85de5df03
Git Commit Hash: 85de5df03fd47f80b90c36a63b7d213aeda4468b
Git Branch: master
UTC Build Time: 2019-07-22 06:40:48
GoVersion: go version go1.12 darwin/amd64
Race Enabled: false
TiKV Min Version: 2.1.0-alpha.1-ff3dd160846b7d1aed9079c389fc188f7f5ea13e
Check Table Before Drop: false

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/bug This issue is a bug.
Projects
None yet
Development

No branches or pull requests

3 participants