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

Unexpect error when use default function in expression of generated column #12471

Closed
Deardrops opened this issue Sep 29, 2019 · 1 comment · Fixed by #12550
Closed

Unexpect error when use default function in expression of generated column #12471

Deardrops opened this issue Sep 29, 2019 · 1 comment · Fixed by #12550
Labels
type/bug The issue is confirmed as a bug.

Comments

@Deardrops
Copy link
Contributor

Deardrops commented Sep 29, 2019

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 t1(a int default 9, b int as (default(a)));
insert into t1 values(1, default);
select * from t1;
  1. What did you expect to see?
    image

  2. What did you see instead?
    image

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

Release Version: v4.0.0-alpha-341-g0df9bb7b8-dirty
@Deardrops Deardrops added the type/bug The issue is confirmed as a bug. label Sep 29, 2019
@Deardrops
Copy link
Contributor Author

Deardrops commented Sep 29, 2019

Related PR: #8540

The issue is caused by the check in

if colExpr.OrigTblName.O == "" {
// column is evaluated by some expressions, for example:
// `select default(c) from (select (a+1) as c from t) as t0`
// in such case, a 'no default' error is returned
er.err = table.ErrNoDefaultValue.GenWithStackByArgs(colExpr.ColName)
return
}

Same as sql statement select default(c) from (select (a+1) as c from t) as t0, When use default() function in expression of generated columns, its colExpr also has an empty field of OrigTblName.O.So the latter will throw an unexpected error.

Any suggessions for fixup this issue?
This Issue fixup in #12550

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

Successfully merging a pull request may close this issue.

1 participant