@@ -359,6 +359,41 @@ id name
3593593 Data3
3603604 Fork_Data
361361============================================
362+ 10. Fork Table复制truncate info功能验证
363+ ============================================
364+ alter system set _ob_enable_truncate_partition_preserve_global_index = true;
365+ drop table if exists t_trunc;
366+ Warnings:
367+ Note 1051 Unknown table 'db_fork_basic.t_trunc'
368+ drop table if exists t_trunc_fork;
369+ Warnings:
370+ Note 1051 Unknown table 'db_fork_basic.t_trunc_fork'
371+ create table t_trunc (
372+ id int primary key,
373+ k int,
374+ c varchar(20)
375+ ) partition by range(id) (
376+ partition p0 values less than (100),
377+ partition p1 values less than (200)
378+ );
379+ create unique index idx_k on t_trunc(k) global partition by hash(k) partitions 2;
380+ insert into t_trunc values (1, 1, 'a'), (2, 2, 'b'), (120, 3, 'c');
381+ # 生成truncate info并保留索引
382+ alter table t_trunc truncate partition p0;
383+ # 截断后重新写入数据,验证旧数据不会被fork带回
384+ insert into t_trunc values (5, 5, 'p0_new'), (6, 6, 'p0_new2');
385+ # 源表校验(使用全局索引访问)
386+ select /*+index(t_trunc idx_k)*/ count(*) from t_trunc;
387+ count(*)
388+ 3
389+ select /*+index(t_trunc idx_k)*/ count(*) from t_trunc where id in (1,2);
390+ count(*)
391+ 0
392+ # 执行Fork并等待完成
393+ fork table t_trunc to t_trunc_fork;
394+ ERROR 0A000: fork table on partitioned table with global index is not supported
395+ # 目标表校验:应只包含新数据,截断过的数据不应出现
396+ ============================================
3623976. 清理
363398============================================
364399drop table if exists t1;
@@ -372,8 +407,6 @@ drop table if exists t4_fork;
372407drop table if exists t5;
373408drop table if exists t5_fork;
374409drop table if exists t_trunc;
375- Warnings:
376- Note 1051 Unknown table 'db_fork_basic.t_trunc'
377410drop table if exists t_trunc_fork;
378411Warnings:
379412Note 1051 Unknown table 'db_fork_basic.t_trunc_fork'
0 commit comments