Skip to content

Commit

Permalink
planner: fix hidden column may do not have a virtual expression (#52184)
Browse files Browse the repository at this point in the history
close #52181
  • Loading branch information
AilinKid authored Mar 28, 2024
1 parent 5f53c70 commit 2ae1933
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
4 changes: 2 additions & 2 deletions pkg/expression/column.go
Original file line number Diff line number Diff line change
Expand Up @@ -390,8 +390,8 @@ const columnPrefix = "Column#"

// String implements Stringer interface.
func (col *Column) String() string {
if col.IsHidden {
// A hidden column must be a virtual generated column, we should output its expression.
if col.IsHidden && col.VirtualExpr != nil {
// A hidden column without virtual expression indicates it's a stored type.
return col.VirtualExpr.String()
}
if col.OrigName != "" {
Expand Down
1 change: 1 addition & 0 deletions pkg/table/tables/tables_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -544,6 +544,7 @@ func TestHiddenColumn(t *testing.T) {
tk.MustGetErrMsg("update t set a=1 where c=3 order by b;", "[planner:1054]Unknown column 'b' in 'order clause'")

// `DELETE` statement
tk.MustQuery("trace plan delete from t;")
tk.MustExec("delete from t;")
tk.MustQuery("select count(*) from t;").Check(testkit.Rows("0"))
tk.MustExec("insert into t values (1, 3, 5);")
Expand Down

0 comments on commit 2ae1933

Please sign in to comment.