-
Notifications
You must be signed in to change notification settings - Fork 5.8k
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 partition: enhance auto id for exchange partition with table #36663
Changes from all commits
2c3036d
b25b797
9114e44
c207a66
b149cbd
5e5a3db
479a0ec
1c3fb13
7793883
44ad874
d4b987d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -2377,6 +2377,89 @@ func TestExchangePartitionHook(t *testing.T) { | |||||||||||||||
tk.MustQuery("select * from pt partition(p0)").Check(testkit.Rows("1")) | ||||||||||||||||
} | ||||||||||||||||
|
||||||||||||||||
func TestExchangePartitionHook3(t *testing.T) { | ||||||||||||||||
store, dom, clean := testkit.CreateMockStoreAndDomain(t) | ||||||||||||||||
defer clean() | ||||||||||||||||
tk := testkit.NewTestKit(t, store) | ||||||||||||||||
// why use tkCancel, not tk. | ||||||||||||||||
//tkCancel := testkit.NewTestKit(t, store) | ||||||||||||||||
Comment on lines
+2384
to
+2385
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||
|
||||||||||||||||
tk.MustExec("set @@tidb_enable_exchange_partition=1") | ||||||||||||||||
defer tk.MustExec("set @@tidb_enable_exchange_partition=0") | ||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think this is necessary. I think this is a session scoped variable and the session will end after the test anyway? |
||||||||||||||||
|
||||||||||||||||
tk.MustExec("use test") | ||||||||||||||||
tk.MustExec(`create table pt (a int primary key auto_increment) partition by range(a) ( | ||||||||||||||||
partition p0 values less than (3), | ||||||||||||||||
partition p1 values less than (6), | ||||||||||||||||
PARTITION p2 values less than (9), | ||||||||||||||||
PARTITION p3 values less than (MAXVALUE) | ||||||||||||||||
);`) | ||||||||||||||||
tk.MustExec(`create table nt(a int primary key auto_increment);`) | ||||||||||||||||
|
||||||||||||||||
tk.MustExec(`insert into pt values (0), (4), (7)`) | ||||||||||||||||
tk.MustExec("insert into nt values (1)") | ||||||||||||||||
|
||||||||||||||||
hook := &ddl.TestDDLCallback{Do: dom} | ||||||||||||||||
dom.DDL().SetHook(hook) | ||||||||||||||||
|
||||||||||||||||
hookFunc := func(job *model.Job) { | ||||||||||||||||
tk.MustExec(`insert into pt values (40000000)`) | ||||||||||||||||
} | ||||||||||||||||
hook.OnJobUpdatedExported = hookFunc | ||||||||||||||||
|
||||||||||||||||
//tk.MustExec(`create table nt1(a int);`) | ||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||
tk.MustExec("alter table pt exchange partition p0 with table nt") | ||||||||||||||||
time.Sleep(time.Duration(63) * time.Second) | ||||||||||||||||
tk.MustExec("insert into nt values (NULL)") | ||||||||||||||||
tk.MustQuery("select * from nt").Check(testkit.Rows("")) | ||||||||||||||||
tk.MustQuery("select * from pt").Check(testkit.Rows("")) | ||||||||||||||||
|
||||||||||||||||
//tk.MustQuery("select * from pt partition(p0)").Check(testkit.Rows("1")) | ||||||||||||||||
//tk.MustExec("alter table pt exchange partition p0 with table nt") | ||||||||||||||||
//tkCancel.MustExec("insert into nt values (1)") | ||||||||||||||||
//tkCancel.MustExec("use test") | ||||||||||||||||
// tkCancel.MustExec("insert into pt values (2)") | ||||||||||||||||
// tkCancel.MustQuery("select * from pt partition(p0)").Check(testkit.Rows()) | ||||||||||||||||
Comment on lines
+2416
to
+2422
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||
} | ||||||||||||||||
|
||||||||||||||||
func TestExchangePartitionHook2(t *testing.T) { | ||||||||||||||||
store, _, clean := testkit.CreateMockStoreAndDomain(t) | ||||||||||||||||
defer clean() | ||||||||||||||||
tk := testkit.NewTestKit(t, store) | ||||||||||||||||
// why use tkCancel, not tk. | ||||||||||||||||
//tkCancel := testkit.NewTestKit(t, store) | ||||||||||||||||
|
||||||||||||||||
tk.MustExec("set @@tidb_enable_exchange_partition=1") | ||||||||||||||||
defer tk.MustExec("set @@tidb_enable_exchange_partition=0") | ||||||||||||||||
|
||||||||||||||||
tk.MustExec("use test") | ||||||||||||||||
tk.MustExec(`CREATE TABLE pt (a int primary key auto_increment, b varchar(255)) | ||||||||||||||||
PARTITION BY RANGE (a) ( | ||||||||||||||||
PARTITION p0 VALUES LESS THAN (1000000), | ||||||||||||||||
partition p1M values less than (2000000));`) | ||||||||||||||||
tk.MustExec(`create table t (a int primary key auto_increment, b varchar(255))`) | ||||||||||||||||
|
||||||||||||||||
tk.MustExec(`insert into pt values (1, "1")`) | ||||||||||||||||
tk.MustExec(`insert into t values (2, "2")`) | ||||||||||||||||
tk.MustExec(`insert into t values (4000000, "4M")`) | ||||||||||||||||
tk.MustExec(`delete from t where a = 4000000`) | ||||||||||||||||
tk.MustExec(`alter table pt exchange partition p0 with table t`) | ||||||||||||||||
|
||||||||||||||||
//hook := &ddl.TestDDLCallback{Do: dom} | ||||||||||||||||
//dom.DDL().SetHook(hook) | ||||||||||||||||
// | ||||||||||||||||
//hookFunc := func(job *model.Job) { | ||||||||||||||||
// if job.Type == model.ActionExchangeTablePartition && job.SchemaState != model.StateNone { | ||||||||||||||||
// tkCancel.MustExec("use test") | ||||||||||||||||
// tkCancel.MustGetErrCode("insert into nt values (5)", tmysql.ErrRowDoesNotMatchGivenPartitionSet) | ||||||||||||||||
// } | ||||||||||||||||
//} | ||||||||||||||||
//hook.OnJobUpdatedExported = hookFunc | ||||||||||||||||
// | ||||||||||||||||
//tk.MustExec("alter table pt exchange partition p0 with table nt") | ||||||||||||||||
//tk.MustQuery("select * from pt partition(p0)").Check(testkit.Rows("1")) | ||||||||||||||||
} | ||||||||||||||||
|
||||||||||||||||
func TestExchangePartitionExpressIndex(t *testing.T) { | ||||||||||||||||
restore := config.RestoreFunc() | ||||||||||||||||
defer restore() | ||||||||||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you can revert this file change?