From d1c541e926a4aa8d9a8c013a4c56ebafe1172a51 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E9=A3=9E?= Date: Thu, 11 Apr 2024 14:50:18 +0800 Subject: [PATCH 1/9] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E9=BB=98=E8=AE=A4?= =?UTF-8?q?=E7=9A=84=E6=AD=A3=E5=88=99=E8=A1=A8=E8=BE=BE=E5=BC=8F=EF=BC=8C?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0redis=E7=9A=84=E9=AB=98=E5=8D=B1=E6=93=8D?= =?UTF-8?q?=E4=BD=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sql/utils/workflow_audit.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/sql/utils/workflow_audit.py b/sql/utils/workflow_audit.py index e03bb18371..eabaaf93ca 100644 --- a/sql/utils/workflow_audit.py +++ b/sql/utils/workflow_audit.py @@ -211,7 +211,7 @@ def is_auto_review(self) -> bool: # 获取正则表达式 auto_review_regex = self.sys_config.get( - "auto_review_regex", "^alter|^create|^drop|^truncate|^rename|^delete" + "auto_review_regex", "^alter|^create|^drop|^truncate|^rename|^delete|^del|^flushdb|^flushall|^lpop|^rpop" ) p = re.compile(auto_review_regex, re.I) @@ -227,7 +227,9 @@ def is_auto_review(self) -> bool: # 匹配成功, 代表需要人工复核 return False # 影响行数加测, 总语句影响行数超过指定数量则需要人工审核 - all_affected_rows += int(review_result.affected_rows) + # 很多时候预测影响行数为0,影响行数规模判断。如果为0行,则改为1行。 + all_affected_rows += 1 if int(review_result.affected_rows) == 0 else int(review_result.affected_rows) + if all_affected_rows > int( self.sys_config.get("auto_review_max_update_rows", 50) ): From 9e77092815cf13c4dc942ebcbec794a726211ab6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E9=A3=9E?= Date: Thu, 11 Apr 2024 14:58:16 +0800 Subject: [PATCH 2/9] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=BD=B1=E5=93=8D?= =?UTF-8?q?=E8=A1=8C=E6=95=B0=E7=94=B10=E6=94=B91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sql/utils/workflow_audit.py | 1 - 1 file changed, 1 deletion(-) diff --git a/sql/utils/workflow_audit.py b/sql/utils/workflow_audit.py index eabaaf93ca..cd48df0f55 100644 --- a/sql/utils/workflow_audit.py +++ b/sql/utils/workflow_audit.py @@ -229,7 +229,6 @@ def is_auto_review(self) -> bool: # 影响行数加测, 总语句影响行数超过指定数量则需要人工审核 # 很多时候预测影响行数为0,影响行数规模判断。如果为0行,则改为1行。 all_affected_rows += 1 if int(review_result.affected_rows) == 0 else int(review_result.affected_rows) - if all_affected_rows > int( self.sys_config.get("auto_review_max_update_rows", 50) ): From 8807bfe9c7b4417cc607dcce2eddcc835ef8f7e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E9=A3=9E?= Date: Thu, 11 Apr 2024 15:05:20 +0800 Subject: [PATCH 3/9] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=AD=A3=E5=88=99?= =?UTF-8?q?=E8=A1=A8=E8=BE=BE=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sql/utils/workflow_audit.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/sql/utils/workflow_audit.py b/sql/utils/workflow_audit.py index cd48df0f55..7ca8b1fc6a 100644 --- a/sql/utils/workflow_audit.py +++ b/sql/utils/workflow_audit.py @@ -211,7 +211,8 @@ def is_auto_review(self) -> bool: # 获取正则表达式 auto_review_regex = self.sys_config.get( - "auto_review_regex", "^alter|^create|^drop|^truncate|^rename|^delete|^del|^flushdb|^flushall|^lpop|^rpop" + "auto_review_regex", + "^alter|^create|^drop|^truncate|^rename|^delete|^del|^flushdb|^flushall|^lpop|^rpop", ) p = re.compile(auto_review_regex, re.I) @@ -228,7 +229,11 @@ def is_auto_review(self) -> bool: return False # 影响行数加测, 总语句影响行数超过指定数量则需要人工审核 # 很多时候预测影响行数为0,影响行数规模判断。如果为0行,则改为1行。 - all_affected_rows += 1 if int(review_result.affected_rows) == 0 else int(review_result.affected_rows) + all_affected_rows += ( + 1 + if int(review_result.affected_rows) == 0 + else int(review_result.affected_rows) + ) if all_affected_rows > int( self.sys_config.get("auto_review_max_update_rows", 50) ): From 7122d82a6b86b0f7c1a13d13c7f7d6b559f5cfd3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E9=A3=9E?= Date: Thu, 11 Apr 2024 19:23:12 +0800 Subject: [PATCH 4/9] =?UTF-8?q?=E6=89=AB=E6=8F=8F/=E5=BD=B1=E5=93=8D?= =?UTF-8?q?=E8=A1=8C=E6=95=B0=EF=BC=8C=20=E6=B7=BB=E5=8A=A0tooltip?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sql/templates/sqlsubmit.html | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/sql/templates/sqlsubmit.html b/sql/templates/sqlsubmit.html index a455e0c239..b6e7c0ab0d 100644 --- a/sql/templates/sqlsubmit.html +++ b/sql/templates/sqlsubmit.html @@ -468,7 +468,7 @@ }, { title: '扫描/影响行数', field: 'affected_rows', - sortable: true + sortable: true, }, { title: '审核状态', field: 'errlevel', @@ -485,6 +485,7 @@ }, { title: '审核信息', field: 'errormessage', + formatter: function (value, row, index) { if (value === null) { return value @@ -545,7 +546,18 @@ } }); return html.join(''); + }, + onPostHeader:function(){ + var affected_rows_header = $('th[data-field="affected_rows"]'); + // 为这个元素添加Bootstrap tooltip所需的属性 + affected_rows_header.attr({ + 'data-toggle': 'tooltip', + 'title': '根据执行计划估算的受影响行数,供参考(Redis暂未支持)' + }); + affected_rows_header.tooltip(); + } + } ); //记录审核结果 From 078be2ebcdc5e0d726689e6905cd382971f383dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E9=A3=9E?= Date: Thu, 11 Apr 2024 19:25:12 +0800 Subject: [PATCH 5/9] =?UTF-8?q?=E6=B7=BB=E5=8A=A0tooltip?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sql/templates/sqlsubmit.html | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/sql/templates/sqlsubmit.html b/sql/templates/sqlsubmit.html index b6e7c0ab0d..0c337fc6cc 100644 --- a/sql/templates/sqlsubmit.html +++ b/sql/templates/sqlsubmit.html @@ -468,7 +468,7 @@ }, { title: '扫描/影响行数', field: 'affected_rows', - sortable: true, + sortable: true }, { title: '审核状态', field: 'errlevel', @@ -485,7 +485,6 @@ }, { title: '审核信息', field: 'errormessage', - formatter: function (value, row, index) { if (value === null) { return value @@ -557,7 +556,6 @@ affected_rows_header.tooltip(); } - } ); //记录审核结果 From a98dc33e1332ce928b197895c92889e7f0c281cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E9=A3=9E?= Date: Fri, 12 Apr 2024 09:51:23 +0800 Subject: [PATCH 6/9] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=BD=B1=E5=93=8D?= =?UTF-8?q?=E8=A1=8C=E6=95=B0=20=E5=AE=A1=E6=A0=B8=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sql/engines/redis.py | 2 +- sql/templates/sqlsubmit.html | 10 ---------- sql/utils/workflow_audit.py | 7 +------ 3 files changed, 2 insertions(+), 17 deletions(-) diff --git a/sql/engines/redis.py b/sql/engines/redis.py index a1ca6a1dd4..e1e99a9a61 100644 --- a/sql/engines/redis.py +++ b/sql/engines/redis.py @@ -204,7 +204,7 @@ def execute_workflow(self, workflow): id=line, errlevel=0, stagestatus="Execute Successfully", - errormessage="None", + errormessage="影响行数后续支持", sql=cmd, affected_rows=0, execute_time=t.cost, diff --git a/sql/templates/sqlsubmit.html b/sql/templates/sqlsubmit.html index 0c337fc6cc..a455e0c239 100644 --- a/sql/templates/sqlsubmit.html +++ b/sql/templates/sqlsubmit.html @@ -545,16 +545,6 @@ } }); return html.join(''); - }, - onPostHeader:function(){ - var affected_rows_header = $('th[data-field="affected_rows"]'); - // 为这个元素添加Bootstrap tooltip所需的属性 - affected_rows_header.attr({ - 'data-toggle': 'tooltip', - 'title': '根据执行计划估算的受影响行数,供参考(Redis暂未支持)' - }); - affected_rows_header.tooltip(); - } } ); diff --git a/sql/utils/workflow_audit.py b/sql/utils/workflow_audit.py index 7ca8b1fc6a..6383465322 100644 --- a/sql/utils/workflow_audit.py +++ b/sql/utils/workflow_audit.py @@ -228,12 +228,7 @@ def is_auto_review(self) -> bool: # 匹配成功, 代表需要人工复核 return False # 影响行数加测, 总语句影响行数超过指定数量则需要人工审核 - # 很多时候预测影响行数为0,影响行数规模判断。如果为0行,则改为1行。 - all_affected_rows += ( - 1 - if int(review_result.affected_rows) == 0 - else int(review_result.affected_rows) - ) + all_affected_rows += int(review_result.affected_rows) if all_affected_rows > int( self.sys_config.get("auto_review_max_update_rows", 50) ): From fe526b71ced2430a7069ce725ff28cb97ce8a849 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E9=A3=9E?= Date: Fri, 12 Apr 2024 09:56:14 +0800 Subject: [PATCH 7/9] =?UTF-8?q?Redis-Check=E6=B7=BB=E5=8A=A0=E8=AF=B4?= =?UTF-8?q?=E6=98=8E-=E5=BD=B1=E5=93=8D=E8=A1=8C=E6=95=B0=E5=90=8E?= =?UTF-8?q?=E7=BB=AD=E6=94=AF=E6=8C=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sql/engines/redis.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sql/engines/redis.py b/sql/engines/redis.py index e1e99a9a61..817c7b8379 100644 --- a/sql/engines/redis.py +++ b/sql/engines/redis.py @@ -178,7 +178,7 @@ def execute_check(self, db_name=None, sql=""): id=line, errlevel=0, stagestatus="Audit completed", - errormessage="None", + errormessage="影响行数后续支持", sql=cmd, affected_rows=0, execute_time=0, From df20e00da6549c48c66fbc9654c88eccd54feaac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E9=A3=9E?= Date: Fri, 12 Apr 2024 10:10:39 +0800 Subject: [PATCH 8/9] =?UTF-8?q?Redis-Check=E6=B7=BB=E5=8A=A0=E8=AF=B4?= =?UTF-8?q?=E6=98=8E-=E5=BD=B1=E5=93=8D=E8=A1=8C=E6=95=B0=E5=90=8E?= =?UTF-8?q?=E7=BB=AD=E6=94=AF=E6=8C=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sql/engines/tests.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sql/engines/tests.py b/sql/engines/tests.py index ca3bd67371..9c66105200 100644 --- a/sql/engines/tests.py +++ b/sql/engines/tests.py @@ -423,7 +423,7 @@ def test_execute_check(self): id=1, errlevel=0, stagestatus="Audit completed", - errormessage="None", + errormessage="影响行数后续支持", sql=sql, affected_rows=0, execute_time=0, @@ -440,7 +440,7 @@ def test_execute_workflow_success(self, _execute_command): id=1, errlevel=0, stagestatus="Execute Successfully", - errormessage="None", + errormessage="影响行数后续支持", sql=sql, affected_rows=0, execute_time=0, From e9c4da5fa3e8351e2140a5fcee21e247978141fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E9=A3=9E?= Date: Fri, 12 Apr 2024 10:29:08 +0800 Subject: [PATCH 9/9] =?UTF-8?q?check=E6=97=B6=E7=9A=84message=E6=98=BE?= =?UTF-8?q?=E7=A4=BA=E4=BF=AE=E6=94=B9=E3=80=82=E6=9A=82=E4=B8=8D=E6=94=AF?= =?UTF-8?q?=E6=8C=81=E6=98=BE=E7=A4=BA=E5=BD=B1=E5=93=8D=E8=A1=8C=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sql/engines/redis.py | 4 ++-- sql/engines/tests.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/sql/engines/redis.py b/sql/engines/redis.py index 817c7b8379..771ee60731 100644 --- a/sql/engines/redis.py +++ b/sql/engines/redis.py @@ -178,7 +178,7 @@ def execute_check(self, db_name=None, sql=""): id=line, errlevel=0, stagestatus="Audit completed", - errormessage="影响行数后续支持", + errormessage="暂不支持显示影响行数", sql=cmd, affected_rows=0, execute_time=0, @@ -204,7 +204,7 @@ def execute_workflow(self, workflow): id=line, errlevel=0, stagestatus="Execute Successfully", - errormessage="影响行数后续支持", + errormessage="暂不支持显示影响行数", sql=cmd, affected_rows=0, execute_time=t.cost, diff --git a/sql/engines/tests.py b/sql/engines/tests.py index 9c66105200..74654ac01b 100644 --- a/sql/engines/tests.py +++ b/sql/engines/tests.py @@ -423,7 +423,7 @@ def test_execute_check(self): id=1, errlevel=0, stagestatus="Audit completed", - errormessage="影响行数后续支持", + errormessage="暂不支持显示影响行数", sql=sql, affected_rows=0, execute_time=0, @@ -440,7 +440,7 @@ def test_execute_workflow_success(self, _execute_command): id=1, errlevel=0, stagestatus="Execute Successfully", - errormessage="影响行数后续支持", + errormessage="暂不支持显示影响行数", sql=sql, affected_rows=0, execute_time=0,