Skip to content

Commit

Permalink
fix conflicts
Browse files Browse the repository at this point in the history
Signed-off-by: Yang Keao <yangkeao@chunibyo.icu>
  • Loading branch information
YangKeao committed Jul 11, 2024
1 parent 1fff3a4 commit f595a8a
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 426 deletions.
8 changes: 2 additions & 6 deletions pkg/ddl/partition.go
Original file line number Diff line number Diff line change
Expand Up @@ -3233,13 +3233,9 @@ func (w *reorgPartitionWorker) fetchRowColVals(txn kv.Transaction, taskRange reo
return false, nil
}

<<<<<<< HEAD
// TODO: Extend for normal tables
// TODO: Extend for REMOVE PARTITIONING
_, err := w.rowDecoder.DecodeTheExistedColumnMap(w.sessCtx, handle, rawRow, sysTZ, w.rowMap)
=======
_, err := w.rowDecoder.DecodeTheExistedColumnMap(w.exprCtx, handle, rawRow, sysTZ, w.rowMap)
>>>>>>> d5fece20f73 (ddl: Regenerating AutoIDs for _tidb_rowid during Reorganize Partition (#53770))
if err != nil {
return false, errors.Trace(err)
}
Expand Down Expand Up @@ -3270,12 +3266,12 @@ func (w *reorgPartitionWorker) fetchRowColVals(txn kv.Transaction, taskRange reo
// TODO: Which autoid allocator to use?
ids := uint64(max(1, w.batchCnt-len(w.rowRecords)))
// Keep using the original table's allocator
stmtCtx.BaseRowID, stmtCtx.MaxRowID, err = tables.AllocHandleIDs(w.ctx, w.tblCtx, w.reorgedTbl, ids)
stmtCtx.BaseRowID, stmtCtx.MaxRowID, err = tables.AllocHandleIDs(w.ctx, w.sessCtx, w.reorgedTbl, ids)
if err != nil {
return false, errors.Trace(err)
}
}
recordID, err := tables.AllocHandle(w.ctx, w.tblCtx, w.reorgedTbl)
recordID, err := tables.AllocHandle(w.ctx, w.sessCtx, w.reorgedTbl)
if err != nil {
return false, errors.Trace(err)
}
Expand Down
20 changes: 2 additions & 18 deletions pkg/table/tables/tables.go
Original file line number Diff line number Diff line change
Expand Up @@ -885,14 +885,8 @@ func (t *TableCommon) AddRecord(sctx sessionctx.Context, r []types.Datum, opts .
// The reserved ID could be used in the future within this statement, by the
// following AddRecord() operation.
// Make the IDs continuous benefit for the performance of TiKV.
<<<<<<< HEAD
stmtCtx := sctx.GetSessionVars().StmtCtx
stmtCtx.BaseRowID, stmtCtx.MaxRowID, err = allocHandleIDs(ctx, sctx, t, uint64(opt.ReserveAutoID))
=======
sessVars := sctx.GetSessionVars()
stmtCtx := sessVars.StmtCtx
stmtCtx.BaseRowID, stmtCtx.MaxRowID, err = AllocHandleIDs(ctx, sctx, t, uint64(opt.ReserveAutoID))
>>>>>>> d5fece20f73 (ddl: Regenerating AutoIDs for _tidb_rowid during Reorganize Partition (#53770))
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -1690,21 +1684,11 @@ func AllocHandle(ctx context.Context, sctx sessionctx.Context, t table.Table) (k
}
}

<<<<<<< HEAD
_, rowID, err := allocHandleIDs(ctx, sctx, t, 1)
_, rowID, err := AllocHandleIDs(ctx, sctx, t, 1)
return kv.IntHandle(rowID), err
}

func allocHandleIDs(ctx context.Context, sctx sessionctx.Context, t table.Table, n uint64) (int64, int64, error) {
=======
_, rowID, err := AllocHandleIDs(ctx, mctx, t, 1)
return kv.IntHandle(rowID), err
}

// AllocHandleIDs allocates n handle ids (_tidb_rowid), and caches the range
// in the table.MutateContext.
func AllocHandleIDs(ctx context.Context, mctx table.MutateContext, t table.Table, n uint64) (int64, int64, error) {
>>>>>>> d5fece20f73 (ddl: Regenerating AutoIDs for _tidb_rowid during Reorganize Partition (#53770))
func AllocHandleIDs(ctx context.Context, sctx sessionctx.Context, t table.Table, n uint64) (int64, int64, error) {
meta := t.Meta()
base, maxID, err := t.Allocators(sctx).Get(autoid.RowIDAllocType).Alloc(ctx, n, 1, 1)
if err != nil {
Expand Down
176 changes: 0 additions & 176 deletions tests/integrationtest/r/ddl/db_partition.result
Original file line number Diff line number Diff line change
Expand Up @@ -3291,181 +3291,6 @@ partition by range(unix_timestamp(time_recorded)) (
partition p1 values less than (1559192604)
);
set @@session.tidb_enable_table_partition = default;
<<<<<<< HEAD
=======
set @@tidb_enable_exchange_partition=1;
drop table if exists pt1;
create table pt1(a int, b int, c int) PARTITION BY hash (a) partitions 1;
alter table pt1 add index idx((a+c));
drop table if exists nt1;
create table nt1(a int, b int, c int);
alter table pt1 exchange partition p0 with table nt1;
Error 1736 (HY000): Tables have different definitions
alter table nt1 add column (`_V$_idx_0` bigint(20) generated always as (a+b) virtual);
alter table pt1 exchange partition p0 with table nt1;
Error 1736 (HY000): Tables have different definitions
alter table nt1 drop column `_V$_idx_0`;
alter table nt1 add index idx((b-c));
alter table pt1 exchange partition p0 with table nt1;
Error 1736 (HY000): Tables have different definitions
alter table nt1 drop index idx;
alter table nt1 add index idx((concat(a, b)));
alter table pt1 exchange partition p0 with table nt1;
Error 1736 (HY000): Tables have different definitions
drop table if exists nt2;
create table nt2 (a int, b int, c int);
alter table nt2 add index idx((a+c));
alter table pt1 exchange partition p0 with table nt2;
set tidb_enable_global_index=true;
drop database if exists partition_exchange;
create database partition_exchange;
use partition_exchange;
create table pt (id int not null) partition by hash (id) partitions 4;
create table nt (id int(1) not null);
alter table pt exchange partition p0 with table nt;
create table pt1 (id int not null, fname varchar(3)) partition by hash (id) partitions 4;
create table nt1 (id int not null, fname varchar(4));
alter table pt1 exchange partition p0 with table nt1;
Error 1736 (HY000): Tables have different definitions
create table pt2 (id int not null, salary decimal) partition by hash(id) partitions 4;
create table nt2 (id int not null, salary decimal(3,2));
alter table pt2 exchange partition p0 with table nt2;
Error 1736 (HY000): Tables have different definitions
create table pt3 (id int not null, salary decimal) partition by hash(id) partitions 1;
create table nt3 (id int not null, salary decimal(10, 1));
alter table pt3 exchange partition p0 with table nt3;
Error 1736 (HY000): Tables have different definitions
create table pt4 (id int not null) partition by hash(id) partitions 1;
create table nt4 (id1 int not null);
alter table pt4 exchange partition p0 with table nt4;
Error 1736 (HY000): Tables have different definitions
create table pt5 (id int not null, primary key (id)) partition by hash(id) partitions 1;
create table nt5 (id int not null);
alter table pt5 exchange partition p0 with table nt5;
Error 1736 (HY000): Tables have different definitions
create table pt6 (id int not null, salary decimal, index idx (id, salary)) partition by hash(id) partitions 1;
create table nt6 (id int not null, salary decimal, index idx (salary, id));
alter table pt6 exchange partition p0 with table nt6;
Error 1736 (HY000): Tables have different definitions
create table pt7 (id int not null, index idx (id) invisible) partition by hash(id) partitions 1;
create table nt7 (id int not null, index idx (id));
alter table pt7 exchange partition p0 with table nt7;
create table pt8 (id int not null, index idx (id)) partition by hash(id) partitions 1;
create table nt8 (id int not null, index id_idx (id));
alter table pt8 exchange partition p0 with table nt8;
Error 1736 (HY000): Tables have different definitions
## Generated column (virtual)
create table pt10 (id int not null, lname varchar(30), fname varchar(100) generated always as (concat(lname,' ')) virtual) partition by hash(id) partitions 1;
create table nt10 (id int not null, lname varchar(30), fname varchar(100));
alter table pt10 exchange partition p0 with table nt10;
Error 3106 (HY000): 'Exchanging partitions for non-generated columns' is not supported for generated columns.
create table pt11 (id int not null, lname varchar(30), fname varchar(100)) partition by hash(id) partitions 1;
create table nt11 (id int not null, lname varchar(30), fname varchar(100) generated always as (concat(lname, ' ')) virtual);
alter table pt11 exchange partition p0 with table nt11;
Error 3106 (HY000): 'Exchanging partitions for non-generated columns' is not supported for generated columns.
create table pt12 (id int not null, lname varchar(30), fname varchar(100) generated always as (concat(lname,' ')) stored) partition by hash(id) partitions 1;
create table nt12 (id int not null, lname varchar(30), fname varchar(100));
alter table pt12 exchange partition p0 with table nt12;
Error 1736 (HY000): Tables have different definitions
create table pt13 (id int not null, lname varchar(30), fname varchar(100)) partition by hash(id) partitions 1;
create table nt13 (id int not null, lname varchar(30), fname varchar(100) generated always as (concat(lname, ' ')) stored);
alter table pt13 exchange partition p0 with table nt13;
Error 1736 (HY000): Tables have different definitions
create table pt14 (id int not null, lname varchar(30), fname varchar(100) generated always as (concat(lname, ' ')) virtual) partition by hash(id) partitions 1;
create table nt14 (id int not null, lname varchar(30), fname varchar(100) generated always as (concat(lname, ' ')) virtual);
alter table pt14 exchange partition p0 with table nt14;
## unique index
create table pt15 (id int not null, unique index uk_id (id)) partition by hash(id) partitions 1;
create table nt15 (id int not null, index uk_id (id));
alter table pt15 exchange partition p0 with table nt15;
Error 1736 (HY000): Tables have different definitions
## auto_increment
create table pt16 (id int not null primary key auto_increment) partition by hash(id) partitions 1;
create table nt16 (id int not null primary key);
alter table pt16 exchange partition p0 with table nt16;
Error 1736 (HY000): Tables have different definitions
## default
create table pt17 (id int not null default 1) partition by hash(id) partitions 1;
create table nt17 (id int not null);
alter table pt17 exchange partition p0 with table nt17;
## view test
create table pt18 (id int not null) partition by hash(id) partitions 1;
create view nt18 as select id from nt17;
alter table pt18 exchange partition p0 with table nt18;
Error 1177 (42000): Can't open table
create table pt19 (id int not null, lname varchar(30), fname varchar(100) generated always as (concat(lname, ' ')) stored) partition by hash(id) partitions 1;
create table nt19 (id int not null, lname varchar(30), fname varchar(100) generated always as (concat(lname, ' ')) virtual);
alter table pt19 exchange partition p0 with table nt19;
Error 3106 (HY000): 'Exchanging partitions for non-generated columns' is not supported for generated columns.
create table pt20 (id int not null) partition by hash(id) partitions 1;
create table nt20 (id int default null);
alter table pt20 exchange partition p0 with table nt20;
Error 1736 (HY000): Tables have different definitions
## unsigned
create table pt21 (id int unsigned) partition by hash(id) partitions 1;
create table nt21 (id int);
alter table pt21 exchange partition p0 with table nt21;
Error 1736 (HY000): Tables have different definitions
## zerofill
create table pt22 (id int) partition by hash(id) partitions 1;
create table nt22 (id int zerofill);
alter table pt22 exchange partition p0 with table nt22;
Error 1736 (HY000): Tables have different definitions
create table pt23 (id int, lname varchar(10) charset binary) partition by hash(id) partitions 1;
create table nt23 (id int, lname varchar(10));
alter table pt23 exchange partition p0 with table nt23;
Error 1736 (HY000): Tables have different definitions
create table pt25 (id int, a datetime on update current_timestamp) partition by hash(id) partitions 1;
create table nt25 (id int, a datetime);
alter table pt25 exchange partition p0 with table nt25;
create table pt26 (id int not null, lname varchar(30), fname varchar(100) generated always as (concat(lname, ' ')) virtual) partition by hash(id) partitions 1;
create table nt26 (id int not null, lname varchar(30), fname varchar(100) generated always as (concat(id, ' ')) virtual);
alter table pt26 exchange partition p0 with table nt26;
Error 1736 (HY000): Tables have different definitions
create table pt27 (a int key, b int, index(a)) partition by hash(a) partitions 1;
create table nt27 (a int not null, b int, index(a));
alter table pt27 exchange partition p0 with table nt27;
Error 1736 (HY000): Tables have different definitions
create table pt28 (a int primary key, b int, index(a)) partition by hash(a) partitions 1;
create table nt28 (a int not null, b int, index(a));
alter table pt28 exchange partition p0 with table nt28;
Error 1736 (HY000): Tables have different definitions
create table pt29 (a int primary key, b int) partition by hash(a) partitions 1;
create table nt29 (a int not null, b int, index(a));
alter table pt29 exchange partition p0 with table nt29;
Error 1736 (HY000): Tables have different definitions
create table pt30 (a int primary key, b int) partition by hash(a) partitions 1;
create table nt30 (a int, b int, unique index(a));
alter table pt30 exchange partition p0 with table nt30;
Error 1736 (HY000): Tables have different definitions
## auto_increment
create table pt31 (id bigint not null primary key auto_increment) partition by hash(id) partitions 1;
create table nt31 (id bigint not null primary key);
alter table pt31 exchange partition p0 with table nt31;
Error 1736 (HY000): Tables have different definitions
## auto_random
create table pt32 (id bigint not null primary key AUTO_RANDOM) partition by hash(id) partitions 1;
create table nt32 (id bigint not null primary key);
alter table pt32 exchange partition p0 with table nt32;
Error 1736 (HY000): Tables have different definitions
## global temporary table
create table pt33 (id int) partition by hash(id) partitions 1;
create global temporary table nt33 (id int) on commit delete rows;
alter table pt33 exchange partition p0 with table nt33;
Error 1733 (HY000): Table to exchange with partition is temporary: 'nt33'
## local temporary table
create table pt34 (id int) partition by hash(id) partitions 1;
create temporary table nt34 (id int);
alter table pt34 exchange partition p0 with table nt34;
Error 1733 (HY000): Table to exchange with partition is temporary: 'nt34'
## global index
create table pt35 (a int, b int, unique index(b)) partition by hash(a) partitions 1;
create table nt35 (a int, b int, unique index(b));
alter table pt35 exchange partition p0 with table nt35;
Error 1731 (HY000): Non matching attribute 'global index: b' between partition and table
drop database partition_exchange;
use ddl__db_partition;
set tidb_enable_global_index=default;
# 53385
drop table if exists t,t1;
create table t (id int not null, store_id int not null ) partition by range (store_id) (partition p0 values less than (6), partition p1 values less than (11), partition p2 values less than (16), partition p3 values less than (21));
Expand Down Expand Up @@ -3507,4 +3332,3 @@ id store_id _tidb_rowid
0 18 30257
1 1 30001
drop table t, t1;
>>>>>>> d5fece20f73 (ddl: Regenerating AutoIDs for _tidb_rowid during Reorganize Partition (#53770))
Loading

0 comments on commit f595a8a

Please sign in to comment.