Yearning icon indicating copy to clipboard operation
Yearning copied to clipboard

更新索引时提示索引重复

Open Euthpic opened this issue 4 years ago • 1 comments

Describe the bug 描述Bug

以下语句在语句检测时会提示索引重复,索引数量超出限制.

ALTER TABLE `order`.`orders`
DROP INDEX `order_index`,
ADD INDEX `order_index`(`id`, `status`) USING BTREE;

可是这两条语句是同一个事物里面的,事务提交后没有这些问题.语句检测能否以事务为单位进行?以避免这类的语句在事务执行后没有超出限制,但是却在语句检测时被限制住了.

To Reproduce 如何复现

Expected behavior 期望的结果

Screenshots 截图

Desktop (please complete the following information): 环境

  • OS: [e.g. iOS]
  • Browser [e.g. chrome, safari]
  • Version [e.g. 22]

Additional context 其他 Add any other context about the problem here.

Euthpic avatar Jun 30 '21 04:06 Euthpic

Yearning采用预检查的方法进行SQL检测,对于同一工单内添加并编辑的语句会产生字段不存在的错误。(在2.3.0版本开始将逐步兼容)

例如

ALTER TABLE core_data_sources ADD t1 int( 11) DEFAULT 0 COMMENT '已退换货数量'; ALTER TABLE core_data_sources ADD t2 int( 11) DEFAULT 0 COMMENT '申请中数量' AFTER t1; 该工单第二条语句依赖第一条语句创建的字段。由于当前数据库并没有t1这个字段,所以该工单检测时会报错t1字段不存在的问题。

语句本身没有问题因为在mysql执行中是逐条执行并检测。当第一条执行后表内生成该字段,第二条执行前检测自然也就正常。

cookieY avatar Jun 30 '21 05:06 cookieY