This is an automated email from the ASF dual-hosted git repository.
zhangliang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git
The following commit(s) were added to refs/heads/master by this push:
new 4d32ab2b7f4 add audit document (#21029)
4d32ab2b7f4 is described below
commit 4d32ab2b7f461f3626eb721d2ffa23334fe4e2e2
Author: Zonglei Dong <[email protected]>
AuthorDate: Sun Sep 25 20:09:39 2022 +0800
add audit document (#21029)
* add sharding audit document.
* Fixes log mistake.
* add audit reserved word for document.
---
.../sharding/alter-sharding-table-rule.cn.md | 16 +++-
.../sharding/alter-sharding-table-rule.en.md | 17 ++++-
.../sharding/create-sharding-auditor.cn.md | 50 +++++++++++++
.../sharding/create-sharding-auditor.en.md | 51 +++++++++++++
.../sharding/create-sharding-table-rule.cn.md | 16 +++-
.../sharding/create-sharding-table-rule.en.md | 12 ++-
.../reference/distsql/syntax/reserved-word.cn.md | 3 +-
.../reference/distsql/syntax/reserved-word.en.md | 3 +-
.../common-config/builtin-algorithm/audit.cn.md | 28 +++++++
.../common-config/builtin-algorithm/audit.en.md | 28 +++++++
.../common-config/builtin-algorithm/keygen.en.md | 1 +
.../java-api/rules/sharding.cn.md | 69 +++++++++++-------
.../java-api/rules/sharding.en.md | 56 +++++++++-----
.../spring-boot-starter/rules/sharding.cn.md | 11 +++
.../spring-boot-starter/rules/sharding.en.md | 11 +++
.../spring-namespace/rules/sharding.cn.md | 85 ++++++++++++++++------
.../spring-namespace/rules/sharding.en.md | 65 ++++++++++++++---
.../yaml-config/rules/sharding.cn.md | 18 +++++
.../yaml-config/rules/sharding.en.md | 19 +++++
.../syntax/rdl/rule-definition/sharding.cn.md | 57 +++++++++++++--
.../syntax/rdl/rule-definition/sharding.en.md | 57 +++++++++++++--
.../distsql/syntax/rql/rule-query/sharding.cn.md | 82 +++++++++++++++------
.../distsql/syntax/rql/rule-query/sharding.en.md | 54 +++++++++++---
.../test/integration/engine/rql/BaseRQLIT.java | 4 +-
24 files changed, 675 insertions(+), 138 deletions(-)
diff --git
a/docs/document/content/reference/distsql/syntax/rdl/rule-definition/sharding/alter-sharding-table-rule.cn.md
b/docs/document/content/reference/distsql/syntax/rdl/rule-definition/sharding/alter-sharding-table-rule.cn.md
index d2c00cbfcbb..dd72c3fb200 100644
---
a/docs/document/content/reference/distsql/syntax/rdl/rule-definition/sharding/alter-sharding-table-rule.cn.md
+++
b/docs/document/content/reference/distsql/syntax/rdl/rule-definition/sharding/alter-sharding-table-rule.cn.md
@@ -14,16 +14,21 @@ AlterShardingTableRule ::=
'ALTER' 'SHARDING' 'TABLE' 'RULE' ( tableDefinition | autoTableDefinition )
( ',' ( tableDefinition | autoTableDefinition ) )*
tableDefinition ::=
- tableName '(' 'DATANODES' '(' dataNode ( ',' dataNode )* ')' ( ','
'DATABASE_STRATEGY' '(' strategyDefinition ')' )? ( ',' 'TABLE_STRATEGY' '('
strategyDefinition ')' )? ( ',' 'KEY_GENERATE_STRATEGY' '('
keyGenerateStrategyDefinition ')' )? ')'
+ tableName '(' 'DATANODES' '(' dataNode ( ',' dataNode )* ')' ( ','
'DATABASE_STRATEGY' '(' strategyDefinition ')' )? ( ',' 'TABLE_STRATEGY' '('
strategyDefinition ')' )? ( ',' 'KEY_GENERATE_STRATEGY' '('
keyGenerateStrategyDefinition ')' )? ( ',' 'AUDIT_STRATEGY' '('
auditStrategyDefinition ')' )? ')'
autoTableDefinition ::=
- tableName '(' 'RESOURCES' '(' resourceName ( ',' resourceName )* ')' ','
'SHARDING_COLUMN' '=' columnName ',' algorithmDefinition ( ','
'KEY_GENERATE_STRATEGY' '(' keyGenerateStrategyDefinition ')' )?')'
+ tableName '(' 'RESOURCES' '(' resourceName ( ',' resourceName )* ')' ','
'SHARDING_COLUMN' '=' columnName ',' algorithmDefinition ( ','
'KEY_GENERATE_STRATEGY' '(' keyGenerateStrategyDefinition ')' )? ( ','
'AUDIT_STRATEGY' '(' auditStrategyDefinition ')' )? ')'
strategyDefinition ::=
'TYPE' '=' strategyType ',' ( 'SHARDING_COLUMN' | 'SHARDING_COLUMNS' ) '='
columnName ',' algorithmDefinition
keyGenerateStrategyDefinition ::=
'KEY_GENERATE_STRATEGY' '(' 'COLUMN' '=' columnName ',' ( 'KEY_GENERATOR'
'=' algorihtmName | algorithmDefinition ) ')'
+
+auditStrategyDefinition ::=
+ 'AUDIT_STRATEGY' '(' 'AUDITORS' '=' '[' auditorName ',' auditorName ']' ','
'ALLOW_HINT_DISABLE' '=' 'TRUE | FALSE' ')'
+ |
+ 'AUDIT_STRATEGY' '(' '[' 'NAME' '=' auditorName ',' algorithmDefinition ']'
',' '[' 'NAME' '=' auditorName ',' algorithmDefinition ']' ')'
algorithmDefinition ::=
('SHARDING_ALGORITHM' '=' algorithmName | 'TYPE' '(' 'NAME' '='
algorithmType ( ',' 'PROPERTIES' '(' propertyDefinition ')' )?')' )
@@ -39,6 +44,9 @@ resourceName ::=
columnName ::=
identifier
+
+auditorName ::=
+ identifier
algorithmName ::=
identifier
@@ -64,6 +72,8 @@ strategyType ::=
- 自动生成的主键策略命名规则为 `tableName` _ `strategyType`;
- `KEY_GENERATE_STRATEGY`
用于指定主键生成策略,为可选项,关于主键生成策略可参考[分布式主键](/cn/user-manual/common-config/builtin-algorithm/keygen/)。
+- `AUDIT_STRATEGY`
+
用于指定分配审计生成策略,为可选项,关于分片审计生成策略可参考[分片审计](/cn/user-manual/common-config/builtin-algorithm/audit/)。
### 示例
@@ -158,7 +168,7 @@ ALTER SHARDING TABLE RULE t_order (
### 保留字
-`ALTER`、`SHARDING`、`TABLE`、`RULE`、`DATANODES`、`DATABASE_STRATEGY`、`TABLE_STRATEGY`、`KEY_GENERATE_STRATEGY`、`RESOURCES`、`SHARDING_COLUMN`、`TYPE`、`SHARDING_COLUMN`、`KEY_GENERATOR`、`SHARDING_ALGORITHM`、`COLUMN`、`NAME`、`PROPERTIES`
+`ALTER`、`SHARDING`、`TABLE`、`RULE`、`DATANODES`、`DATABASE_STRATEGY`、`TABLE_STRATEGY`、`KEY_GENERATE_STRATEGY`、`RESOURCES`、`SHARDING_COLUMN`、`TYPE`、`SHARDING_COLUMN`、`KEY_GENERATOR`、`SHARDING_ALGORITHM`、`COLUMN`、`NAME`、`PROPERTIES`、`AUDIT_STRATEGY`、`AUDITORS`、`ALLOW_HINT_DISABLE`
### 相关链接
diff --git
a/docs/document/content/reference/distsql/syntax/rdl/rule-definition/sharding/alter-sharding-table-rule.en.md
b/docs/document/content/reference/distsql/syntax/rdl/rule-definition/sharding/alter-sharding-table-rule.en.md
index 5ed616573ab..cb0b623a95c 100644
---
a/docs/document/content/reference/distsql/syntax/rdl/rule-definition/sharding/alter-sharding-table-rule.en.md
+++
b/docs/document/content/reference/distsql/syntax/rdl/rule-definition/sharding/alter-sharding-table-rule.en.md
@@ -14,10 +14,10 @@ AlterShardingTableRule ::=
'ALTER' 'SHARDING' 'TABLE' 'RULE' ( tableDefinition | autoTableDefinition )
( ',' ( tableDefinition | autoTableDefinition ) )*
tableDefinition ::=
- tableName '(' 'DATANODES' '(' dataNode ( ',' dataNode )* ')' ( ','
'DATABASE_STRATEGY' '(' strategyDefinition ')' )? ( ',' 'TABLE_STRATEGY' '('
strategyDefinition ')' )? ( ',' 'KEY_GENERATE_STRATEGY' '('
keyGenerateStrategyDefinition ')' )? ')'
+ tableName '(' 'DATANODES' '(' dataNode ( ',' dataNode )* ')' ( ','
'DATABASE_STRATEGY' '(' strategyDefinition ')' )? ( ',' 'TABLE_STRATEGY' '('
strategyDefinition ')' )? ( ',' 'KEY_GENERATE_STRATEGY' '('
keyGenerateStrategyDefinition ')' )? ( ',' 'AUDIT_STRATEGY' '('
auditStrategyDefinition ')' )? ')'
autoTableDefinition ::=
- tableName '(' 'RESOURCES' '(' resourceName ( ',' resourceName )* ')' ','
'SHARDING_COLUMN' '=' columnName ',' algorithmDefinition ( ','
'KEY_GENERATE_STRATEGY' '(' keyGenerateStrategyDefinition ')' )?')'
+ tableName '(' 'RESOURCES' '(' resourceName ( ',' resourceName )* ')' ','
'SHARDING_COLUMN' '=' columnName ',' algorithmDefinition ( ','
'KEY_GENERATE_STRATEGY' '(' keyGenerateStrategyDefinition ')' )? ( ','
'AUDIT_STRATEGY' '(' auditStrategyDefinition ')' )? ')'
strategyDefinition ::=
'TYPE' '=' strategyType ',' ( 'SHARDING_COLUMN' | 'SHARDING_COLUMNS' ) '='
columnName ',' algorithmDefinition
@@ -25,6 +25,11 @@ strategyDefinition ::=
keyGenerateStrategyDefinition ::=
'KEY_GENERATE_STRATEGY' '(' 'COLUMN' '=' columnName ',' ( 'KEY_GENERATOR'
'=' algorihtmName | algorithmDefinition ) ')'
+auditStrategyDefinition ::=
+ 'AUDIT_STRATEGY' '(' 'AUDITORS' '=' '[' auditorName ',' auditorName ']' ','
'ALLOW_HINT_DISABLE' '=' 'TRUE | FALSE' ')'
+ |
+ 'AUDIT_STRATEGY' '(' '[' 'NAME' '=' auditorName ',' algorithmDefinition ']'
',' '[' 'NAME' '=' auditorName ',' algorithmDefinition ']' ')'
+
algorithmDefinition ::=
('SHARDING_ALGORITHM' '=' algorithmName | 'TYPE' '(' 'NAME' '='
algorithmType ( ',' 'PROPERTIES' '(' propertyDefinition ')' )?')' )
@@ -40,6 +45,9 @@ resourceName ::=
columnName ::=
identifier
+auditorName ::=
+ identifier
+
algorithmName ::=
identifier
@@ -73,6 +81,9 @@ strategyType ::=
- `KEY_GENERATE_STRATEGY` is used to specify the primary key generation
strategy, which is optional. For the primary key
generation strategy, please refer
to [Distributed Primary
Key](/en/user-manual/common-config/builtin-algorithm/keygen/).
+- `AUDIT_STRATEGY` is used to specify the sharding audit strategy, which is
optional. For the sharding audit
+ generation strategy, please refer
+ to [Sharding Audit](/en/user-manual/common-config/builtin-algorithm/audit/).
### Example
@@ -167,7 +178,7 @@ ALTER SHARDING TABLE RULE t_order (
### Reserved word
-`ALTER`, `SHARDING`, `TABLE`, `RULE`, `DATANODES`, `DATABASE_STRATEGY`,
`TABLE_STRATEGY`, `KEY_GENERATE_STRATEGY`, `RESOURCES`, `SHARDING_COLUMN`,
`TYPE`, `SHARDING_COLUMN`, `KEY_GENERATOR`, `SHARDING_ALGORITHM`, `COLUMN`,
`NAME`, `PROPERTIES`
+`ALTER`, `SHARDING`, `TABLE`, `RULE`, `DATANODES`, `DATABASE_STRATEGY`,
`TABLE_STRATEGY`, `KEY_GENERATE_STRATEGY`, `RESOURCES`, `SHARDING_COLUMN`,
`TYPE`, `SHARDING_COLUMN`, `KEY_GENERATOR`, `SHARDING_ALGORITHM`, `COLUMN`,
`NAME`, `PROPERTIES`, `AUDIT_STRATEGY`, `AUDITORS`, `ALLOW_HINT_DISABLE`
### Related links
diff --git
a/docs/document/content/reference/distsql/syntax/rdl/rule-definition/sharding/create-sharding-auditor.cn.md
b/docs/document/content/reference/distsql/syntax/rdl/rule-definition/sharding/create-sharding-auditor.cn.md
new file mode 100644
index 00000000000..5f1b7b9238b
--- /dev/null
+++
b/docs/document/content/reference/distsql/syntax/rdl/rule-definition/sharding/create-sharding-auditor.cn.md
@@ -0,0 +1,50 @@
++++
+title = "CREATE SHARDING AUDITOR"
+weight = 8
++++
+
+## 描述
+
+`CREATE SHARDING AUDITOR` 语法用于为当前所选的逻辑库添加分片审计生成器
+
+### 语法定义
+
+```sql
+CreateShardingAlgorithm ::=
+ 'CREATE' 'SHARDING' 'AUDITOR' auditorName '(' algorithmDefinition ')'
+
+algorithmDefinition ::=
+ 'TYPE' '(' 'NAME' '=' algorithmType ( ',' 'PROPERTIES' '('
propertyDefinition ')' )?')'
+
+propertyDefinition ::=
+ ( key '=' value ) ( ',' key '=' value )*
+
+auditorName ::=
+ identifier
+
+algorithmType ::=
+ string
+```
+
+### 补充说明
+
+- `algorithmType`
+
为分片审计算法类型,详细的分片审计生成算法类型信息请参考[分片审计算法类型](cn/user-manual/common-config/builtin-algorithm/audit/)。
+
+### 示例
+
+#### 创建分片审计器
+
+```sql
+CREATE SHARDING AUDITOR sharding_key_required_auditor (
+ TYPE(NAME="DML_SHARDING_CONDITIONS", PROPERTIES("a"="b"))
+);
+```
+
+### 保留字
+
+`CREATE`、`SHARDING`、`AUDITOR`、`TYPE`、`NAME`、`PROPERTIES`
+
+### 相关链接
+
+- [保留字](/cn/reference/distsql/syntax/reserved-word/)
diff --git
a/docs/document/content/reference/distsql/syntax/rdl/rule-definition/sharding/create-sharding-auditor.en.md
b/docs/document/content/reference/distsql/syntax/rdl/rule-definition/sharding/create-sharding-auditor.en.md
new file mode 100644
index 00000000000..6dc9ebc142a
--- /dev/null
+++
b/docs/document/content/reference/distsql/syntax/rdl/rule-definition/sharding/create-sharding-auditor.en.md
@@ -0,0 +1,51 @@
++++
+title = "CREATE SHARDING AUDITOR"
+weight = 8
++++
+
+## Description
+
+The `CREATE SHARDING AUDITOR` syntax is used to add a sharding key auditor for
the currently selected
+logic database
+
+### Syntax
+
+```sql
+CreateShardingAlgorithm ::=
+ 'CREATE' 'SHARDING' 'AUDITOR' auditorName '(' algorithmDefinition ')'
+
+algorithmDefinition ::=
+ 'TYPE' '(' 'NAME' '=' algorithmType ( ',' 'PROPERTIES' '('
propertyDefinition ')' )?')'
+
+propertyDefinition ::=
+ ( key '=' value ) ( ',' key '=' value )*
+
+auditorName ::=
+ identifier
+
+algorithmType ::=
+ string
+```
+
+### Supplement
+
+- `algorithmType` is the sharding audit algorithm type. For detailed sharding
audit algorithm type information, please refer
+ to [SHARDING AUDIT
ALGORITHM](en/user-manual/common-config/builtin-algorithm/audit/).
+
+### Example
+
+#### Create a sharding auditor
+
+```sql
+CREATE SHARDING AUDITOR sharding_key_required_auditor (
+ TYPE(NAME="DML_SHARDING_CONDITIONS", PROPERTIES("a"="b"))
+);
+```
+
+### Reserved word
+
+`CREATE`, `SHARDING`, `AUDITOR`, `TYPE`, `NAME`, `PROPERTIES`
+
+### Related links
+
+- [Reserved word](/en/reference/distsql/syntax/reserved-word/)
diff --git
a/docs/document/content/reference/distsql/syntax/rdl/rule-definition/sharding/create-sharding-table-rule.cn.md
b/docs/document/content/reference/distsql/syntax/rdl/rule-definition/sharding/create-sharding-table-rule.cn.md
index 570a464a886..676c0da72b8 100644
---
a/docs/document/content/reference/distsql/syntax/rdl/rule-definition/sharding/create-sharding-table-rule.cn.md
+++
b/docs/document/content/reference/distsql/syntax/rdl/rule-definition/sharding/create-sharding-table-rule.cn.md
@@ -14,10 +14,10 @@ CreateShardingTableRule ::=
'CREATE' 'SHARDING' 'TABLE' 'RULE' ( tableDefinition | autoTableDefinition )
( ',' ( tableDefinition | autoTableDefinition ) )*
tableDefinition ::=
- tableName '(' 'DATANODES' '(' dataNode ( ',' dataNode )* ')' ( ','
'DATABASE_STRATEGY' '(' strategyDefinition ')' )? ( ',' 'TABLE_STRATEGY' '('
strategyDefinition ')' )? ( ',' 'KEY_GENERATE_STRATEGY' '('
keyGenerateStrategyDefinition ')' )? ')'
+ tableName '(' 'DATANODES' '(' dataNode ( ',' dataNode )* ')' ( ','
'DATABASE_STRATEGY' '(' strategyDefinition ')' )? ( ',' 'TABLE_STRATEGY' '('
strategyDefinition ')' )? ( ',' 'KEY_GENERATE_STRATEGY' '('
keyGenerateStrategyDefinition ')' )? ( ',' 'AUDIT_STRATEGY' '('
auditStrategyDefinition ')' )? ')'
autoTableDefinition ::=
- tableName '(' 'RESOURCES' '(' resourceName ( ',' resourceName )* ')' ','
'SHARDING_COLUMN' '=' columnName ',' algorithmDefinition ( ','
'KEY_GENERATE_STRATEGY' '(' keyGenerateStrategyDefinition ')' )?')'
+ tableName '(' 'RESOURCES' '(' resourceName ( ',' resourceName )* ')' ','
'SHARDING_COLUMN' '=' columnName ',' algorithmDefinition ( ','
'KEY_GENERATE_STRATEGY' '(' keyGenerateStrategyDefinition ')' )? ( ','
'AUDIT_STRATEGY' '(' auditStrategyDefinition ')' )? ')'
strategyDefinition ::=
'TYPE' '=' strategyType ',' ( 'SHARDING_COLUMN' | 'SHARDING_COLUMNS' ) '='
columnName ',' algorithmDefinition
@@ -25,6 +25,11 @@ strategyDefinition ::=
keyGenerateStrategyDefinition ::=
'KEY_GENERATE_STRATEGY' '(' 'COLUMN' '=' columnName ',' ( 'KEY_GENERATOR'
'=' algorihtmName | algorithmDefinition ) ')'
+auditStrategyDefinition ::=
+ 'AUDIT_STRATEGY' '(' 'AUDITORS' '=' '[' auditorName ',' auditorName ']' ','
'ALLOW_HINT_DISABLE' '=' 'TRUE | FALSE' ')'
+ |
+ 'AUDIT_STRATEGY' '(' '[' 'NAME' '=' auditorName ',' algorithmDefinition ']'
',' '[' 'NAME' '=' auditorName ',' algorithmDefinition ']' ')'
+
algorithmDefinition ::=
('SHARDING_ALGORITHM' '=' algorithmName | 'TYPE' '(' 'NAME' '='
algorithmType ( ',' 'PROPERTIES' '(' propertyDefinition ')' )?')' )
@@ -39,6 +44,9 @@ resourceName ::=
columnName ::=
identifier
+
+auditorName ::=
+ identifier
algorithmName ::=
identifier
@@ -64,6 +72,8 @@ algorithmType ::=
- 自动生成的主键策略命名规则为 `tableName` _ `strategyType;
- `KEY_GENERATE_STRATEGY`
用于指定主键生成策略,为可选项,关于主键生成策略可参考[分布式主键](/cn/user-manual/common-config/builtin-algorithm/keygen/)。
+- `AUDIT_STRATEGY`
+
用于指定分配审计生成策略,为可选项,关于分片审计生成策略可参考[分片审计](/cn/user-manual/common-config/builtin-algorithm/audit/)。
### 示例
@@ -158,7 +168,7 @@ CREATE SHARDING TABLE RULE t_order (
### 保留字
-`CREATE`、`SHARDING`、`TABLE`、`RULE`、`DATANODES`、`DATABASE_STRATEGY`、`TABLE_STRATEGY`、`KEY_GENERATE_STRATEGY`、`RESOURCES`、`SHARDING_COLUMN`、`TYPE`、`SHARDING_COLUMN`、`KEY_GENERATOR`、`SHARDING_ALGORITHM`、`COLUMN`、`NAME`、`PROPERTIES`
+`CREATE`、`SHARDING`、`TABLE`、`RULE`、`DATANODES`、`DATABASE_STRATEGY`、`TABLE_STRATEGY`、`KEY_GENERATE_STRATEGY`、`RESOURCES`、`SHARDING_COLUMN`、`TYPE`、`SHARDING_COLUMN`、`KEY_GENERATOR`、`SHARDING_ALGORITHM`、`COLUMN`、`NAME`、`PROPERTIES`、`AUDIT_STRATEGY`、`AUDITORS`、`ALLOW_HINT_DISABLE`
### 相关链接
diff --git
a/docs/document/content/reference/distsql/syntax/rdl/rule-definition/sharding/create-sharding-table-rule.en.md
b/docs/document/content/reference/distsql/syntax/rdl/rule-definition/sharding/create-sharding-table-rule.en.md
index d932e9f53d4..3a8b6b159a1 100644
---
a/docs/document/content/reference/distsql/syntax/rdl/rule-definition/sharding/create-sharding-table-rule.en.md
+++
b/docs/document/content/reference/distsql/syntax/rdl/rule-definition/sharding/create-sharding-table-rule.en.md
@@ -14,10 +14,10 @@ CreateShardingTableRule ::=
'CREATE' 'SHARDING' 'TABLE' 'RULE' ( tableDefinition | autoTableDefinition )
( ',' ( tableDefinition | autoTableDefinition ) )*
tableDefinition ::=
- tableName '(' 'DATANODES' '(' dataNode ( ',' dataNode )* ')' ( ','
'DATABASE_STRATEGY' '(' strategyDefinition ')' )? ( ',' 'TABLE_STRATEGY' '('
strategyDefinition ')' )? ( ',' 'KEY_GENERATE_STRATEGY' '('
keyGenerateStrategyDefinition ')' )? ')'
+ tableName '(' 'DATANODES' '(' dataNode ( ',' dataNode )* ')' ( ','
'DATABASE_STRATEGY' '(' strategyDefinition ')' )? ( ',' 'TABLE_STRATEGY' '('
strategyDefinition ')' )? ( ',' 'KEY_GENERATE_STRATEGY' '('
keyGenerateStrategyDefinition ')' )? ( ',' 'AUDIT_STRATEGY' '('
auditStrategyDefinition ')' )? ')'
autoTableDefinition ::=
- tableName '(' 'RESOURCES' '(' resourceName ( ',' resourceName )* ')' ','
'SHARDING_COLUMN' '=' columnName ',' algorithmDefinition ( ','
'KEY_GENERATE_STRATEGY' '(' keyGenerateStrategyDefinition ')' )?')'
+ tableName '(' 'RESOURCES' '(' resourceName ( ',' resourceName )* ')' ','
'SHARDING_COLUMN' '=' columnName ',' algorithmDefinition ( ','
'KEY_GENERATE_STRATEGY' '(' keyGenerateStrategyDefinition ')' )? ( ','
'AUDIT_STRATEGY' '(' auditStrategyDefinition ')' )? ')'
strategyDefinition ::=
'TYPE' '=' strategyType ',' ( 'SHARDING_COLUMN' | 'SHARDING_COLUMNS' ) '='
columnName ',' algorithmDefinition
@@ -39,6 +39,9 @@ resourceName ::=
columnName ::=
identifier
+
+auditorName ::=
+ identifier
algorithmName ::=
identifier
@@ -73,6 +76,9 @@ algorithmType ::=
- `KEY_GENERATE_STRATEGY` is used to specify the primary key generation
strategy, which is optional. For the primary key
generation strategy, please refer
to [Distributed Primary
Key](/en/user-manual/common-config/builtin-algorithm/keygen/).
+- `AUDIT_STRATEGY` is used to specify the sharding audit strategy, which is
optional. For the sharding audit
+ generation strategy, please refer
+ to [Sharding Audit](/en/user-manual/common-config/builtin-algorithm/audit/).
### Example
@@ -167,7 +173,7 @@ CREATE SHARDING TABLE RULE t_order (
### Reserved word
-`CREATE`, `SHARDING`, `TABLE`, `RULE`, `DATANODES`, `DATABASE_STRATEGY`,
`TABLE_STRATEGY`, `KEY_GENERATE_STRATEGY`, `RESOURCES`, `SHARDING_COLUMN`,
`TYPE`, `SHARDING_COLUMN`, `KEY_GENERATOR`, `SHARDING_ALGORITHM`, `COLUMN`,
`NAME`, `PROPERTIES`
+`CREATE`, `SHARDING`, `TABLE`, `RULE`, `DATANODES`, `DATABASE_STRATEGY`,
`TABLE_STRATEGY`, `KEY_GENERATE_STRATEGY`, `RESOURCES`, `SHARDING_COLUMN`,
`TYPE`, `SHARDING_COLUMN`, `KEY_GENERATOR`, `SHARDING_ALGORITHM`, `COLUMN`,
`NAME`, `PROPERTIES`, `AUDIT_STRATEGY`, `AUDITORS`, `ALLOW_HINT_DISABLE`
### Related links
diff --git a/docs/document/content/reference/distsql/syntax/reserved-word.cn.md
b/docs/document/content/reference/distsql/syntax/reserved-word.cn.md
index 4ead28e70b6..cda5bf7ecb1 100644
--- a/docs/document/content/reference/distsql/syntax/reserved-word.cn.md
+++ b/docs/document/content/reference/distsql/syntax/reserved-word.cn.md
@@ -14,7 +14,8 @@ weight = 3
`CREATE`、`ALTER`、`DEFAULT`、`SHARDING`、`BROADCAST`、`BINDING`、`DATABASE`、`TABLE`、`STRATEGY`、`RULE`、`RULES`、`ALGORITHM`
、`DATANODES`、`DATABASE_STRATEGY`、`TABLE_STRATEGY`、`KEY_GENERATE_STRATEGY`、`RESOURCES`、`SHARDING_COLUMN`、`KEY`
-、`GENERATOR`、`TYPE`、`SHARDING_COLUMNS`、`KEY_GENERATOR`、`SHARDING_ALGORITHM`、`COLUMN`、`NAME`、`PROPERTIES`
+、`GENERATOR`、`TYPE`、`SHARDING_COLUMNS`、`KEY_GENERATOR`、`SHARDING_ALGORITHM`、`COLUMN`、`NAME`、`PROPERTIES`、`AUDIT_STRATEGY`
+、`AUDITORS`、`ALLOW_HINT_DISABLE`
#### 单表
diff --git a/docs/document/content/reference/distsql/syntax/reserved-word.en.md
b/docs/document/content/reference/distsql/syntax/reserved-word.en.md
index 68388562d25..9b68298ee5d 100644
--- a/docs/document/content/reference/distsql/syntax/reserved-word.en.md
+++ b/docs/document/content/reference/distsql/syntax/reserved-word.en.md
@@ -14,7 +14,8 @@ weight = 3
`CREATE`, `DEFAULT`, `SHARDING`, `BROADCAST`, `BINDING`, `DATABASE`, `TABLE`,
`STRATEGY`, `RULE`, `RULES`, `ALGORITHM`
, `DATANODES`, `DATABASE_STRATEGY`, `TABLE_STRATEGY`, `KEY_GENERATE_STRATEGY`,
`RESOURCES`, `SHARDING_COLUMN`, `KEY`
-, `GENERATOR`, `TYPE`, `SHARDING_COLUMNS`, `KEY_GENERATOR`,
`SHARDING_ALGORITHM`, `COLUMN`, `NAME`, `PROPERTIES`
+, `GENERATOR`, `TYPE`, `SHARDING_COLUMNS`, `KEY_GENERATOR`,
`SHARDING_ALGORITHM`, `COLUMN`, `NAME`, `PROPERTIES`, `AUDIT_STRATEGY`
+, `AUDITORS`, `ALLOW_HINT_DISABLE`
#### Single Table
diff --git
a/docs/document/content/user-manual/common-config/builtin-algorithm/audit.cn.md
b/docs/document/content/user-manual/common-config/builtin-algorithm/audit.cn.md
new file mode 100644
index 00000000000..b1d3928f9cb
--- /dev/null
+++
b/docs/document/content/user-manual/common-config/builtin-algorithm/audit.cn.md
@@ -0,0 +1,28 @@
++++
+title = "分片审计算法"
+weight = 8
++++
+
+## 背景信息
+
+分片审计功能是针对数据库分片场景下对执行的 SQL 语句进行审计操作。分片审计既可以进行拦截操作,拦截系统配置的非法 SQL 语句,也可以是对 SQL
语句进行统计操作。
+
+## 参数解释
+
+### DML_SHARDING_CONDITIONS 算法
+
+类型:DML_SHARDING_CONDITIONS
+
+## 操作步骤
+
+1. 配置数据分片规则时设置分配审计生成策略
+
+## 配置示例
+
+- DML_SHARDING_CONDITIONS
+
+```yaml
+auditors:
+ sharding_key_required_auditor:
+ type: DML_SHARDING_CONDITIONS
+```
diff --git
a/docs/document/content/user-manual/common-config/builtin-algorithm/audit.en.md
b/docs/document/content/user-manual/common-config/builtin-algorithm/audit.en.md
new file mode 100644
index 00000000000..eb8812cae87
--- /dev/null
+++
b/docs/document/content/user-manual/common-config/builtin-algorithm/audit.en.md
@@ -0,0 +1,28 @@
++++
+title = "Sharding Audit Algorithm"
+weight = 8
++++
+
+## Background
+
+The sharding audit is to audit the SQL statements in the sharding database.
Sharding audit not only intercept illegal SQL statements, but also gather the
SQL statistics.
+
+## Parameters
+
+### DML_SHARDING_CONDITIONS algorithm
+
+Type: DML_SHARDING_CONDITIONS
+
+## Procedure
+
+1. when configuring data sharding rules, create sharding audit configurations.
+
+## Sample
+
+- DML_SHARDING_CONDITIONS
+
+```yaml
+auditors:
+ sharding_key_required_auditor:
+ type: DML_SHARDING_CONDITIONS
+```
diff --git
a/docs/document/content/user-manual/common-config/builtin-algorithm/keygen.en.md
b/docs/document/content/user-manual/common-config/builtin-algorithm/keygen.en.md
index 5c00335dffc..3fc66c45c5b 100644
---
a/docs/document/content/user-manual/common-config/builtin-algorithm/keygen.en.md
+++
b/docs/document/content/user-manual/common-config/builtin-algorithm/keygen.en.md
@@ -16,6 +16,7 @@ There are many third-party solutions that can perfectly solve
this problem, such
In order to cater to the requirements of different users in different
scenarios, Apache ShardingSphere not only provides built-in distributed primary
key generators, such as UUID, SNOWFLAKE, but also abstracts the interface of
distributed primary key generators to facilitate users to implement their own
customized primary key generators.
## Parameters
+
### Snowflake
Type: SNOWFLAKE
diff --git
a/docs/document/content/user-manual/shardingsphere-jdbc/java-api/rules/sharding.cn.md
b/docs/document/content/user-manual/shardingsphere-jdbc/java-api/rules/sharding.cn.md
index 225b5f01935..727fc7c04fc 100644
---
a/docs/document/content/user-manual/shardingsphere-jdbc/java-api/rules/sharding.cn.md
+++
b/docs/document/content/user-manual/shardingsphere-jdbc/java-api/rules/sharding.cn.md
@@ -15,18 +15,20 @@ weight = 1
可配置属性:
-| *名称* | *数据类型*
| *说明* | *默认值* |
-| ----------------------------------- |
------------------------------------------------ | ------------------- |
------- |
-| tables (+) |
Collection\<ShardingTableRuleConfiguration\> | 分片表规则列表 | - |
-| autoTables (+) |
Collection\<ShardingAutoTableRuleConfiguration\> | 自动分片表规则列表 | - |
-| bindingTableGroups (*) | Collection\<String\>
| 绑定表规则列表 | 无 |
-| broadcastTables (*) | Collection\<String\>
| 广播表规则列表 | 无 |
-| defaultDatabaseShardingStrategy (?) | ShardingStrategyConfiguration
| 默认分库策略 | 不分片 |
-| defaultTableShardingStrategy (?) | ShardingStrategyConfiguration
| 默认分表策略 | 不分片 |
-| defaultKeyGenerateStrategy (?) | KeyGeneratorConfiguration
| 默认自增列生成器配置 | 雪花算法 |
-| defaultShardingColumn (?) | String
| 默认分片列名称 | 无 |
-| shardingAlgorithms (+) | Map\<String, AlgorithmConfiguration\>
| 分片算法名称和配置 | 无 |
-| keyGenerators (?) | Map\<String, AlgorithmConfiguration\>
| 自增列生成算法名称和配置 | 无 |
+| *名称* | *数据类型*
| *说明* | *默认值* |
+|-------------------------------------|
------------------------------------------------ |--------------|-------|
+| tables (+) |
Collection\<ShardingTableRuleConfiguration\> | 分片表规则列表 | - |
+| autoTables (+) |
Collection\<ShardingAutoTableRuleConfiguration\> | 自动分片表规则列表 | - |
+| bindingTableGroups (*) | Collection\<String\>
| 绑定表规则列表 | 无 |
+| broadcastTables (*) | Collection\<String\>
| 广播表规则列表 | 无 |
+| defaultDatabaseShardingStrategy (?) | ShardingStrategyConfiguration
| 默认分库策略 | 不分片 |
+| defaultTableShardingStrategy (?) | ShardingStrategyConfiguration
| 默认分表策略 | 不分片 |
+| defaultKeyGenerateStrategy (?) | KeyGeneratorConfiguration
| 默认自增列生成器配置 | 雪花算法 |
+| defaultAuditStrategy (?) | ShardingAuditStrategyConfiguration
| 默认分片审计策略配置 | 强制分片键 |
+| defaultShardingColumn (?) | String
| 默认分片列名称 | 无 |
+| shardingAlgorithms (+) | Map\<String, AlgorithmConfiguration\>
| 分片算法名称和配置 | 无 |
+| keyGenerators (?) | Map\<String, AlgorithmConfiguration\>
| 自增列生成算法名称和配置 | 无 |
+| auditors (?) | Map\<String, AlgorithmConfiguration\>
| 分片审计算法名称和配置 | 无 |
### 分片表配置
@@ -34,13 +36,14 @@ weight = 1
可配置属性:
-| *名称* | *数据类型* | *说明*
| *默认值*
|
-| ---------------------------- | ----------------------------- |
------------------------------------------------------------- |
---------------------------------------------------------------------------- |
-| logicTable | String | 分片逻辑表名称
| -
|
-| actualDataNodes (?) | String | 由数据源名 +
表名组成,以小数点分隔。<br />多个表以逗号分隔,支持行表达式 |
使用已知数据源与逻辑表名称生成数据节点,用于广播表或只分库不分表且所有库的表结构完全一致的情况 |
-| databaseShardingStrategy (?) | ShardingStrategyConfiguration | 分库策略
| 使用默认分库策略
|
-| tableShardingStrategy (?) | ShardingStrategyConfiguration | 分表策略
| 使用默认分表策略
|
-| keyGenerateStrategy (?) | KeyGeneratorConfiguration | 自增列生成器
| 使用默认自增主键生成器
|
+| *名称* | *数据类型* | *说明*
| *默认值*
|
+|------------------------------|------------------------------------|-------------------------------------------|-------------------------------------------------|
+| logicTable | String | 分片逻辑表名称
| -
|
+| actualDataNodes (?) | String | 由数据源名 +
表名组成,以小数点分隔。<br />多个表以逗号分隔,支持行表达式 |
使用已知数据源与逻辑表名称生成数据节点,用于广播表或只分库不分表且所有库的表结构完全一致的情况 |
+| databaseShardingStrategy (?) | ShardingStrategyConfiguration | 分库策略
| 使用默认分库策略
|
+| tableShardingStrategy (?) | ShardingStrategyConfiguration | 分表策略
| 使用默认分表策略
|
+| keyGenerateStrategy (?) | KeyGeneratorConfiguration | 自增列生成器
| 使用默认自增主键生成器
|
+| auditStrategy (?) | ShardingAuditStrategyConfiguration | 分片审计策略
| 使用默认分片审计策略
|
### 自动分片表配置
@@ -48,12 +51,13 @@ weight = 1
可配置属性:
-| *名称* | *数据类型* | *说明*
| *默认值* |
-| ----------------------- | ----------------------------- |
-------------------------- | ------------------ |
-| logicTable | String | 分片逻辑表名称
| - |
-| actualDataSources (?) | String | 数据源名称,多个数据源以逗号分隔 |
使用全部配置的数据源 |
-| shardingStrategy (?) | ShardingStrategyConfiguration | 分片策略
| 使用默认分片策略 |
-| keyGenerateStrategy (?) | KeyGeneratorConfiguration | 自增列生成器
| 使用默认自增主键生成器 |
+| *名称* | *数据类型* | *说明*
| *默认值* |
+| -----------------------
|------------------------------------|---------------------| ------------------
|
+| logicTable | String | 分片逻辑表名称
| - |
+| actualDataSources (?) | String |
数据源名称,多个数据源以逗号分隔 | 使用全部配置的数据源 |
+| shardingStrategy (?) | ShardingStrategyConfiguration | 分片策略
| 使用默认分片策略 |
+| keyGenerateStrategy (?) | KeyGeneratorConfiguration | 自增列生成器
| 使用默认自增主键生成器 |
+| auditStrategy (?) | ShardingAuditStrategyConfiguration | 分片审计策略
| 使用默认分片审计策略 |
### 分片策略配置
@@ -110,6 +114,19 @@ weight = 1
算法类型的详情,请参见[内置分布式序列算法列表](/cn/user-manual/common-config/builtin-algorithm/keygen)。
+### 分片审计策略配置
+
+类名称:org.apache.shardingsphere.sharding.api.config.strategy.audit.ShardingAuditStrategyConfiguration
+
+可配置属性:
+
+| *名称* | *数据类型* | *说明* |
+|-------------------|----------------------|-----------|
+| auditorNames | Collection\<String\> | 分片审计算法名称 |
+| allowHintDisable | Boolean | 是否禁用分片审计hint |
+
+算法类型的详情,请参见[内置分片审计列算法列表](/cn/user-manual/common-config/builtin-algorithm/audit)。
+
## 操作步骤
1. 创建真实数据源映射关系,key 为数据源逻辑名称,value 为 DataSource 对象;
@@ -139,12 +156,14 @@ public final class
ShardingDatabasesAndTablesConfigurationPrecise implements Exa
result.getShardingAlgorithms().put("inline", new
AlgorithmConfiguration("INLINE", props));
result.getShardingAlgorithms().put("standard_test_tbl", new
AlgorithmConfiguration("STANDARD_TEST_TBL", new Properties()));
result.getKeyGenerators().put("snowflake", new
AlgorithmConfiguration("SNOWFLAKE", new Properties()));
+ result.getAuditors().put("sharding_key_required_auditor", new
AlgorithmConfiguration("DML_SHARDING_CONDITIONS", new Properties()));
return result;
}
private ShardingTableRuleConfiguration getOrderTableRuleConfiguration() {
ShardingTableRuleConfiguration result = new
ShardingTableRuleConfiguration("t_order", "demo_ds_${0..1}.t_order_${[0, 1]}");
result.setKeyGenerateStrategy(new
KeyGenerateStrategyConfiguration("order_id", "snowflake"));
+ result.setAuditStrategy(new
ShardingAuditStrategyConfiguration(Collections.singleton("sharding_key_required_auditor"),
true));
return result;
}
diff --git
a/docs/document/content/user-manual/shardingsphere-jdbc/java-api/rules/sharding.en.md
b/docs/document/content/user-manual/shardingsphere-jdbc/java-api/rules/sharding.en.md
index cec23d8c3a5..c4a6a2c7609 100644
---
a/docs/document/content/user-manual/shardingsphere-jdbc/java-api/rules/sharding.en.md
+++
b/docs/document/content/user-manual/shardingsphere-jdbc/java-api/rules/sharding.en.md
@@ -15,18 +15,20 @@ Class name:
org.apache.shardingsphere.sharding.api.config.ShardingRuleConfigurat
Attributes:
-| *Name* | *DataType*
| *Description* | *Default Value* |
-| ----------------------------------- |
------------------------------------------------ |
----------------------------------------- | --------------- |
-| tables (+) |
Collection\<ShardingTableRuleConfiguration\> | Sharding table rules
| - |
-| autoTables (+) |
Collection\<ShardingAutoTableRuleConfiguration\> | Sharding auto table rules
| - |
-| bindingTableGroups (*) | Collection\<String\>
| Binding table rules | Empty |
-| broadcastTables (*) | Collection\<String\>
| Broadcast table rules | Empty |
-| defaultDatabaseShardingStrategy (?) | ShardingStrategyConfiguration
| Default database sharding strategy | Not sharding |
-| defaultTableShardingStrategy (?) | ShardingStrategyConfiguration
| Default table sharding strategy | Not sharding |
-| defaultKeyGenerateStrategy (?) | KeyGeneratorConfiguration
| Default key generator | Snowflake |
-| defaultShardingColumn (?) | String
| Default sharding column name | None |
-| shardingAlgorithms (+) | Map\<String, AlgorithmConfiguration\>
| Sharding algorithm name and configurations | None |
-| keyGenerators (?) | Map\<String, AlgorithmConfiguration\>
| Key generate algorithm name and configurations | None |
+| *Name* | *DataType*
| *Description* | *Default Value*
|
+| ----------------------------------- |
------------------------------------------------
|--------------------------------------------------|-------------------------|
+| tables (+) |
Collection\<ShardingTableRuleConfiguration\> | Sharding table rules
| - |
+| autoTables (+) |
Collection\<ShardingAutoTableRuleConfiguration\> | Sharding auto table rules
| - |
+| bindingTableGroups (*) | Collection\<String\>
| Binding table rules | Empty
|
+| broadcastTables (*) | Collection\<String\>
| Broadcast table rules | Empty
|
+| defaultDatabaseShardingStrategy (?) | ShardingStrategyConfiguration
| Default database sharding strategy | Not sharding
|
+| defaultTableShardingStrategy (?) | ShardingStrategyConfiguration
| Default table sharding strategy | Not sharding
|
+| defaultKeyGenerateStrategy (?) | KeyGeneratorConfiguration
| Default key generator | Snowflake
|
+| defaultAuditStrategy (?) | ShardingAuditStrategyConfiguration
| Default key auditor |
DML_SHARDING_CONDITIONS |
+| defaultShardingColumn (?) | String
| Default sharding column name | None
|
+| shardingAlgorithms (+) | Map\<String, AlgorithmConfiguration\>
| Sharding algorithm name and configurations | None
|
+| keyGenerators (?) | Map\<String, AlgorithmConfiguration\>
| Key generate algorithm name and configurations | None
|
+| auditors (?) | Map\<String, AlgorithmConfiguration\>
| Sharding audit algorithm name and configurations | None
|
### Sharding Table Configuration
@@ -34,13 +36,14 @@ Class name:
org.apache.shardingsphere.sharding.api.config.ShardingTableRuleConfi
Attributes:
-| *Name* | *DataType* | *Description*
| *Default Value*
|
-| ---------------------------- | ----------------------------- |
-------------------------------------------------------------------------------------------------------------------------------------
| ------------------------------------------ |
-| logicTable | String | Name of
sharding logic table
| -
|
-| actualDataNodes (?) | String | Describe data
source names and actual tables, delimiter as point.<br /> Multiple data nodes
split by comma, support inline expression | Broadcast table or databases
sharding only |
-| databaseShardingStrategy (?) | ShardingStrategyConfiguration | Databases
sharding strategy
| Use default databases sharding
strategy |
-| tableShardingStrategy (?) | ShardingStrategyConfiguration | Tables
sharding strategy
| Use default tables sharding
strategy |
-| keyGenerateStrategy (?) | KeyGeneratorConfiguration | Key generator
configuration
| Use default key generator
|
+| *Name* | *DataType* |
*Description*
| *Default Value*
|
+| ----------------------------
|------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------|--------------------------------------------|
+| logicTable | String | Name of
sharding logic table
| -
|
+| actualDataNodes (?) | String | Describe
data source names and actual tables, delimiter as point.<br /> Multiple data
nodes split by comma, support inline expression | Broadcast table or databases
sharding only |
+| databaseShardingStrategy (?) | ShardingStrategyConfiguration |
Databases sharding strategy
| Use default databases
sharding strategy |
+| tableShardingStrategy (?) | ShardingStrategyConfiguration | Tables
sharding strategy
| Use default tables sharding
strategy |
+| keyGenerateStrategy (?) | KeyGeneratorConfiguration | Key
generator configuration
| Use default key generator
|
+| auditStrategy (?) | ShardingAuditStrategyConfiguration | Sharding
audit strategy configuration
| Use default auditor
|
### Sharding Auto Table Configuration
@@ -110,6 +113,19 @@ Attributes:
Please refer to [Built-in Key Generate Algorithm
List](/en/user-manual/common-config/builtin-algorithm/keygen) for more details
about type of algorithm.
+### Sharding audit Strategy Configuration
+
+Class
name:org.apache.shardingsphere.sharding.api.config.strategy.audit.ShardingAuditStrategyConfiguration
+
+Attributes:
+
+| *Name* | *DataType* | *Description*
|
+|------------------|-----------------------|----------------------------------------|
+| auditorNames | Collection\<String\> | Sharding audit algorithm name
|
+| allowHintDisable | Boolean | Enable or disable sharding audit
hint |
+
+Please refer to [Built-in Sharding Audit Algorithm
List](/en/user-manual/common-config/builtin-algorithm/audit) for more details
about type of algorithm.
+
## Procedure
1. Create an authentic data source mapping relationship, with key as the
logical name of the data source and value as the DataSource object.
@@ -139,12 +155,14 @@ public final class
ShardingDatabasesAndTablesConfigurationPrecise implements Exa
result.getShardingAlgorithms().put("inline", new
AlgorithmConfiguration("INLINE", props));
result.getShardingAlgorithms().put("standard_test_tbl", new
AlgorithmConfiguration("STANDARD_TEST_TBL", new Properties()));
result.getKeyGenerators().put("snowflake", new
AlgorithmConfiguration("SNOWFLAKE", new Properties()));
+ result.getAuditors().put("sharding_key_required_auditor", new
AlgorithmConfiguration("DML_SHARDING_CONDITIONS", new Properties()));
return result;
}
private ShardingTableRuleConfiguration getOrderTableRuleConfiguration() {
ShardingTableRuleConfiguration result = new
ShardingTableRuleConfiguration("t_order", "demo_ds_${0..1}.t_order_${[0, 1]}");
result.setKeyGenerateStrategy(new
KeyGenerateStrategyConfiguration("order_id", "snowflake"));
+ result.setAuditStrategy(new
ShardingAuditStrategyConfiguration(Collections.singleton("sharding_key_required_auditor"),
true));
return result;
}
diff --git
a/docs/document/content/user-manual/shardingsphere-jdbc/spring-boot-starter/rules/sharding.cn.md
b/docs/document/content/user-manual/shardingsphere-jdbc/spring-boot-starter/rules/sharding.cn.md
index 9b548ca5cdb..9c46fb263c5 100644
---
a/docs/document/content/user-manual/shardingsphere-jdbc/spring-boot-starter/rules/sharding.cn.md
+++
b/docs/document/content/user-manual/shardingsphere-jdbc/spring-boot-starter/rules/sharding.cn.md
@@ -41,6 +41,10 @@
spring.shardingsphere.rules.sharding.auto-tables.<auto-table-name>.sharding-stra
spring.shardingsphere.rules.sharding.tables.<table-name>.key-generate-strategy.column=
# 分布式序列列名称
spring.shardingsphere.rules.sharding.tables.<table-name>.key-generate-strategy.key-generator-name=
# 分布式序列算法名称
+# 分片审计策略配置
+spring.shardingsphere.rules.sharding.tables.<table-name>.audit-strategy.auditor-names=
# 分片审计算法名称
+spring.shardingsphere.rules.sharding.tables.<table-name>.audit-strategy.allow-hint-disable=
# 是否禁用分片审计hint
+
spring.shardingsphere.rules.sharding.binding-tables[0]= # 绑定表规则列表
spring.shardingsphere.rules.sharding.binding-tables[1]= # 绑定表规则列表
spring.shardingsphere.rules.sharding.binding-tables[x]= # 绑定表规则列表
@@ -61,6 +65,10 @@
spring.shardingsphere.rules.sharding.sharding-algorithms.<sharding-algorithm-nam
# 分布式序列算法配置
spring.shardingsphere.rules.sharding.key-generators.<key-generate-algorithm-name>.type=
# 分布式序列算法类型
spring.shardingsphere.rules.sharding.key-generators.<key-generate-algorithm-name>.props.xxx=
# 分布式序列算法属性配置
+
+# 分片审计算法配置
+spring.shardingsphere.rules.sharding.auditors.<sharding-audit-algorithm-name>.type=
# 分片审计算法类型
+spring.shardingsphere.rules.sharding.auditors.<sharding-audit-algorithm-name>.props.xxx=
# 分片审计算法属性配置
```
算法类型的详情,请参见[内置分片算法列表](/cn/user-manual/common-config/builtin-algorithm/sharding)和[内置分布式序列算法列表](/cn/user-manual/common-config/builtin-algorithm/keygen)。
@@ -104,6 +112,8 @@
spring.shardingsphere.rules.sharding.tables.t_order.table-strategy.standard.shar
spring.shardingsphere.rules.sharding.tables.t_order.key-generate-strategy.column=order_id
spring.shardingsphere.rules.sharding.tables.t_order.key-generate-strategy.key-generator-name=snowflake
+spring.shardingsphere.rules.sharding.tables.t_order.audit-strategy.auditor-names=shardingKeyAudit
+spring.shardingsphere.rules.sharding.tables.t_order.audit-strategy.allow-hint-disable=true
spring.shardingsphere.rules.sharding.tables.t_order_item.actual-data-nodes=ds-$->{0..1}.t_order_item_$->{0..1}
spring.shardingsphere.rules.sharding.tables.t_order_item.table-strategy.standard.sharding-column=order_id
@@ -120,6 +130,7 @@
spring.shardingsphere.rules.sharding.sharding-algorithms.t-order-item-inline.typ
spring.shardingsphere.rules.sharding.sharding-algorithms.t-order-item-inline.props.algorithm-expression=t_order_item_$->{order_id
% 2}
spring.shardingsphere.rules.sharding.key-generators.snowflake.type=SNOWFLAKE
+spring.shardingsphere.rules.sharding.auditors.shardingKeyAudit.type=DML_SHARDING_CONDITIONS
```
## 相关参考
diff --git
a/docs/document/content/user-manual/shardingsphere-jdbc/spring-boot-starter/rules/sharding.en.md
b/docs/document/content/user-manual/shardingsphere-jdbc/spring-boot-starter/rules/sharding.en.md
index dd9bf734925..3311671f138 100644
---
a/docs/document/content/user-manual/shardingsphere-jdbc/spring-boot-starter/rules/sharding.en.md
+++
b/docs/document/content/user-manual/shardingsphere-jdbc/spring-boot-starter/rules/sharding.en.md
@@ -41,6 +41,10 @@
spring.shardingsphere.rules.sharding.auto-tables.<auto-table-name>.sharding-stra
spring.shardingsphere.rules.sharding.tables.<table-name>.key-generate-strategy.column=
# Column name of key generator
spring.shardingsphere.rules.sharding.tables.<table-name>.key-generate-strategy.key-generator-name=
# Key generator name
+# Sharding auditor strategy configuration
+spring.shardingsphere.rules.sharding.tables.<table-name>.audit-strategy.auditor-names=
# Sharding auditor name
+spring.shardingsphere.rules.sharding.tables.<table-name>.audit-strategy.allow-hint-disable=
# Enable or disable sharding audit hint
+
spring.shardingsphere.rules.sharding.binding-tables[0]= # Binding table name
spring.shardingsphere.rules.sharding.binding-tables[1]= # Binding table name
spring.shardingsphere.rules.sharding.binding-tables[x]= # Binding table name
@@ -61,6 +65,10 @@
spring.shardingsphere.rules.sharding.sharding-algorithms.<sharding-algorithm-nam
# Key generate algorithm configuration
spring.shardingsphere.rules.sharding.key-generators.<key-generate-algorithm-name>.type=
# Key generate algorithm type
spring.shardingsphere.rules.sharding.key-generators.<key-generate-algorithm-name>.props.xxx=
# Key generate algorithm properties
+
+# Sharding audit algorithm configuration
+spring.shardingsphere.rules.sharding.auditors.<sharding-audit-algorithm-name>.type=
# Sharing audit algorithm type
+spring.shardingsphere.rules.sharding.auditors.<sharding-audit-algorithm-name>.props.xxx=
# Sharding audit algorithm properties
```
Please refer to [Built-in Sharding Algorithm
List](/en/user-manual/common-config/builtin-algorithm/sharding) and [Built-in
Key Generate Algorithm
List](/en/user-manual/common-config/builtin-algorithm/keygen) for more details
about type of algorithm.
@@ -104,6 +112,8 @@
spring.shardingsphere.rules.sharding.tables.t_order.table-strategy.standard.shar
spring.shardingsphere.rules.sharding.tables.t_order.key-generate-strategy.column=order_id
spring.shardingsphere.rules.sharding.tables.t_order.key-generate-strategy.key-generator-name=snowflake
+spring.shardingsphere.rules.sharding.tables.t_order.audit-strategy.auditor-names=shardingKeyAudit
+spring.shardingsphere.rules.sharding.tables.t_order.audit-strategy.allow-hint-disable=true
spring.shardingsphere.rules.sharding.tables.t_order_item.actual-data-nodes=ds-$->{0..1}.t_order_item_$->{0..1}
spring.shardingsphere.rules.sharding.tables.t_order_item.table-strategy.standard.sharding-column=order_id
@@ -120,6 +130,7 @@
spring.shardingsphere.rules.sharding.sharding-algorithms.t-order-item-inline.typ
spring.shardingsphere.rules.sharding.sharding-algorithms.t-order-item-inline.props.algorithm-expression=t_order_item_$->{order_id
% 2}
spring.shardingsphere.rules.sharding.key-generators.snowflake.type=SNOWFLAKE
+spring.shardingsphere.rules.sharding.auditors.shardingKeyAudit.type=DML_SHARDING_CONDITIONS
```
## Related References
diff --git
a/docs/document/content/user-manual/shardingsphere-jdbc/spring-namespace/rules/sharding.cn.md
b/docs/document/content/user-manual/shardingsphere-jdbc/spring-namespace/rules/sharding.cn.md
index 7e1a20c7264..2381047adab 100644
---
a/docs/document/content/user-manual/shardingsphere-jdbc/spring-namespace/rules/sharding.cn.md
+++
b/docs/document/content/user-manual/shardingsphere-jdbc/spring-namespace/rules/sharding.cn.md
@@ -13,29 +13,31 @@ weight = 1
\<sharding:rule />
-| *名称* | *类型* | *说明* |
-| ------------------------------------- | ------ | ----------------- |
-| id | 属性 | Spring Bean Id |
-| table-rules (?) | 标签 | 分片表规则配置 |
-| auto-table-rules (?) | 标签 | 自动分片表规则配置 |
-| binding-table-rules (?) | 标签 | 绑定表规则配置 |
-| broadcast-table-rules (?) | 标签 | 广播表规则配置 |
-| default-database-strategy-ref (?) | 属性 | 默认分库策略名称 |
-| default-table-strategy-ref (?) | 属性 | 默认分表策略名称 |
-| default-key-generate-strategy-ref (?) | 属性 | 默认分布式序列策略名称 |
-| default-sharding-column (?) | 属性 | 默认分片列名称 |
+| *名称* | *类型* | *说明* |
+|---------------------------------------| ------ |----------------|
+| id | 属性 | Spring Bean Id |
+| table-rules (?) | 标签 | 分片表规则配置 |
+| auto-table-rules (?) | 标签 | 自动分片表规则配置 |
+| binding-table-rules (?) | 标签 | 绑定表规则配置 |
+| broadcast-table-rules (?) | 标签 | 广播表规则配置 |
+| default-database-strategy-ref (?) | 属性 | 默认分库策略名称 |
+| default-table-strategy-ref (?) | 属性 | 默认分表策略名称 |
+| default-key-generate-strategy-ref (?) | 属性 | 默认分布式序列策略名称 |
+| default-audit-strategy-ref (?) | 属性 | 默认分片审计策略名称 |
+| default-sharding-column (?) | 属性 | 默认分片列名称 |
\<sharding:table-rule />
-| *名称* | *类型* | *说明* |
-| ------------------------- | ----- | --------------- |
-| logic-table | 属性 | 逻辑表名称 |
+| *名称* | *类型* | *说明*
|
+|---------------------------| -----
|----------------------------------------------------------------------------------------------------------------------------|
+| logic-table | 属性 | 逻辑表名称
|
| actual-data-nodes | 属性 | 由数据源名 + 表名组成,以小数点分隔。多个表以逗号分隔,支持 inline
表达式。缺省表示使用已知数据源与逻辑表名称生成数据节点,用于广播表(即每个库中都需要一个同样的表用于关联查询,多为字典表)或只分库不分表且所有库的表结构完全一致的情况
|
-| actual-data-sources | 属性 | 自动分片表数据源名 |
-| database-strategy-ref | 属性 | 标准分片表分库策略名称 |
-| table-strategy-ref | 属性 | 标准分片表分表策略名称 |
-| sharding-strategy-ref | 属性 | 自动分片表策略名称 |
-| key-generate-strategy-ref | 属性 | 分布式序列策略名称 |
+| actual-data-sources | 属性 | 自动分片表数据源名
|
+| database-strategy-ref | 属性 | 标准分片表分库策略名称
|
+| table-strategy-ref | 属性 | 标准分片表分表策略名称
|
+| sharding-strategy-ref | 属性 | 自动分片表策略名称
|
+| key-generate-strategy-ref | 属性 | 分布式序列策略名称
|
+| audit-strategy-ref | 属性 | 分片审计策略名称
|
\<sharding:binding-table-rules />
@@ -98,6 +100,26 @@ weight = 1
| column | 属性 | 分布式序列列名称 |
| algorithm-ref | 属性 | 分布式序列算法名称 |
+\<sharding:audit-strategy />
+
+| *名称* | *类型* | *说明* |
+| -------------------|--------|--------------|
+| id | 属性 | 分片审计策略名称 |
+| allow-hint-disable | 属性 | 是否禁用分片审计hint |
+| auditors | 标签 | 分片审计算法名称 |
+
+\<sharding:auditors />
+
+| *名称* | *类型* | *说明* |
+| -----------------|--------|----------|
+| auditor | 标签 | 分片审计算法名称 |
+
+\<sharding:auditor />
+
+| *名称* | *类型* | *说明* |
+| -----------------|------|----------|
+| algorithm-ref | 属性 | 分片审计算法名称 |
+
\<sharding:sharding-algorithm />
| *名称* | *类型* | *说明* |
@@ -114,7 +136,15 @@ weight = 1
| type | 属性 | 分布式序列算法类型 |
| props (?) | 标签 | 分布式序列算法属性配置 |
-算法类型的详情,请参见[内置分片算法列表](/cn/user-manual/common-config/builtin-algorithm/sharding)和[内置分布式序列算法列表](/cn/user-manual/common-config/builtin-algorithm/keygen)。
+\<sharding:audit-algorithm />
+
+| *名称* | *类型* | *说明* |
+| --------- | ----- |------------|
+| id | 属性 | 分片审计算法名称 |
+| type | 属性 | 分片审计算法类型 |
+| props (?) | 标签 | 分片审计算法属性配置 |
+
+算法类型的详情,请参见[内置分片算法列表](/cn/user-manual/common-config/builtin-algorithm/sharding),[内置分布式序列算法列表](/cn/user-manual/common-config/builtin-algorithm/keygen)
和 [内置分片审计算法列表](/cn/user-manual/common-config/builtin-algorithm/audit)。
> 注意事项:行表达式标识符可以使用 `${...}` 或 `$->{...}`,但前者与 Spring 本身的属性文件占位符冲突,因此在 Spring
> 环境中使用行表达式标识符建议使用 `$->{...}`。
@@ -169,13 +199,26 @@ weight = 1
<sharding:key-generate-algorithm id="snowflakeAlgorithm" type="SNOWFLAKE">
</sharding:key-generate-algorithm>
+
+ <sharding:audit-algorithm id="auditAlgorithm"
type="DML_SHARDING_CONDITIONS" />
<sharding:key-generate-strategy id="orderKeyGenerator" column="order_id"
algorithm-ref="snowflakeAlgorithm" />
<sharding:key-generate-strategy id="itemKeyGenerator"
column="order_item_id" algorithm-ref="snowflakeAlgorithm" />
+
+ <sharding:audit-strategy id="defaultAudit" allow-hint-disable="true">
+ <sharding:auditors>
+ <sharding:auditor algorithm-ref="auditAlgorithm" />
+ </sharding:auditors>
+ </sharding:audit-strategy>
+ <sharding:audit-strategy id="shardingKeyAudit" allow-hint-disable="true">
+ <sharding:auditors>
+ <sharding:auditor algorithm-ref="auditAlgorithm" />
+ </sharding:auditors>
+ </sharding:audit-strategy>
<sharding:rule id="shardingRule">
<sharding:table-rules>
- <sharding:table-rule logic-table="t_order"
database-strategy-ref="databaseStrategy"
key-generate-strategy-ref="orderKeyGenerator" />
+ <sharding:table-rule logic-table="t_order"
database-strategy-ref="databaseStrategy"
key-generate-strategy-ref="orderKeyGenerator"
audit-strategy-ref="shardingKeyAudit" />
<sharding:table-rule logic-table="t_order_item"
database-strategy-ref="databaseStrategy"
key-generate-strategy-ref="itemKeyGenerator" />
</sharding:table-rules>
<sharding:binding-table-rules>
diff --git
a/docs/document/content/user-manual/shardingsphere-jdbc/spring-namespace/rules/sharding.en.md
b/docs/document/content/user-manual/shardingsphere-jdbc/spring-namespace/rules/sharding.en.md
index 0b3ce1d25ab..60c34fa6f96 100644
---
a/docs/document/content/user-manual/shardingsphere-jdbc/spring-namespace/rules/sharding.en.md
+++
b/docs/document/content/user-manual/shardingsphere-jdbc/spring-namespace/rules/sharding.en.md
@@ -14,7 +14,7 @@ Namespace:
[http://shardingsphere.apache.org/schema/shardingsphere/sharding/shar
\<sharding:rule />
| *Name* | *Type* | *Description*
|
-| ------------------------------------- | --------- |
------------------------------------------- |
+| ------------------------------------- | ---------
|---------------------------------------------|
| id | Attribute | Spring Bean Id
|
| table-rules (?) | Tag | Sharding table rule
configuration |
| auto-table-rules (?) | Tag | Automatic sharding table
rule configuration |
@@ -23,19 +23,21 @@ Namespace:
[http://shardingsphere.apache.org/schema/shardingsphere/sharding/shar
| default-database-strategy-ref (?) | Attribute | Default database
strategy name |
| default-table-strategy-ref (?) | Attribute | Default table strategy
name |
| default-key-generate-strategy-ref (?) | Attribute | Default key generate
strategy name |
+| default-audit-strategy-ref (?) | Attribute | Default sharding audit
strategy name |
| default-sharding-column (?) | Attribute | Default sharding column
name |
\<sharding:table-rule />
-| *Name* | *Type* | *Description* |
-| ------------------------- | --------- | -------------------------- |
-| logic-table | Attribute | Logic table name |
+| *Name* | *Type* | *Description*
|
+| ------------------------- | ---------
|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
+| logic-table | Attribute | Logic table name
|
| actual-data-nodes | Attribute | Describe data source names and
actual tables, delimiter as point, multiple data nodes separated with comma,
support inline expression. Absent means sharding databases only. |
-| actual-data-sources | Attribute | Data source names for auto sharding
table |
-| database-strategy-ref | Attribute | Database strategy name for standard
sharding table |
-| table-strategy-ref | Attribute | Table strategy name for standard
sharding table |
-| sharding-strategy-ref | Attribute | sharding strategy name for auto
sharding table |
-| key-generate-strategy-ref | Attribute | Key generate strategy name |
+| actual-data-sources | Attribute | Data source names for auto sharding
table
|
+| database-strategy-ref | Attribute | Database strategy name for standard
sharding table
|
+| table-strategy-ref | Attribute | Table strategy name for standard
sharding table
|
+| sharding-strategy-ref | Attribute | sharding strategy name for auto
sharding table
|
+| key-generate-strategy-ref | Attribute | Key generate strategy name
|
+| audit-strategy-ref | Attribute | Sharding audit strategy name
|
\<sharding:binding-table-rules />
@@ -98,6 +100,26 @@ Namespace:
[http://shardingsphere.apache.org/schema/shardingsphere/sharding/shar
| column | Attribute | Key generate column name |
| algorithm-ref | Attribute | Key generate algorithm name |
+\<sharding:audit-strategy />
+
+| *Name* | *Type* | *Description* |
+|--------------------|-----------|---------------------------------------|
+| id | Attribute | Sharding audit strategy name |
+| allow-hint-disable | Attribute | Enable or disable sharding audit hint |
+| auditors | Tag | Sharding audit algorithm name |
+
+\<sharding:auditors />
+
+| *Name* | *Type* | *Description* |
+|---------|--------|-------------------------------|
+| auditor | Tag | Sharding audit algorithm name |
+
+\<sharding:auditor />
+
+| *Name* | *Type* | *Description* |
+| -----------------|-----------|-------------------------------|
+| algorithm-ref | Attribute | Sharding audit algorithm name |
+
\<sharding:sharding-algorithm />
| *Name* | *Type* | *Description* |
@@ -114,7 +136,15 @@ Namespace:
[http://shardingsphere.apache.org/schema/shardingsphere/sharding/shar
| type | Attribute | Key generate algorithm type |
| props (?) | Tag | Key generate algorithm properties |
-Please refer to [Built-in Sharding Algorithm
List](/en/user-manual/common-config/builtin-algorithm/sharding) and [Built-in
Key Generate Algorithm
List](/en/user-manual/common-config/builtin-algorithm/keygen) for more details
about type of algorithm.
+\<sharding:audit-algorithm />
+
+| *Name* | *Type* | *Description* |
+| --------- | --------- |-------------------------------------|
+| id | Attribute | Sharding audit algorithm name |
+| type | Attribute | Sharding audit algorithm type |
+| props (?) | Tag | Sharding audit algorithm properties |
+
+Please refer to [Built-in Sharding Audit Algorithm
List](/en/user-manual/common-config/builtin-algorithm/sharding), [Built-in Key
Generate Algorithm
List](/en/user-manual/common-config/builtin-algorithm/keygen) and [Built-in
Sharding Audit Algorithm
List](/en/user-manual/common-config/builtin-algorithm/audit) for more details
about type of algorithm.
> Attention: Inline expression identifier can use `${...}` or `$->{...}`, but
> `${...}` is conflict with spring placeholder of properties, so use
> `$->{...}` on spring environment is better.
@@ -170,12 +200,25 @@ Please refer to [Built-in Sharding Algorithm
List](/en/user-manual/common-config
<sharding:key-generate-algorithm id="snowflakeAlgorithm" type="SNOWFLAKE">
</sharding:key-generate-algorithm>
+ <sharding:audit-algorithm id="auditAlgorithm"
type="DML_SHARDING_CONDITIONS" />
+
<sharding:key-generate-strategy id="orderKeyGenerator" column="order_id"
algorithm-ref="snowflakeAlgorithm" />
<sharding:key-generate-strategy id="itemKeyGenerator"
column="order_item_id" algorithm-ref="snowflakeAlgorithm" />
+ <sharding:audit-strategy id="defaultAudit" allow-hint-disable="true">
+ <sharding:auditors>
+ <sharding:auditor algorithm-ref="auditAlgorithm" />
+ </sharding:auditors>
+ </sharding:audit-strategy>
+ <sharding:audit-strategy id="shardingKeyAudit" allow-hint-disable="true">
+ <sharding:auditors>
+ <sharding:auditor algorithm-ref="auditAlgorithm" />
+ </sharding:auditors>
+ </sharding:audit-strategy>
+
<sharding:rule id="shardingRule">
<sharding:table-rules>
- <sharding:table-rule logic-table="t_order"
database-strategy-ref="databaseStrategy"
key-generate-strategy-ref="orderKeyGenerator" />
+ <sharding:table-rule logic-table="t_order"
database-strategy-ref="databaseStrategy"
key-generate-strategy-ref="orderKeyGenerator"
audit-strategy-ref="shardingKeyAudit" />
<sharding:table-rule logic-table="t_order_item"
database-strategy-ref="databaseStrategy"
key-generate-strategy-ref="itemKeyGenerator" />
</sharding:table-rules>
<sharding:binding-table-rules>
diff --git
a/docs/document/content/user-manual/shardingsphere-jdbc/yaml-config/rules/sharding.cn.md
b/docs/document/content/user-manual/shardingsphere-jdbc/yaml-config/rules/sharding.cn.md
index f9a2746e8ae..e561b350eff 100644
---
a/docs/document/content/user-manual/shardingsphere-jdbc/yaml-config/rules/sharding.cn.md
+++
b/docs/document/content/user-manual/shardingsphere-jdbc/yaml-config/rules/sharding.cn.md
@@ -29,6 +29,11 @@ rules:
keyGenerateStrategy: # 分布式序列策略
column: # 自增列名称,缺省表示不使用自增主键生成器
keyGeneratorName: # 分布式序列算法名称
+ auditStrategy: # 分片审计策略
+ auditorNames: # 分片审计算法名称
+ - <auditor-name>
+ - <auditor-name>
+ allowHintDisable: true # 是否禁用分片审计hint
autoTables: # 自动分片表规则配置
t_order_auto: # 逻辑表名称
actualDataSources (?): # 数据源名称
@@ -60,6 +65,12 @@ rules:
type: # 分布式序列算法类型
props: # 分布式序列算法属性配置
# ...
+ # 分片审计算法配置
+ auditors:
+ <sharding-audit-algorithm-name> (+): # 分片审计算法名称
+ type: # 分片审计算法类型
+ props: # 分片审计算法属性配置
+ # ...
```
## 操作步骤
@@ -98,6 +109,10 @@ rules:
keyGenerateStrategy:
column: order_id
keyGeneratorName: snowflake
+ auditStrategy:
+ auditorNames:
+ - sharding_key_required_auditor
+ allowHintDisable: true
t_order_item:
actualDataNodes: ds_${0..1}.t_order_item_${0..1}
tableStrategy:
@@ -147,6 +162,9 @@ rules:
keyGenerators:
snowflake:
type: SNOWFLAKE
+ auditors:
+ sharding_key_required_auditor:
+ type: DML_SHARDING_CONDITIONS
props:
sql-show: false
diff --git
a/docs/document/content/user-manual/shardingsphere-jdbc/yaml-config/rules/sharding.en.md
b/docs/document/content/user-manual/shardingsphere-jdbc/yaml-config/rules/sharding.en.md
index 4e6b088dbde..7c6ca1c8bd5 100644
---
a/docs/document/content/user-manual/shardingsphere-jdbc/yaml-config/rules/sharding.en.md
+++
b/docs/document/content/user-manual/shardingsphere-jdbc/yaml-config/rules/sharding.en.md
@@ -29,6 +29,11 @@ rules:
keyGenerateStrategy: # Key generator strategy
column: # Column name of key generator
keyGeneratorName: # Key generator name
+ auditStrategy: # Sharding audit strategy
+ auditorNames: # Sharding auditor name
+ - <auditor-name>
+ - <auditor-name>
+ allowHintDisable: true # Enable or disable sharding audit hint
autoTables: # Auto Sharding table configuration
t_order_auto: # Logic table name
actualDataSources (?): # Data source names
@@ -60,6 +65,13 @@ rules:
type: # Key generate algorithm type
props: # Key generate algorithm properties
# ...
+
+ # Sharding audit algorithm configuration
+ auditors:
+ <sharding-audit-algorithm-name> (+): # Sharding audit algorithm name
+ type: # Sharding audit algorithm type
+ props: # Sharding audit algorithm properties
+ # ...
```
## Procedure
@@ -98,6 +110,10 @@ rules:
keyGenerateStrategy:
column: order_id
keyGeneratorName: snowflake
+ auditStrategy:
+ auditorNames:
+ - sharding_key_required_auditor
+ allowHintDisable: true
t_order_item:
actualDataNodes: ds_${0..1}.t_order_item_${0..1}
tableStrategy:
@@ -147,6 +163,9 @@ rules:
keyGenerators:
snowflake:
type: SNOWFLAKE
+ auditors:
+ sharding_key_required_auditor:
+ type: DML_SHARDING_CONDITIONS
props:
sql-show: false
diff --git
a/docs/document/content/user-manual/shardingsphere-proxy/distsql/syntax/rdl/rule-definition/sharding.cn.md
b/docs/document/content/user-manual/shardingsphere-proxy/distsql/syntax/rdl/rule-definition/sharding.cn.md
index f80d93207b7..c436b8bfd95 100644
---
a/docs/document/content/user-manual/shardingsphere-proxy/distsql/syntax/rdl/rule-definition/sharding.cn.md
+++
b/docs/document/content/user-manual/shardingsphere-proxy/distsql/syntax/rdl/rule-definition/sharding.cn.md
@@ -30,16 +30,22 @@ CREATE SHARDING KEY GENERATOR keyGeneratorDefinition [,
keyGeneratorDefinition]
ALTER SHARDING KEY GENERATOR keyGeneratorDefinition [, keyGeneratorDefinition]
...
-DROP SHARDING KEY GENERATOR keyGeneratorName [, keyGeneratorName] ...
+DROP SHARDING KEY GENERATOR [IF EXISTS] keyGeneratorName [, keyGeneratorName]
...
+
+CREATE SHARDING AUDITOR auditorDefinition [, auditorDefinition] ...
+
+ALTER SHARDING AUDITOR auditorDefinition [, auditorDefinition] ...
+
+DROP SHARDING AUDITOR [IF EXISTS] auditorName [, auditorName] ...
shardingTableRuleDefinition:
shardingAutoTableRule | shardingTableRule
shardingAutoTableRule:
- tableName(resources, shardingColumn, algorithmDefinition [,
keyGenerateDeclaration])
+ tableName(resources, shardingColumn, algorithmDefinition [,
keyGenerateDeclaration] [, auditDeclaration])
shardingTableRule:
- tableName(dataNodes [, databaseStrategy] [, tableStrategy] [,
keyGenerateDeclaration])
+ tableName(dataNodes [, databaseStrategy] [, tableStrategy] [,
keyGenerateDeclaration] [, auditDeclaration])
resources:
RESOURCES(resource [, resource] ...)
@@ -64,6 +70,18 @@ keyGenerateDeclaration:
keyGenerateDefinition:
KEY_GENERATE_STRATEGY(COLUMN=columnName, strategyDefinition)
+
+auditDeclaration:
+ auditDefinition | auditStrategy
+
+auditDefinition:
+ AUDIT_STRATEGY([(singleAuditDefinition),(singleAuditDefinition)],
ALLOW_HINT_DISABLE=true)
+
+singleAuditDefinition:
+ NAME=auditor1, algorithmDefinition
+
+auditStrategy:
+ AUDIT_STRATEGY(AUDITORS=[auditor1,auditor2], ALLOW_HINT_DISABLE=true)
shardingScope:
DATABASE | TABLE
@@ -103,10 +121,17 @@ algorithmProperty:
keyGeneratorDefinition:
keyGeneratorName (algorithmDefinition)
+
+auditorDefinition:
+ auditorName (auditorAlgorithmDefinition)
+
+auditorAlgorithmDefinition:
+ TYPE(NAME=auditorAlgorithmType [, PROPERTIES([algorithmProperties])])
```
- `RESOURCES` 需使用 RDL 管理的数据源资源;
- `shardingAlgorithmType` 指定自动分片算法类型,请参考
[自动分片算法](/cn/user-manual/common-config/builtin-algorithm/sharding/);
- `keyGenerateStrategyType` 指定分布式主键生成策略,请参考
[分布式主键](/cn/user-manual/common-config/builtin-algorithm/keygen/);
+- `auditorAlgorithmType` 指定分片审计策略,请参考
[分片审计](/cn/user-manual/common-config/builtin-algorithm/audit/);
- 重复的 `tableName` 将无法被创建;
- `shardingAlgorithm` 能够被不同的 `Sharding Table Rule` 复用,因此在执行 `DROP SHARDING
TABLE RULE` 时,对应的 `shardingAlgorithm` 不会被移除;
- 如需移除 `shardingAlgorithm`,请执行 `DROP SHARDING ALGORITHM`;
@@ -157,18 +182,34 @@ TYPE(NAME="SNOWFLAKE")
DROP SHARDING KEY GENERATOR snowflake_key_generator;
```
+*Auditor*
+
+```sql
+CREATE SHARDING AUDITOR sharding_key_required_auditor (
+TYPE(NAME="DML_SHARDING_CONDITIONS")
+);
+
+ALTER SHARDING AUDITOR sharding_key_required_auditor (
+TYPE(NAME="DML_SHARDING_CONDITIONS")
+);
+
+DROP SHARDING AUDITOR IF EXISTS sharding_key_required_auditor;
+```
+
*Auto Table*
```sql
CREATE SHARDING TABLE RULE t_order (
RESOURCES(resource_0,resource_1),
SHARDING_COLUMN=order_id,TYPE(NAME="hash_mod",PROPERTIES("sharding-count"="4")),
-KEY_GENERATE_STRATEGY(COLUMN=another_id,TYPE(NAME="snowflake"))
+KEY_GENERATE_STRATEGY(COLUMN=another_id,TYPE(NAME="snowflake")),
+AUDIT_STRATEGY(AUDITORS=[auditor1,auditor2],ALLOW_HINT_DISABLE=true)
);
ALTER SHARDING TABLE RULE t_order (
RESOURCES(resource_0,resource_1,resource_2,resource_3),
SHARDING_COLUMN=order_id,TYPE(NAME="hash_mod",PROPERTIES("sharding-count"="16")),
-KEY_GENERATE_STRATEGY(COLUMN=another_id,TYPE(NAME="snowflake"))
+KEY_GENERATE_STRATEGY(COLUMN=another_id,TYPE(NAME="snowflake")),
+AUDIT_STRATEGY(AUDITORS=[auditor1,auditor2],ALLOW_HINT_DISABLE=true)
);
DROP SHARDING TABLE RULE t_order;
@@ -187,7 +228,8 @@ CREATE SHARDING TABLE RULE t_order_item (
DATANODES("resource_${0..1}.t_order_item_${0..1}"),
DATABASE_STRATEGY(TYPE="standard",SHARDING_COLUMN=user_id,SHARDING_ALGORITHM(TYPE(NAME="inline",PROPERTIES("algorithm-expression"="resource_${user_id
% 2}")))),
TABLE_STRATEGY(TYPE="standard",SHARDING_COLUMN=order_id,SHARDING_ALGORITHM=table_inline),
-KEY_GENERATE_STRATEGY(COLUMN=another_id,KEY_GENERATOR=snowflake_key_generator)
+KEY_GENERATE_STRATEGY(COLUMN=another_id,KEY_GENERATOR=snowflake_key_generator),
+AUDIT_STRATEGY(AUDITORS=[auditor1,auditor2],ALLOW_HINT_DISABLE=true)
);
ALTER SHARDING ALGORITHM database_inline (
@@ -200,7 +242,8 @@ ALTER SHARDING TABLE RULE t_order_item (
DATANODES("resource_${0..3}.t_order_item${0..3}"),
DATABASE_STRATEGY(TYPE="standard",SHARDING_COLUMN=user_id,SHARDING_ALGORITHM=database_inline),
TABLE_STRATEGY(TYPE="standard",SHARDING_COLUMN=order_id,SHARDING_ALGORITHM=table_inline),
-KEY_GENERATE_STRATEGY(COLUMN=another_id,KEY_GENERATOR=snowflake_key_generator)
+KEY_GENERATE_STRATEGY(COLUMN=another_id,KEY_GENERATOR=snowflake_key_generator),
+AUDIT_STRATEGY(AUDITORS=[auditor1,auditor2],ALLOW_HINT_DISABLE=true)
);
DROP SHARDING TABLE RULE t_order_item;
diff --git
a/docs/document/content/user-manual/shardingsphere-proxy/distsql/syntax/rdl/rule-definition/sharding.en.md
b/docs/document/content/user-manual/shardingsphere-proxy/distsql/syntax/rdl/rule-definition/sharding.en.md
index 97444f112da..a2b4e6dd7b9 100644
---
a/docs/document/content/user-manual/shardingsphere-proxy/distsql/syntax/rdl/rule-definition/sharding.en.md
+++
b/docs/document/content/user-manual/shardingsphere-proxy/distsql/syntax/rdl/rule-definition/sharding.en.md
@@ -30,16 +30,22 @@ CREATE SHARDING KEY GENERATOR keyGeneratorDefinition [,
keyGeneratorDefinition]
ALTER SHARDING KEY GENERATOR keyGeneratorDefinition [, keyGeneratorDefinition]
...
-DROP SHARDING KEY GENERATOR keyGeneratorName [, keyGeneratorName] ...
+DROP SHARDING KEY GENERATOR [IF EXISTS] keyGeneratorName [, keyGeneratorName]
...
+
+CREATE SHARDING AUDITOR auditorDefinition [, auditorDefinition] ...
+
+ALTER SHARDING AUDITOR auditorDefinition [, auditorDefinition] ...
+
+DROP SHARDING AUDITOR [IF EXISTS] auditorName [, auditorName] ...
shardingTableRuleDefinition:
shardingAutoTableRule | shardingTableRule
shardingAutoTableRule:
- tableName(resources, shardingColumn, algorithmDefinition [,
keyGenerateDeclaration])
+ tableName(resources, shardingColumn, algorithmDefinition [,
keyGenerateDeclaration] [, auditDeclaration])
shardingTableRule:
- tableName(dataNodes [, databaseStrategy] [, tableStrategy] [,
keyGenerateDeclaration])
+ tableName(dataNodes [, databaseStrategy] [, tableStrategy] [,
keyGenerateDeclaration] [, auditDeclaration])
resources:
RESOURCES(resource [, resource] ...)
@@ -64,6 +70,18 @@ keyGenerateDeclaration:
keyGenerateDefinition:
KEY_GENERATE_STRATEGY(COLUMN=columnName, strategyDefinition)
+
+auditDeclaration:
+ auditDefinition | auditStrategy
+
+auditDefinition:
+ AUDIT_STRATEGY([(singleAuditDefinition),(singleAuditDefinition)],
ALLOW_HINT_DISABLE=true)
+
+singleAuditDefinition:
+ NAME=auditor1, algorithmDefinition
+
+auditStrategy:
+ AUDIT_STRATEGY(AUDITORS=[auditor1,auditor2], ALLOW_HINT_DISABLE=true)
shardingScope:
DATABASE | TABLE
@@ -103,10 +121,17 @@ algorithmProperty:
keyGeneratorDefinition:
keyGeneratorName (algorithmDefinition)
+
+auditorDefinition:
+ auditorName (auditorAlgorithmDefinition)
+
+auditorAlgorithmDefinition:
+ TYPE(NAME=auditorAlgorithmType [, PROPERTIES([algorithmProperties])])
```
- `RESOURCES` needs to use data source resources managed by RDL
- `shardingAlgorithmType` specifies the type of automatic sharding algorithm,
please refer to [Auto Sharding
Algorithm](/en/user-manual/common-config/builtin-algorithm/sharding/)
- `keyGenerateStrategyType` specifies the distributed primary key generation
strategy, please refer to [Key Generate
Algorithm](/en/user-manual/common-config/builtin-algorithm/keygen/)
+- `auditorAlgorithmType` specifies the sharding audit strategy, please refer
to [Sharding Audit
Algorithm](/cn/user-manual/common-config/builtin-algorithm/audit/);
- Duplicate `tableName` will not be created
- `shardingAlgorithm` can be reused by different `Sharding Table Rule`, so
when executing `DROP SHARDING TABLE RULE`, the corresponding
`shardingAlgorithm` will not be removed
- To remove `shardingAlgorithm`, please execute `DROP SHARDING ALGORITHM`
@@ -158,18 +183,34 @@ TYPE(NAME="SNOWFLAKE"))
DROP SHARDING KEY GENERATOR snowflake_key_generator;
```
+*Auditor*
+
+```sql
+CREATE SHARDING AUDITOR sharding_key_required_auditor (
+TYPE(NAME="DML_SHARDING_CONDITIONS")
+);
+
+ALTER SHARDING AUDITOR sharding_key_required_auditor (
+TYPE(NAME="DML_SHARDING_CONDITIONS")
+);
+
+DROP SHARDING AUDITOR IF EXISTS sharding_key_required_auditor;
+```
+
*Auto Table*
```sql
CREATE SHARDING TABLE RULE t_order (
RESOURCES(resource_0,resource_1),
SHARDING_COLUMN=order_id,TYPE(NAME="hash_mod",PROPERTIES("sharding-count"="4")),
-KEY_GENERATE_STRATEGY(COLUMN=another_id,TYPE(NAME="snowflake"))
+KEY_GENERATE_STRATEGY(COLUMN=another_id,TYPE(NAME="snowflake")),
+AUDIT_STRATEGY(AUDITORS=[auditor1,auditor2],ALLOW_HINT_DISABLE=true)
);
ALTER SHARDING TABLE RULE t_order (
RESOURCES(resource_0,resource_1,resource_2,resource_3),
SHARDING_COLUMN=order_id,TYPE(NAME="hash_mod",PROPERTIES("sharding-count"="16")),
-KEY_GENERATE_STRATEGY(COLUMN=another_id,TYPE(NAME="snowflake"))
+KEY_GENERATE_STRATEGY(COLUMN=another_id,TYPE(NAME="snowflake")),
+AUDIT_STRATEGY(AUDITORS=[auditor1,auditor2],ALLOW_HINT_DISABLE=true)
);
DROP SHARDING TABLE RULE t_order;
@@ -188,7 +229,8 @@ CREATE SHARDING TABLE RULE t_order_item (
DATANODES("resource_${0..1}.t_order_item_${0..1}"),
DATABASE_STRATEGY(TYPE="standard",SHARDING_COLUMN=user_id,SHARDING_ALGORITHM(TYPE(NAME="inline",PROPERTIES("algorithm-expression"="resource_${user_id
% 2}")))),
TABLE_STRATEGY(TYPE="standard",SHARDING_COLUMN=order_id,SHARDING_ALGORITHM=table_inline),
-KEY_GENERATE_STRATEGY(COLUMN=another_id,KEY_GENERATOR=snowflake_key_generator)
+KEY_GENERATE_STRATEGY(COLUMN=another_id,KEY_GENERATOR=snowflake_key_generator),
+AUDIT_STRATEGY(AUDITORS=[auditor1,auditor2],ALLOW_HINT_DISABLE=true)
);
ALTER SHARDING ALGORITHM database_inline (
@@ -201,7 +243,8 @@ ALTER SHARDING TABLE RULE t_order_item (
DATANODES("resource_${0..3}.t_order_item${0..3}"),
DATABASE_STRATEGY(TYPE="standard",SHARDING_COLUMN=user_id,SHARDING_ALGORITHM=database_inline),
TABLE_STRATEGY(TYPE="standard",SHARDING_COLUMN=order_id,SHARDING_ALGORITHM=table_inline),
-KEY_GENERATE_STRATEGY(COLUMN=another_id,KEY_GENERATOR=snowflake_key_generator)
+KEY_GENERATE_STRATEGY(COLUMN=another_id,KEY_GENERATOR=snowflake_key_generator),
+AUDIT_STRATEGY(AUDITORS=[auditor1,auditor2],ALLOW_HINT_DISABLE=true)
);
DROP SHARDING TABLE RULE t_order_item;
diff --git
a/docs/document/content/user-manual/shardingsphere-proxy/distsql/syntax/rql/rule-query/sharding.cn.md
b/docs/document/content/user-manual/shardingsphere-proxy/distsql/syntax/rql/rule-query/sharding.cn.md
index db784c4df50..8ef10b35134 100644
---
a/docs/document/content/user-manual/shardingsphere-proxy/distsql/syntax/rql/rule-query/sharding.cn.md
+++
b/docs/document/content/user-manual/shardingsphere-proxy/distsql/syntax/rql/rule-query/sharding.cn.md
@@ -21,8 +21,12 @@ SHOW SHARDING TABLE RULES USED ALGORITHM
shardingAlgorithmName [FROM databaseNam
SHOW SHARDING KEY GENERATORS [FROM databaseName]
SHOW UNUSED SHARDING KEY GENERATORS [FROM databaseName]
+
+SHOW UNUSED SHARDING AUDITORS [FROM databaseName]
SHOW SHARDING TABLE RULES USED KEY GENERATOR keyGeneratorName [FROM
databaseName]
+
+SHOW SHARDING TABLE RULES USED AUDITOR auditorName [FROM databaseName]
SHOW DEFAULT SHARDING STRATEGY
@@ -49,22 +53,24 @@ SHOW SHARDING BROADCAST TABLE RULES [FROM databaseName]
### Sharding Table Rule
-| 列 | 说明 |
-| --------------------------------- | ---------------------------------- |
-| table | 逻辑表名 |
-| actual_data_nodes | 实际的数据节点 |
-| actual_data_sources | 实际的数据源(通过 RDL 创建的规则时显示)|
-| database_strategy_type | 数据库分片策略类型 |
-| database_sharding_column | 数据库分片键 |
-| database_sharding_algorithm_type | 数据库分片算法类型 |
-| database_sharding_algorithm_props | 数据库分片算法参数 |
-| table_strategy_type | 表分片策略类型 |
-| table_sharding_column | 表分片键 |
-| table_sharding_algorithm_type | 表分片算法类型 |
-| table_sharding_algorithm_props | 表分片算法参数 |
-| key_generate_column | 分布式主键生成列 |
-| key_generator_type | 分布式主键生成器类型 |
-| key_generator_props | 分布式主键生成器参数 |
+| 列 | 说明 |
+|-----------------------------------|-------------------------|
+| table | 逻辑表名 |
+| actual_data_nodes | 实际的数据节点 |
+| actual_data_sources | 实际的数据源(通过 RDL 创建的规则时显示) |
+| database_strategy_type | 数据库分片策略类型 |
+| database_sharding_column | 数据库分片键 |
+| database_sharding_algorithm_type | 数据库分片算法类型 |
+| database_sharding_algorithm_props | 数据库分片算法参数 |
+| table_strategy_type | 表分片策略类型 |
+| table_sharding_column | 表分片键 |
+| table_sharding_algorithm_type | 表分片算法类型 |
+| table_sharding_algorithm_props | 表分片算法参数 |
+| key_generate_column | 分布式主键生成列 |
+| key_generator_type | 分布式主键生成器类型 |
+| key_generator_props | 分布式主键生成器参数 |
+| auditor_types | 分片审计生成器参数 |
+| allow_hint_disable | 是否禁用分片审计hint |
### Sharding Algorithms
@@ -90,6 +96,14 @@ SHOW SHARDING BROADCAST TABLE RULES [FROM databaseName]
| type | 分片审计算法类型 |
| props | 分片审计算法参数 |
+### Unused Sharding Auditors
+
+| 列 | 说明 |
+| ------|-------------------|
+| name | 分片审计算法名称 |
+| type | 分片审计算法类型 |
+| props | 分片审计算法参数 |
+
### Sharding Key Generators
| 列 | 说明 |
@@ -142,11 +156,11 @@ SHOW SHARDING BROADCAST TABLE RULES [FROM databaseName]
```sql
mysql> SHOW SHARDING TABLE RULES;
+--------------+---------------------------------+-------------------+----------------------+------------------------+-------------------------------+----------------------------------------+-------------------+---------------------+----------------------------+---------------------------------------------------+-------------------+------------------+-------------------+
-| table | actual_data_nodes | actual_data_sources |
database_strategy_type | database_sharding_column |
database_sharding_algorithm_type | database_sharding_algorithm_props |
table_strategy_type | table_sharding_column | table_sharding_algorithm_type |
table_sharding_algorithm_props | key_generate_column |
key_generator_type | key_generator_props |
+| table | actual_data_nodes | actual_data_sources |
database_strategy_type | database_sharding_column |
database_sharding_algorithm_type | database_sharding_algorithm_props |
table_strategy_type | table_sharding_column | table_sharding_algorithm_type |
table_sharding_algorithm_props | key_generate_column |
key_generator_type | key_generator_props | auditor_types | allow_hint_disable |
+--------------+---------------------------------+-------------------+----------------------+------------------------+-------------------------------+----------------------------------------+-------------------+---------------------+----------------------------+---------------------------------------------------+-------------------+------------------+-------------------+
-| t_order | ds_${0..1}.t_order_${0..1} | | INLINE
| user_id | INLINE |
algorithm-expression:ds_${user_id % 2} | INLINE | order_id
| INLINE | algorithm-expression:t_order_${order_id % 2}
| order_id | SNOWFLAKE | |
-| t_order_item | ds_${0..1}.t_order_item_${0..1} | | INLINE
| user_id | INLINE |
algorithm-expression:ds_${user_id % 2} | INLINE | order_id
| INLINE | algorithm-expression:t_order_item_${order_id %
2} | order_item_id | SNOWFLAKE | |
-| t2 | | ds_0,ds_1 |
| | |
| mod | id | mod
| sharding-count:10 |
| | |
+| t_order | ds_${0..1}.t_order_${0..1} | | INLINE
| user_id | INLINE |
algorithm-expression:ds_${user_id % 2} | INLINE | order_id
| INLINE | algorithm-expression:t_order_${order_id % 2}
| order_id | SNOWFLAKE | |
DML_SHARDING_CONDITIONS |true |
+| t_order_item | ds_${0..1}.t_order_item_${0..1} | | INLINE
| user_id | INLINE |
algorithm-expression:ds_${user_id % 2} | INLINE | order_id
| INLINE | algorithm-expression:t_order_item_${order_id %
2} | order_item_id | SNOWFLAKE | |
| |
+| t2 | | ds_0,ds_1 |
| | |
| mod | id | mod
| sharding-count:10 |
| | |
| |
+--------------+---------------------------------+-------------------+----------------------+------------------------+-------------------------------+----------------------------------------+-------------------+---------------------+----------------------------+---------------------------------------------------+-------------------+------------------+-------------------+
3 rows in set (0.02 sec)
```
@@ -155,9 +169,9 @@ mysql> SHOW SHARDING TABLE RULES;
```sql
mysql> SHOW SHARDING TABLE RULE t_order;
+---------+----------------------------+-------------------+----------------------+------------------------+-------------------------------+----------------------------------------+-------------------+---------------------+----------------------------+----------------------------------------------+-------------------+------------------+-------------------+
-| table | actual_data_nodes | actual_data_sources |
database_strategy_type | database_sharding_column |
database_sharding_algorithm_type | database_sharding_algorithm_props |
table_strategy_type | table_sharding_column | table_sharding_algorithm_type |
table_sharding_algorithm_props | key_generate_column |
key_generator_type | key_generator_props |
+| table | actual_data_nodes | actual_data_sources |
database_strategy_type | database_sharding_column |
database_sharding_algorithm_type | database_sharding_algorithm_props |
table_strategy_type | table_sharding_column | table_sharding_algorithm_type |
table_sharding_algorithm_props | key_generate_column |
key_generator_type | key_generator_props | auditor_types | allow_hint_disable |
+---------+----------------------------+-------------------+----------------------+------------------------+-------------------------------+----------------------------------------+-------------------+---------------------+----------------------------+----------------------------------------------+-------------------+------------------+-------------------+
-| t_order | ds_${0..1}.t_order_${0..1} | | INLINE
| user_id | INLINE |
algorithm-expression:ds_${user_id % 2} | INLINE | order_id
| INLINE | algorithm-expression:t_order_${order_id % 2} |
order_id | SNOWFLAKE | |
+| t_order | ds_${0..1}.t_order_${0..1} | | INLINE
| user_id | INLINE |
algorithm-expression:ds_${user_id % 2} | INLINE | order_id
| INLINE | algorithm-expression:t_order_${order_id % 2} |
order_id | SNOWFLAKE | |
DML_SHARDING_CONDITIONS |true |
+---------+----------------------------+-------------------+----------------------+------------------------+-------------------------------+----------------------------------------+-------------------+---------------------+----------------------------+----------------------------------------------+-------------------+------------------+-------------------+
1 row in set (0.01 sec)
```
@@ -226,11 +240,22 @@ mysql> SHOW UNUSED SHARDING KEY GENERATORS;
+------------------------+-----------+-----------------+
| name | type | props |
+------------------------+-----------+-----------------+
-| uuid_key_generator | uuid | |
+| dml_audit | uuid | |
+------------------------+-----------+-----------------+
1 row in set (0.01 sec)
```
+*SHOW UNUSED SHARDING KEY AUDITORS*
+```sql
+mysql> SHOW UNUSED SHARDING KEY AUDITORS;
++------------+-------------------------+-------+
+| name | type | props |
++------------+-------------------------+-------+
+| dml_audit | DML_SHARDING_CONDITIONS | |
++------------+-------------------------+-------+
+1 row in set (0.01 sec)
+```
+
*SHOW SHARDING TABLE RULES USED KEY GENERATOR keyGeneratorName*
```sql
mysql> SHOW SHARDING TABLE RULES USED KEY GENERATOR t_order_snowflake;
@@ -242,6 +267,17 @@ mysql> SHOW SHARDING TABLE RULES USED KEY GENERATOR
t_order_snowflake;
1 row in set (0.01 sec)
```
+*SHOW SHARDING TABLE RULES USED AUDITOR auditorName*
+```sql
+mysql> SHOW SHARDING TABLE RULES USED AUDITOR sharding_key_required;
++-------+---------+
+| type | name |
++-------+---------+
+| table | t_order |
++-------+---------+
+1 row in set (0.01 sec)
+```
+
*SHOW DEFAULT SHARDING STRATEGY*
```sql
mysql> SHOW DEFAULT SHARDING STRATEGY ;
diff --git
a/docs/document/content/user-manual/shardingsphere-proxy/distsql/syntax/rql/rule-query/sharding.en.md
b/docs/document/content/user-manual/shardingsphere-proxy/distsql/syntax/rql/rule-query/sharding.en.md
index e8a36622354..76c868757fb 100644
---
a/docs/document/content/user-manual/shardingsphere-proxy/distsql/syntax/rql/rule-query/sharding.en.md
+++
b/docs/document/content/user-manual/shardingsphere-proxy/distsql/syntax/rql/rule-query/sharding.en.md
@@ -21,8 +21,12 @@ SHOW SHARDING TABLE RULES USED ALGORITHM
shardingAlgorithmName [FROM databaseNam
SHOW SHARDING KEY GENERATORS [FROM databaseName]
SHOW UNUSED SHARDING KEY GENERATORS [FROM databaseName]
+
+SHOW UNUSED SHARDING AUDITORS [FROM databaseName]
SHOW SHARDING TABLE RULES USED KEY GENERATOR keyGeneratorName [FROM
databaseName]
+
+SHOW SHARDING TABLE RULES USED AUDITOR auditorName [FROM databaseName]
SHOW DEFAULT SHARDING STRATEGY
@@ -50,21 +54,23 @@ SHOW SHARDING BROADCAST TABLE RULES [FROM databaseName]
### Sharding Table Rule
| Column | Description
|
-| --------------------------------- |
--------------------------------------------------------- |
+| ---------------------------------
|-----------------------------------------------------------|
| table | Logical table name
|
| actual_data_nodes | Actual data node
|
| actual_data_sources | Actual data source (Displayed when
creating rules by RDL) |
| database_strategy_type | Database sharding strategy type
|
| database_sharding_column | Database sharding column
|
| database_sharding_algorithm_type | Database sharding algorithm type
|
-| database_sharding_algorithm_props | Database sharding algorithm properties
|
+| database_sharding_algorithm_props | Database sharding algorithm properties
|
| table_strategy_type | Table sharding strategy type
|
| table_sharding_column | Table sharding column
|
| table_sharding_algorithm_type | Table sharding algorithm type
|
-| table_sharding_algorithm_props | Table sharding algorithm properties
|
+| table_sharding_algorithm_props | Table sharding algorithm properties
|
| key_generate_column | Sharding key generator column
|
| key_generator_type | Sharding key generator type
|
| key_generator_props | Sharding key generator properties
|
+| auditor_types | Sharding auditor types
|
+| allow_hint_disable | Enable or disable sharding audit hint
|
### Sharding Algorithms
@@ -90,6 +96,14 @@ SHOW SHARDING BROADCAST TABLE RULES [FROM databaseName]
| type | Sharding audit algorithm type |
| props | Sharding audit algorithm properties |
+### Unused Sharding Auditors
+
+| Column | Description |
+| ------ |-------------------------------------|
+| name | Sharding audit algorithm name |
+| type | Sharding audit algorithm type |
+| props | Sharding audit algorithm properties |
+
### Sharding key generators
| Column | Description |
@@ -142,11 +156,11 @@ SHOW SHARDING BROADCAST TABLE RULES [FROM databaseName]
```sql
mysql> SHOW SHARDING TABLE RULES;
+--------------+---------------------------------+-------------------+----------------------+------------------------+-------------------------------+----------------------------------------+-------------------+---------------------+----------------------------+---------------------------------------------------+-------------------+------------------+-------------------+
-| table | actual_data_nodes | actual_data_sources |
database_strategy_type | database_sharding_column |
database_sharding_algorithm_type | database_sharding_algorithm_props |
table_strategy_type | table_sharding_column | table_sharding_algorithm_type |
table_sharding_algorithm_props | key_generate_column |
key_generator_type | key_generator_props |
+| table | actual_data_nodes | actual_data_sources |
database_strategy_type | database_sharding_column |
database_sharding_algorithm_type | database_sharding_algorithm_props |
table_strategy_type | table_sharding_column | table_sharding_algorithm_type |
table_sharding_algorithm_props | key_generate_column |
key_generator_type | key_generator_props |auditor_types | allow_hint_disable |
+--------------+---------------------------------+-------------------+----------------------+------------------------+-------------------------------+----------------------------------------+-------------------+---------------------+----------------------------+---------------------------------------------------+-------------------+------------------+-------------------+
-| t_order | ds_${0..1}.t_order_${0..1} | | INLINE
| user_id | INLINE |
algorithm-expression:ds_${user_id % 2} | INLINE | order_id
| INLINE | algorithm-expression:t_order_${order_id % 2}
| order_id | SNOWFLAKE | |
-| t_order_item | ds_${0..1}.t_order_item_${0..1} | | INLINE
| user_id | INLINE |
algorithm-expression:ds_${user_id % 2} | INLINE | order_id
| INLINE | algorithm-expression:t_order_item_${order_id %
2} | order_item_id | SNOWFLAKE | |
-| t2 | | ds_0,ds_1 |
| | |
| mod | id | mod
| sharding-count:10 |
| | |
+| t_order | ds_${0..1}.t_order_${0..1} | | INLINE
| user_id | INLINE |
algorithm-expression:ds_${user_id % 2} | INLINE | order_id
| INLINE | algorithm-expression:t_order_${order_id % 2}
| order_id | SNOWFLAKE |
|DML_SHARDING_CONDITIONS |true |
+| t_order_item | ds_${0..1}.t_order_item_${0..1} | | INLINE
| user_id | INLINE |
algorithm-expression:ds_${user_id % 2} | INLINE | order_id
| INLINE | algorithm-expression:t_order_item_${order_id %
2} | order_item_id | SNOWFLAKE | |
| |
+| t2 | | ds_0,ds_1 |
| | |
| mod | id | mod
| sharding-count:10 |
| | |
| |
+--------------+---------------------------------+-------------------+----------------------+------------------------+-------------------------------+----------------------------------------+-------------------+---------------------+----------------------------+---------------------------------------------------+-------------------+------------------+-------------------+
3 rows in set (0.02 sec)
```
@@ -155,9 +169,9 @@ mysql> SHOW SHARDING TABLE RULES;
```sql
mysql> SHOW SHARDING TABLE RULE t_order;
+---------+----------------------------+-------------------+----------------------+------------------------+-------------------------------+----------------------------------------+-------------------+---------------------+----------------------------+----------------------------------------------+-------------------+------------------+-------------------+
-| table | actual_data_nodes | actual_data_sources |
database_strategy_type | database_sharding_column |
database_sharding_algorithm_type | database_sharding_algorithm_props |
table_strategy_type | table_sharding_column | table_sharding_algorithm_type |
table_sharding_algorithm_props | key_generate_column |
key_generator_type | key_generator_props |
+| table | actual_data_nodes | actual_data_sources |
database_strategy_type | database_sharding_column |
database_sharding_algorithm_type | database_sharding_algorithm_props |
table_strategy_type | table_sharding_column | table_sharding_algorithm_type |
table_sharding_algorithm_props | key_generate_column |
key_generator_type | key_generator_props | auditor_types | allow_hint_disable |
+---------+----------------------------+-------------------+----------------------+------------------------+-------------------------------+----------------------------------------+-------------------+---------------------+----------------------------+----------------------------------------------+-------------------+------------------+-------------------+
-| t_order | ds_${0..1}.t_order_${0..1} | | INLINE
| user_id | INLINE |
algorithm-expression:ds_${user_id % 2} | INLINE | order_id
| INLINE | algorithm-expression:t_order_${order_id % 2} |
order_id | SNOWFLAKE | |
+| t_order | ds_${0..1}.t_order_${0..1} | | INLINE
| user_id | INLINE |
algorithm-expression:ds_${user_id % 2} | INLINE | order_id
| INLINE | algorithm-expression:t_order_${order_id % 2} |
order_id | SNOWFLAKE | |
DML_SHARDING_CONDITIONS |true |
+---------+----------------------------+-------------------+----------------------+------------------------+-------------------------------+----------------------------------------+-------------------+---------------------+----------------------------+----------------------------------------------+-------------------+------------------+-------------------+
1 row in set (0.01 sec)
```
@@ -231,6 +245,17 @@ mysql> SHOW UNUSED SHARDING KEY GENERATORS;
1 row in set (0.01 sec)
```
+*SHOW UNUSED SHARDING KEY AUDITORS*
+```sql
+mysql> SHOW UNUSED SHARDING KEY AUDITORS;
++------------+-------------------------+-------+
+| name | type | props |
++------------+-------------------------+-------+
+| dml_audit | DML_SHARDING_CONDITIONS | |
++------------+-------------------------+-------+
+1 row in set (0.01 sec)
+```
+
*SHOW SHARDING TABLE RULES USED KEY GENERATOR keyGeneratorName*
```sql
mysql> SHOW SHARDING TABLE RULES USED KEY GENERATOR keyGeneratorName;
@@ -242,6 +267,17 @@ mysql> SHOW SHARDING TABLE RULES USED KEY GENERATOR
keyGeneratorName;
1 row in set (0.01 sec)
```
+*SHOW SHARDING TABLE RULES USED AUDITOR auditorName*
+```sql
+mysql> SHOW SHARDING TABLE RULES USED AUDITOR sharding_key_required;
++-------+---------+
+| type | name |
++-------+---------+
+| table | t_order |
++-------+---------+
+1 row in set (0.01 sec)
+```
+
*SHOW DEFAULT SHARDING STRATEGY*
```sql
mysql> SHOW DEFAULT SHARDING STRATEGY ;
diff --git
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/rql/BaseRQLIT.java
b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/rql/BaseRQLIT.java
index ff078efdce8..93d37637a86 100644
---
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/rql/BaseRQLIT.java
+++
b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/rql/BaseRQLIT.java
@@ -65,11 +65,11 @@ public abstract class BaseRQLIT extends SingleITCase {
int rowCount = 0;
ResultSetMetaData actualMetaData = actual.getMetaData();
while (actual.next()) {
- assertTrue("Size of actual result set is different with size of
expected dat set rows.", rowCount < expected.size());
+ assertTrue("Size of actual result set is different with size of
expected data set rows.", rowCount < expected.size());
assertRow(actual, actualMetaData, expected.get(rowCount));
rowCount++;
}
- assertThat("Size of actual result set is different with size of
expected dat set rows.", rowCount, is(expected.size()));
+ assertThat("Size of actual result set is different with size of
expected data set rows.", rowCount, is(expected.size()));
}
private void assertRow(final ResultSet actual, final ResultSetMetaData
actualMetaData, final DataSetRow expected) throws SQLException {