Online ddl的测试判定

Online ddl的测试判定
一、创建测试表

| t1    | CREATE TABLE `t1` (
  `id` bigint(20) NOT NULL AUTO_INCREMENT,
  `name` varchar(32) DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `idx_name_idx_name_idx_name_idx_name_idx_name_idx_name_idx` (`name`) BLOCK_SIZE 16384 LOCAL
) AUTO_INCREMENT = 1000001 AUTO_INCREMENT_MODE = 'ORDER' DEFAULT CHARSET = utf8mb4 ROW_FORMAT = DYNAMIC COMPRESSION = 'zstd_1.3.8' REPLICA_NUM = 3 BLOCK_SIZE = 16384 USE_BLOOM_FILTER = FALSE TABLET_SIZE = 134217728 PCTFREE = 0 |

二、查看表的table id

obclient [test]> select table_id from oceanbase.DBA_OB_TABLE_LOCATIONS where table_name= 't1';
+----------+
| table_id |
+----------+
|   501156 |
|   501156 |
|   501156 |
+----------+

三、执行需要测试的ddl

obclient [test]> alter table t1 add column age int;
Query OK, 0 rows affected (0.228 sec)

四、再次查看表的table id

obclient [test]> select table_id from oceanbase.DBA_OB_TABLE_LOCATIONS where table_name= 't1';
+----------+
| table_id |
+----------+
|   501156 |
|   501156 |
|   501156 |
+----------+
3 rows in set (0.052 sec)

若table id没有变化,则该ddl是online的

obclient [test]> alter table t1 add column grade int after name ;
Query OK, 0 rows affected (1.673 sec)

obclient [test]> select table_id from oceanbase.DBA_OB_TABLE_LOCATIONS where table_name= 't1';
+----------+
| table_id |
+----------+
|   501427 |
|   501427 |
|   501427 |
+----------+
3 rows in set (0.005 sec)

若table id发生改变,则该ddl是offline的
可以将逻辑集成到CI/CD以自动判定

6 个赞

学到了

1 个赞

哦哦

1 个赞

11

mark学习

测试逻辑比较有局限性啊