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

ddl, tests: add expression default values feature relevant tests for some DDLs and fix a related bug (#51571) #53394

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
2 changes: 1 addition & 1 deletion pkg/ddl/ddl_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -6035,8 +6035,8 @@ func (d *ddl) AlterColumn(ctx sessionctx.Context, ident ast.Ident, spec *ast.Alt

// Clean the NoDefaultValueFlag value.
col.DelFlag(mysql.NoDefaultValueFlag)
col.DefaultIsExpr = false
if len(specNewColumn.Options) == 0 {
col.DefaultIsExpr = false
err = col.SetDefaultValue(nil)
if err != nil {
return errors.Trace(err)
Expand Down
7 changes: 7 additions & 0 deletions tests/integrationtest/r/ddl/db_integration.result
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,13 @@ t CREATE TABLE `t` (
`c` int(10) DEFAULT NULL,
`c1` varchar(256) DEFAULT (uuid())
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin
drop table if exists t;
create table t (c int(10), c1 varchar(256) default rand());
alter table t alter column c1 set default 'xx';
insert into t values (1, default);
select c1 from t;
c1
xx
drop table if exists t1;
create table t1 (a int(11) not null auto_increment key, b int(11), c bigint, unique key (a, b, c));
alter table t1 drop index a;
Expand Down
7 changes: 7 additions & 0 deletions tests/integrationtest/t/ddl/db_integration.test
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,13 @@ insert into t(c) values (1),(2),(3),(4),(5),(6),(7),(8),(9),(10);
select count(distinct c1) from t;
show create table t;

# TestDefaultValueExpressionWithModifyColumn
drop table if exists t;
create table t (c int(10), c1 varchar(256) default rand());
alter table t alter column c1 set default 'xx';
insert into t values (1, default);
select c1 from t;

# TestDropAutoIncrementIndex
drop table if exists t1;
create table t1 (a int(11) not null auto_increment key, b int(11), c bigint, unique key (a, b, c));
Expand Down