From 7c3b13dab41c1b067d81e690e1b0306cb0e90856 Mon Sep 17 00:00:00 2001 From: "Captain.B" Date: Mon, 24 May 2021 16:25:07 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E5=90=88=E5=B9=B6sql?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../db/migration/V85__v.1.10_add_num.sql | 50 ------------------- 1 file changed, 50 deletions(-) delete mode 100644 backend/src/main/resources/db/migration/V85__v.1.10_add_num.sql diff --git a/backend/src/main/resources/db/migration/V85__v.1.10_add_num.sql b/backend/src/main/resources/db/migration/V85__v.1.10_add_num.sql deleted file mode 100644 index f7d17d0569..0000000000 --- a/backend/src/main/resources/db/migration/V85__v.1.10_add_num.sql +++ /dev/null @@ -1,50 +0,0 @@ -alter table issues add num int null; - -DROP PROCEDURE IF EXISTS test_cursor; -DELIMITER // -CREATE PROCEDURE test_cursor() -BEGIN - DECLARE projectId VARCHAR(64); - DECLARE issueId VARCHAR(64); - DECLARE num INT; - DECLARE done INT DEFAULT 0; - DECLARE cursor1 CURSOR FOR (SELECT DISTINCT project_id - FROM issues - WHERE num IS NULL); - DECLARE cursor2 CURSOR FOR (SELECT id - FROM issues - WHERE project_id = projectId - ORDER BY create_time); - - DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = TRUE; - OPEN cursor1; - outer_loop: - LOOP - FETCH cursor1 INTO projectId; - IF done - THEN - LEAVE outer_loop; - END IF; - SET num = 100001; - OPEN cursor2; - inner_loop: - LOOP - FETCH cursor2 INTO issueId; - IF done - THEN - LEAVE inner_loop; - END IF; - UPDATE issues - SET num = num - WHERE id = issueId; - SET num = num + 1; - END LOOP; - SET done = 0; - CLOSE cursor2; - END LOOP; - CLOSE cursor1; -END // -DELIMITER ; - -CALL test_cursor(); -DROP PROCEDURE IF EXISTS test_cursor; \ No newline at end of file