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

table: Don't cast date default values (same as timestamp/datetime) | tidb-test=920d9bf1b1137cda1272bdd59ae527aee8067944 #59149

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions ddl/db_partition_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4903,3 +4903,12 @@ func TestIssue54829(t *testing.T) {
}

// TODO: check EXCHANGE how it handles null (for all types of partitioning!!!)

func TestIssue59047(t *testing.T) {
store := testkit.CreateMockStore(t)
tk := testkit.NewTestKit(t, store)
tk.MustExec("use test")
tk.MustExec(`create table t (id bigint primary key, name varchar(20))`)
tk.MustExec(`alter table t add column d date not null`)
tk.MustExec(`update t set name = 'x'`)
}
4 changes: 3 additions & 1 deletion table/column.go
Original file line number Diff line number Diff line change
Expand Up @@ -568,7 +568,9 @@ func getColDefaultValue(ctx sessionctx.Context, col *model.ColumnInfo, defaultVa
return getColDefaultValueFromNil(ctx, col, args)
}

if col.GetType() != mysql.TypeTimestamp && col.GetType() != mysql.TypeDatetime {
switch col.GetType() {
case mysql.TypeTimestamp, mysql.TypeDate, mysql.TypeDatetime:
default:
value, err := CastValue(ctx, types.NewDatum(defaultVal), col, false, false)
if err != nil {
return types.Datum{}, err
Expand Down
Loading