This is an automated email from the ASF dual-hosted git repository. menghaoran 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 750cfde85dc Refactor ParseDistSQLHandler (#18296) 750cfde85dc is described below commit 750cfde85dc8eaf8f53b54b0039a0a9f6b2d1c53 Author: Liang Zhang <zhangli...@apache.org> AuthorDate: Sat Jun 11 10:23:50 2022 +0800 Refactor ParseDistSQLHandler (#18296) --- .../distsql/syntax/ral/_index.cn.md | 74 +++++++++++----------- .../distsql/syntax/ral/_index.en.md | 62 +++++++++--------- .../syntax/rql/rule-query/db-discovery.cn.md | 10 +-- .../syntax/rql/rule-query/db-discovery.en.md | 2 +- .../distsql/syntax/rql/rule-query/encrypt.cn.md | 4 +- .../distsql/syntax/rql/rule-query/encrypt.en.md | 28 ++++---- .../distsql/syntax/rql/rule-query/shadow.cn.md | 26 ++++---- .../distsql/syntax/rql/rule-query/shadow.en.md | 8 +-- .../distsql/ral/advanced/ParseDistSQLHandler.java | 9 ++- 9 files changed, 113 insertions(+), 110 deletions(-) diff --git a/docs/document/content/user-manual/shardingsphere-proxy/distsql/syntax/ral/_index.cn.md b/docs/document/content/user-manual/shardingsphere-proxy/distsql/syntax/ral/_index.cn.md index 39f229d8ea6..e2aea4f95c8 100644 --- a/docs/document/content/user-manual/shardingsphere-proxy/distsql/syntax/ral/_index.cn.md +++ b/docs/document/content/user-manual/shardingsphere-proxy/distsql/syntax/ral/_index.cn.md @@ -15,35 +15,35 @@ RAL (Resource & Rule Administration Language) 为 Apache ShardingSphere 的管 | SET SHARDING HINT DATABASE_VALUE = yy | 针对当前连接,设置 hint 仅对数据库分片有效,并添加分片值,yy:数据库分片值 | SET SHARDING HINT DATABASE_VALUE = 100 | | ADD SHARDING HINT DATABASE_VALUE xx = yy | 针对当前连接,为表 xx 添加分片值 yy,xx:逻辑表名称,yy:数据库分片值 | ADD SHARDING HINT DATABASE_VALUE t_order= 100 | | ADD SHARDING HINT TABLE_VALUE xx = yy | 针对当前连接,为表 xx 添加分片值 yy,xx:逻辑表名称,yy:表分片值 | ADD SHARDING HINT TABLE_VALUE t_order = 100 | -| CLEAR HINT SETTINGS | 针对当前连接,清除 hint 所有设置 | CLEAR HINT | +| CLEAR HINT SETTINGS | 针对当前连接,清除 hint 所有设置 | CLEAR HINT | | CLEAR [SHARDING HINT / READWRITE_SPLITTING HINT] | 针对当前连接,清除 sharding 或 readwrite_splitting 的 hint 设置 | CLEAR READWRITE_SPLITTING HINT | | SHOW [SHARDING / READWRITE_SPLITTING] HINT STATUS | 针对当前连接,查询 sharding 或 readwrite_splitting 的 hint 设置 | SHOW READWRITE_SPLITTING HINT STATUS | ## 弹性伸缩 -| 语句 | 说明 | 示例 | -|:--------------------------------------------------- |:------------------------------------------------------------- |:----------------------------------------------- | -| SHOW SCALING LIST | 查询运行列表 | SHOW SCALING LIST | -| SHOW SCALING STATUS jobId | 查询任务状态,xx:任务 id | SHOW SCALING STATUS 1234 | -| START SCALING jobId | 开始运行任务,xx:任务 id | START SCALING 1234 | -| STOP SCALING jobId | 停止运行任务,xx:任务 id | STOP SCALING 12345 | -| DROP SCALING jobId | 移除任务,xx:任务 id | DROP SCALING 1234 | -| RESET SCALING jobId | 重置任务进度,xx:任务 id | RESET SCALING 1234 | -| CHECK SCALING jobId | 数据一致性校验,使用 `server.yaml` 里的校验算法,xx:任务 id | CHECK SCALING 1234 | -| SHOW SCALING CHECK ALGORITHMS | 展示可用的一致性校验算法 | SHOW SCALING CHECK ALGORITHMS | -| CHECK SCALING {jobId} by type(name={algorithmType}) | 数据一致性校验,使用指定的校验算法 | CHECK SCALING 1234 by type(name=DEFAULT) | -| STOP SCALING SOURCE WRITING jobId | 旧的 ShardingSphere 数据源停写,xx:任务 id | STOP SCALING SOURCE WRITING 1234 | -| RESTORE SCALING SOURCE WRITING jobId | 旧的 ShardingSphere 数据源恢复写,xx:任务 id | RESTORE SCALING SOURCE WRITING 1234 | -| APPLY SCALING jobId | 切换至新的 ShardingSphere 元数据,xx:任务 id | APPLY SCALING 1234 | +| 语句 | 说明 | 示例 | +|:--------------------------------------------------- |:----------------------------------------------------- |:--------------------------------------- | +| SHOW SCALING LIST | 查询运行列表 | SHOW SCALING LIST | +| SHOW SCALING STATUS jobId | 查询任务状态,xx:任务 id | SHOW SCALING STATUS 1234 | +| START SCALING jobId | 开始运行任务,xx:任务 id | START SCALING 1234 | +| STOP SCALING jobId | 停止运行任务,xx:任务 id | STOP SCALING 12345 | +| DROP SCALING jobId | 移除任务,xx:任务 id | DROP SCALING 1234 | +| RESET SCALING jobId | 重置任务进度,xx:任务 id | RESET SCALING 1234 | +| CHECK SCALING jobId | 数据一致性校验,使用 `server.yaml` 里的校验算法,xx:任务 id | CHECK SCALING 1234 | +| SHOW SCALING CHECK ALGORITHMS | 展示可用的一致性校验算法 | SHOW SCALING CHECK ALGORITHMS | +| CHECK SCALING {jobId} by type(name={algorithmType}) | 数据一致性校验,使用指定的校验算法 | CHECK SCALING 1234 by type(name=DEFAULT) | +| STOP SCALING SOURCE WRITING jobId | 旧的 ShardingSphere 数据源停写,xx:任务 id | STOP SCALING SOURCE WRITING 1234 | +| RESTORE SCALING SOURCE WRITING jobId | 旧的 ShardingSphere 数据源恢复写,xx:任务 id | RESTORE SCALING SOURCE WRITING 1234 | +| APPLY SCALING jobId | 切换至新的 ShardingSphere 元数据,xx:任务 id | APPLY SCALING 1234 | ## 熔断 -| 语句 | 说明 | 示例 | -|:--------------------------------------------------------------------------------|:-------------------------------------------------- |:-------------------------------------------| -| [ENABLE / DISABLE] READWRITE_SPLITTING (READ)? resourceName [FROM databaseName] | 启用 / 禁用读库 | ENABLE READWRITE_SPLITTING READ resource_0 | -| [ENABLE / DISABLE] INSTANCE instanceId | 启用 / 禁用 proxy 实例 | DISABLE INSTANCE instance_1 | -| SHOW INSTANCE LIST | 查询 proxy 实例信息 | SHOW INSTANCE LIST | -| SHOW READWRITE_SPLITTING (READ)? resourceName [FROM databaseName] | 查询所有读库的状态 | SHOW READWRITE_SPLITTING READ RESOURCES | +| 语句 | 说明 | 示例 | +|:------------------------------------------------------------------------------- |:-------------------- |:------------------------------------------ | +| [ENABLE / DISABLE] READWRITE_SPLITTING (READ)? resourceName [FROM databaseName] | 启用 / 禁用读库 | ENABLE READWRITE_SPLITTING READ resource_0 | +| [ENABLE / DISABLE] INSTANCE instanceId | 启用 / 禁用 proxy 实例 | DISABLE INSTANCE instance_1 | +| SHOW INSTANCE LIST | 查询 proxy 实例信息 | SHOW INSTANCE LIST | +| SHOW READWRITE_SPLITTING (READ)? resourceName [FROM databaseName] | 查询所有读库的状态 | SHOW READWRITE_SPLITTING READ RESOURCES | ## 全局规则 @@ -57,22 +57,22 @@ RAL (Resource & Rule Administration Language) 为 Apache ShardingSphere 的管 ## 其他 -| 语句 | 说明 | 示例 | -|:--------------------------------------------------------------------------- |:----------------------------------------------------------- |:----------------------------------------------- | -| SHOW INSTANCE MODE | 查询当前 proxy 的 mode 配置 | SHOW INSTANCE MODE | -| COUNT DATABASE RULES [FROM database] | 查询 database 中的规则数量 | COUNT DATABASE RULES | -| SET VARIABLE proxy_property_name = xx | proxy_property_name 为 proxy 的[属性配置](/cn/user-manual/shardingsphere-proxy/yaml-config/props/) ,需使用下划线命名 | SET VARIABLE sql_show = true | -| SET VARIABLE transaction_type = xx | 修改当前连接的事务类型, 支持 LOCAL,XA,BASE | SET VARIABLE transaction_type = XA | -| SET VARIABLE agent_plugins_enabled = [TRUE / FALSE] | 设置 agent 插件的启用状态,默认值 false | SET VARIABLE agent_plugins_enabled = TRUE | -| SHOW ALL VARIABLES | 查询 proxy 所有的属性配置 | SHOW ALL VARIABLES | -| SHOW VARIABLE variable_name | 查询 proxy 属性,需使用下划线命名 | SHOW VARIABLE sql_show | -| PREVIEW SQL | 预览实际 SQL | PREVIEW SELECT * FROM t_order | -| PARSE SQL | 解析 SQL 并输出抽象语法树 PARSE SELECT * FROM t_order | -| REFRESH TABLE METADATA | 刷新所有表的元数据 | REFRESH TABLE METADATA | -| REFRESH TABLE METADATA [tableName / tableName FROM RESOURCE resourceName] | 刷新指定表的元数据 | REFRESH TABLE METADATA t_order FROM RESOURCE ds_1 | -| SHOW TABLE METADATA tableName [, tableName] ... | 查询表的元数据 | SHOW TABLE METADATA t_order | -| EXPORT DATABASE CONFIG [FROM database_name] [, file="file_path"] | 查询 / 导出 database 中的资源和规则配置 | EXPORT DATABASE CONFIG FROM readwrite_splitting_db | -| SHOW RULES USED RESOURCE resourceName [from database] | 查询 database 中使用指定资源的规则 | SHOW RULES USED RESOURCE ds_0 FROM databaseName | +| 语句 | 说明 | 示例 | +|:------------------------------------------------------------------------- |:--------------------------------------------------------------------------------------------------------------- |:------------------------------------------------ | +| SHOW INSTANCE MODE | 查询当前 proxy 的 mode 配置 | SHOW INSTANCE MODE | +| COUNT DATABASE RULES [FROM database] | 查询 database 中的规则数量 | COUNT DATABASE RULES | +| SET VARIABLE proxy_property_name = xx | proxy_property_name 为 proxy 的[属性配置](/cn/user-manual/shardingsphere-proxy/yaml-config/props/) ,需使用下划线命名 | SET VARIABLE sql_show = true | +| SET VARIABLE transaction_type = xx | 修改当前连接的事务类型, 支持 LOCAL,XA,BASE | SET VARIABLE transaction_type = XA | +| SET VARIABLE agent_plugins_enabled = [TRUE / FALSE] | 设置 agent 插件的启用状态,默认值 false | SET VARIABLE agent_plugins_enabled = TRUE | +| SHOW ALL VARIABLES | 查询 proxy 所有的属性配置 | SHOW ALL VARIABLES | +| SHOW VARIABLE variable_name | 查询 proxy 属性,需使用下划线命名 | SHOW VARIABLE sql_show | +| PREVIEW SQL | 预览实际 SQL | PREVIEW SELECT * FROM t_order | +| PARSE SQL | 解析 SQL 并输出抽象语法树 | PARSE SELECT * FROM t_order | +| REFRESH TABLE METADATA | 刷新所有表的元数据 | REFRESH TABLE METADATA | +| REFRESH TABLE METADATA [tableName / tableName FROM RESOURCE resourceName] | 刷新指定表的元数据 | REFRESH TABLE METADATA t_order FROM RESOURCE ds_1 | +| SHOW TABLE METADATA tableName [, tableName] ... | 查询表的元数据 | SHOW TABLE METADATA t_order | +| EXPORT DATABASE CONFIG [FROM database_name] [, file="file_path"] | 查询 / 导出 database 中的资源和规则配置 | EXPORT DATABASE CONFIG FROM readwrite_splitting_db | +| SHOW RULES USED RESOURCE resourceName [from database] | 查询 database 中使用指定资源的规则 | SHOW RULES USED RESOURCE ds_0 FROM databaseName | ## 注意事项 diff --git a/docs/document/content/user-manual/shardingsphere-proxy/distsql/syntax/ral/_index.en.md b/docs/document/content/user-manual/shardingsphere-proxy/distsql/syntax/ral/_index.en.md index ead783d6934..aefdfba0a70 100644 --- a/docs/document/content/user-manual/shardingsphere-proxy/distsql/syntax/ral/_index.en.md +++ b/docs/document/content/user-manual/shardingsphere-proxy/distsql/syntax/ral/_index.en.md @@ -10,11 +10,11 @@ RAL (Resource & Rule Administration Language) responsible for the added-on featu | Statement | Function | Example | |:---------------------------------------------------- |:----------------------------------------------------------------------------------------------------------- |:---------------------------------------------- | -| SET READWRITE_SPLITTING HINT SOURCE = [auto / write] | For current connection, set readwrite splitting routing strategy (automatic or forced to write data source) | SET READWRITE_SPLITTINGHINT SOURCE = write | +| SET READWRITE_SPLITTING HINT SOURCE = [auto / write] | For current connection, set readwrite splitting routing strategy (automatic or forced to write data source) | SET READWRITE_SPLITTINGHINT SOURCE = write | | SET SHARDING HINT DATABASE_VALUE = yy | For current connection, set sharding value for database sharding only, yy: sharding value | SET SHARDING HINT DATABASE_VALUE = 100 | -| ADD SHARDING HINT DATABASE_VALUE xx = yy | For current connection, add sharding value for table, xx: logic table, yy: database sharding value | ADD SHARDING HINT DATABASE_VALUE t_order = 100 | +| ADD SHARDING HINT DATABASE_VALUE xx = yy | For current connection, add sharding value for table, xx: logic table, yy: database sharding value | ADD SHARDING HINT DATABASE_VALUE t_order = 100 | | ADD SHARDING HINT TABLE_VALUE xx = yy | For current connection, add sharding value for table, xx: logic table, yy: table sharding value | ADD SHARDING HINT TABLE_VALUE t_order = 100 | -| CLEAR HINT SETTINGS | For current connection, clear all hint settings | CLEAR HINT | +| CLEAR HINT SETTINGS | For current connection, clear all hint settings | CLEAR HINT | | CLEAR [SHARDING HINT / READWRITE_SPLITTING HINT] | For current connection, clear hint settings of sharding or readwrite splitting | CLEAR READWRITE_SPLITTING HINT | | SHOW [SHARDING / READWRITE_SPLITTING] HINT STATUS | For current connection, query hint settings of sharding or readwrite splitting | SHOW READWRITE_SPLITTING HINT STATUS | @@ -23,22 +23,22 @@ RAL (Resource & Rule Administration Language) responsible for the added-on featu | Statement | Function | Example | |:---------------------------------------------------- |:----------------------------------------------------------------- |:---------------------------------------- | | SHOW SCALING LIST | Query running list | SHOW SCALING LIST | -| SHOW SCALING STATUS jobId | Query scaling status, xx: jobId | SHOW SCALING STATUS 1234 | -| START SCALING jobId | Start scaling, xx: jobId | START SCALING 1234 | -| STOP SCALING jobId | Stop scaling, xx: jobId | STOP SCALING 1234 | -| DROP SCALING jobId | Drop scaling, xx: jobId | DROP SCALING 1234 | -| RESET SCALING jobId | reset progress, xx: jobId | RESET SCALING 1234 | -| CHECK SCALING jobId | Data consistency check with algorithm in `server.yaml`, xx: jobId | CHECK SCALING 1234 | +| SHOW SCALING STATUS jobId | Query scaling status, xx: jobId | SHOW SCALING STATUS 1234 | +| START SCALING jobId | Start scaling, xx: jobId | START SCALING 1234 | +| STOP SCALING jobId | Stop scaling, xx: jobId | STOP SCALING 1234 | +| DROP SCALING jobId | Drop scaling, xx: jobId | DROP SCALING 1234 | +| RESET SCALING jobId | reset progress, xx: jobId | RESET SCALING 1234 | +| CHECK SCALING jobId | Data consistency check with algorithm in `server.yaml`, xx: jobId | CHECK SCALING 1234 | | SHOW SCALING CHECK ALGORITHMS | Show available consistency check algorithms | SHOW SCALING CHECK ALGORITHMS | | CHECK SCALING {jobId} by type(name={algorithmType}) | Data consistency check with defined algorithm | CHECK SCALING 1234 by type(name=DEFAULT) | -| STOP SCALING SOURCE WRITING jobId | The source ShardingSphere data source is discontinued, xx: jobId | STOP SCALING SOURCE WRITING 1234 | -| RESTORE SCALING SOURCE WRITING jobId | Restore source data source writing, xx: jobId | RESTORE SCALING SOURCE WRITING 1234 | -| APPLY SCALING jobId | Switch to target ShardingSphere metadata, xx: jobId | APPLY SCALING 1234 | +| STOP SCALING SOURCE WRITING jobId | The source ShardingSphere data source is discontinued, xx: jobId | STOP SCALING SOURCE WRITING 1234 | +| RESTORE SCALING SOURCE WRITING jobId | Restore source data source writing, xx: jobId | RESTORE SCALING SOURCE WRITING 1234 | +| APPLY SCALING jobId | Switch to target ShardingSphere metadata, xx: jobId | APPLY SCALING 1234 | ## Circuit Breaker | Statement | Function | Example | -|:--------------------------------------------------------------------------------|:---------------------------------- |:-------------------------------------------| +|:------------------------------------------------------------------------------- |:---------------------------------- |:------------------------------------------ | | [ENABLE / DISABLE] READWRITE_SPLITTING (READ)? resourceName [FROM databaseName] | Enable or disable read data source | ENABLE READWRITE_SPLITTING READ resource_0 | | [ENABLE / DISABLE] INSTANCE instanceId | Enable or disable proxy instance | DISABLE INSTANCE instance_1 | | SHOW INSTANCE LIST | Query proxy instance information | SHOW INSTANCE LIST | @@ -47,31 +47,31 @@ RAL (Resource & Rule Administration Language) responsible for the added-on featu ## Global Rule | Statement | Function | Example [...] -|:--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|:---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|:------------------------------------------------------------- [...] +|:------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |:-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |:------------------------------------------------------------- [...] | SHOW AUTHORITY RULE | Query authority rule configuration | SHOW AUTHORITY RULE [...] | SHOW TRANSACTION RULE | Query transaction rule configuration | SHOW TRANSACTION RULE [...] | SHOW SQL_PARSER RULE | Query SQL parser rule configuration | SHOW SQL_PARSER RULE [...] -| ALTER TRANSACTION RULE(DEFAULT=xx,TYPE(NAME=xxx, PROPERTIES("key1"="value1","key2"="value2"...))) | Alter transaction rule configuration, `DEFAULT`: default transaction type, support LOCAL, XA, BASE; `NAME`: name of transaction manager, support Atomikos, Narayana and Bitronix | ALTER TRANSACTION RULE(DEFAULT=XA,TYPE(NAME=Narayana, PROPER [...] +| ALTER TRANSACTION RULE(DEFAULT=xx,TYPE(NAME=xxx, PROPERTIES("key1"="value1","key2"="value2"...))) | Alter transaction rule configuration, `DEFAULT`: default transaction type, support LOCAL, XA, BASE; `NAME`: name of transaction manager, support Atomikos, Narayana and Bitronix | ALTER TRANSACTION RULE(DEFAULT=XA,TYPE(NAME=Narayana, PROPERT [...] | ALTER SQL_PARSER RULE SQL_COMMENT_PARSE_ENABLE=xx, PARSE_TREE_CACHE(INITIAL_CAPACITY=xx, MAXIMUM_SIZE=xx, CONCURRENCY_LEVEL=xx), SQL_STATEMENT_CACHE(INITIAL_CAPACITY=xxx, MAXIMUM_SIZE=xxx, CONCURRENCY_LEVEL=xxx) | Alter SQL parser rule configuration, `SQL_COMMENT_PARSE_ENABLE`: whether to parse the SQL comment, `PARSE_TREE_CACHE`: local cache configuration of syntax tree, `SQL_STATEMENT_CACHE`: local cache of SQL statement | ALTER SQL_PARSER RULE SQL_COMMENT_PARSE_ENABLE=false, PARSE_T [...] ## Other -| Statement | Function | Example | -|:--------------------------------------------------------------------------- |:---------------------------------------------------------------------------------- |:----------------------------------------- | -| SHOW INSTANCE MODE | Query the mode configuration of the proxy | SHOW INSTANCE MODE | -| COUNT DATABASE RULES [FROM database] | Query the number of rules in a database | COUNT DATABASE RULES | -| SET VARIABLE proxy_property_name = xx | proxy_property_name is one of [properties configuration](/en/user-manual/shardingsphere-proxy/yaml-config/props/) of proxy, name is split by underscore | SET VARIABLE sql_show = true | -| SET VARIABLE transaction_type = xx | Modify transaction_type of the current connection, supports LOCAL, XA, BASE | SET VARIABLE transaction_type = XA | -| SET VARIABLE agent_plugins_enabled = [TRUE / FALSE] | Set whether the agent plugins are enabled, the default value is false | SET VARIABLE agent_plugins_enabled = TRUE | -| SHOW ALL VARIABLES | Query proxy all properties configuration | SHOW ALL VARIABLES | -| SHOW VARIABLE variable_name | Query proxy variable, name is split by underscore | SHOW VARIABLE sql_show | -| PREVIEW SQL | Preview the actual SQLs | PREVIEW SELECT * FROM t_order | -| PARSE SQL | Parse SQL and output abstract syntax tree | PARSE SELECT * FROM t_order | -| REFRESH TABLE METADATA | Refresh the metadata of all tables | REFRESH TABLE METADATA | -| REFRESH TABLE METADATA [tableName / tableName FROM RESOURCE resourceName] | Refresh the metadata of a table | REFRESH TABLE METADATA t_order FROM resource ds_1 | -| SHOW TABLE METADATA tableName [, tableName] ... | Query table metadata | SHOW TABLE METADATA t_order | -| EXPORT DATABASE CONFIG [FROM database_name] [, file="file_path"] | Query / export resources and rule configuration in database | EXPORT DATABASE CONFIG FROM readwrite_splitting_db | -| SHOW RULES USED RESOURCE resourceName [from database] | Query the rules for using the specified resource in database | SHOW RULES USED RESOURCE ds_0 FROM databaseName | +| Statement | Function | Example | +|:------------------------------------------------------------------------- |:------------------------------------------------------------------------------------------------------------------------------------------------------- |:-------------------------------------------------- | +| SHOW INSTANCE MODE | Query the mode configuration of the proxy | SHOW INSTANCE MODE | +| COUNT DATABASE RULES [FROM database] | Query the number of rules in a database | COUNT DATABASE RULES | +| SET VARIABLE proxy_property_name = xx | proxy_property_name is one of [properties configuration](/en/user-manual/shardingsphere-proxy/yaml-config/props/) of proxy, name is split by underscore | SET VARIABLE sql_show = true | +| SET VARIABLE transaction_type = xx | Modify transaction_type of the current connection, supports LOCAL, XA, BASE | SET VARIABLE transaction_type = XA | +| SET VARIABLE agent_plugins_enabled = [TRUE / FALSE] | Set whether the agent plugins are enabled, the default value is false | SET VARIABLE agent_plugins_enabled = TRUE | +| SHOW ALL VARIABLES | Query proxy all properties configuration | SHOW ALL VARIABLES | +| SHOW VARIABLE variable_name | Query proxy variable, name is split by underscore | SHOW VARIABLE sql_show | +| PREVIEW SQL | Preview the actual SQLs | PREVIEW SELECT * FROM t_order | +| PARSE SQL | Parse SQL and output abstract syntax tree | PARSE SELECT * FROM t_order | +| REFRESH TABLE METADATA | Refresh the metadata of all tables | REFRESH TABLE METADATA | +| REFRESH TABLE METADATA [tableName / tableName FROM RESOURCE resourceName] | Refresh the metadata of a table | REFRESH TABLE METADATA t_order FROM resource ds_1 | +| SHOW TABLE METADATA tableName [, tableName] ... | Query table metadata | SHOW TABLE METADATA t_order | +| EXPORT DATABASE CONFIG [FROM database_name] [, file="file_path"] | Query / export resources and rule configuration in database | EXPORT DATABASE CONFIG FROM readwrite_splitting_db | +| SHOW RULES USED RESOURCE resourceName [from database] | Query the rules for using the specified resource in database | SHOW RULES USED RESOURCE ds_0 FROM databaseName | ## Notice diff --git a/docs/document/content/user-manual/shardingsphere-proxy/distsql/syntax/rql/rule-query/db-discovery.cn.md b/docs/document/content/user-manual/shardingsphere-proxy/distsql/syntax/rql/rule-query/db-discovery.cn.md index bce2a811828..86be4b37763 100644 --- a/docs/document/content/user-manual/shardingsphere-proxy/distsql/syntax/rql/rule-query/db-discovery.cn.md +++ b/docs/document/content/user-manual/shardingsphere-proxy/distsql/syntax/rql/rule-query/db-discovery.cn.md @@ -18,7 +18,7 @@ SHOW DB_DISCOVERY HEARTBEATS [FROM databaseName] ### DB Discovery Rule | 列 | 说明 | -| ------------------------ | --------------- | +| ------------------------ | -------------- | | group_name | 规则名称 | | data_source_names | 数据源名称列表 | | primary_data_source_name | 主数据源名称 | @@ -28,15 +28,15 @@ SHOW DB_DISCOVERY HEARTBEATS [FROM databaseName] ### DB Discovery Type | 列 | 说明 | -| ------------------------ | ---------------| +| ------------------------ | -------------- | | name | 类型名称 | -| type | 类型种类 | -| props | 类型参数 | +| type | 类型种类 | +| props | 类型参数 | ### DB Discovery Heartbeat | 列 | 说明 | -| ------------------------ | ---------------| +| ------------------------ | -------------- | | name | 心跳名称 | | props | 心跳参数 | diff --git a/docs/document/content/user-manual/shardingsphere-proxy/distsql/syntax/rql/rule-query/db-discovery.en.md b/docs/document/content/user-manual/shardingsphere-proxy/distsql/syntax/rql/rule-query/db-discovery.en.md index d45343cad12..2448d93dc22 100644 --- a/docs/document/content/user-manual/shardingsphere-proxy/distsql/syntax/rql/rule-query/db-discovery.en.md +++ b/docs/document/content/user-manual/shardingsphere-proxy/distsql/syntax/rql/rule-query/db-discovery.en.md @@ -36,7 +36,7 @@ SHOW DB_DISCOVERY HEARTBEATS [FROM databaseName] ### DB Discovery Heartbeat | Column | Description | -| ------------------------ | ----------------------| +| ------------------------ | --------------------- | | name | Heartbeat name | | props | Heartbeat properties | diff --git a/docs/document/content/user-manual/shardingsphere-proxy/distsql/syntax/rql/rule-query/encrypt.cn.md b/docs/document/content/user-manual/shardingsphere-proxy/distsql/syntax/rql/rule-query/encrypt.cn.md index 3e9ac1a386b..b5f4b2c5ffd 100644 --- a/docs/document/content/user-manual/shardingsphere-proxy/distsql/syntax/rql/rule-query/encrypt.cn.md +++ b/docs/document/content/user-manual/shardingsphere-proxy/distsql/syntax/rql/rule-query/encrypt.cn.md @@ -15,14 +15,14 @@ SHOW ENCRYPT TABLE RULE tableName [from databaseName] ## 返回值说明 | 列 | 说明 | -| --------------- | ---------- | +| ------------------------- | ------------------ | | table | 逻辑表名 | | logic_column | 逻辑列名 | | logic_data_type | 逻辑列数据类型 | | cipher_column | 密文列名 | | cipher_data_type | 密文列数据类型 | | plain_column | 明文列名 | -| plain_data_type | 明文列数据类型 | +| plain_data_type | 明文列数据类型 | | assisted_query_column | 辅助查询列名 | | assisted_query_data_type | 辅助查询列数据类型 | | encryptor_type | 加密算法类型 | diff --git a/docs/document/content/user-manual/shardingsphere-proxy/distsql/syntax/rql/rule-query/encrypt.en.md b/docs/document/content/user-manual/shardingsphere-proxy/distsql/syntax/rql/rule-query/encrypt.en.md index f041c23a5f7..d16dc460e5c 100644 --- a/docs/document/content/user-manual/shardingsphere-proxy/distsql/syntax/rql/rule-query/encrypt.en.md +++ b/docs/document/content/user-manual/shardingsphere-proxy/distsql/syntax/rql/rule-query/encrypt.en.md @@ -14,20 +14,20 @@ SHOW ENCRYPT TABLE RULE tableName [from databaseName] ## Return Value Description -| Column | Description | -| --------------- | ------------------------------- | -| table | Logical table name | -| logic_column | Logical column name | -| logic_data_type | Logical column data type | -| cipher_column | Ciphertext column name | -| cipher_data_type | Ciphertext column data type | -| plain_column | Plaintext column name | -| plain_data_type | Plaintext column data type | -| assisted_query_column | Assisted query column name | -| assisted_query_data_type | Assisted query column data type | -| encryptor_type | Encryption algorithm type | -| encryptor_props | Encryption algorithm parameter | -| query_with_cipher_column | Whether to use encrypted column for query | +| Column | Description | +| ------------------------- | ---------------------------------------- | +| table | Logical table name | +| logic_column | Logical column name | +| logic_data_type | Logical column data type | +| cipher_column | Ciphertext column name | +| cipher_data_type | Ciphertext column data type | +| plain_column | Plaintext column name | +| plain_data_type | Plaintext column data type | +| assisted_query_column | Assisted query column name | +| assisted_query_data_type | Assisted query column data type | +| encryptor_type | Encryption algorithm type | +| encryptor_props | Encryption algorithm parameter | +| query_with_cipher_column | Whether to use encrypted column for query | ## Example diff --git a/docs/document/content/user-manual/shardingsphere-proxy/distsql/syntax/rql/rule-query/shadow.cn.md b/docs/document/content/user-manual/shardingsphere-proxy/distsql/syntax/rql/rule-query/shadow.cn.md index 0c519b0a11a..f36c7afa213 100644 --- a/docs/document/content/user-manual/shardingsphere-proxy/distsql/syntax/rql/rule-query/shadow.cn.md +++ b/docs/document/content/user-manual/shardingsphere-proxy/distsql/syntax/rql/rule-query/shadow.cn.md @@ -32,25 +32,25 @@ shadowRule: ### Shadow Table Rule -| 列 | 说明 | -| ----------------------| ---------------| -| shadow_table | 影子表 | -| shadow_algorithm_name | 影子算法名称 | +| 列 | 说明 | +| --------------------- | ---------- | +| shadow_table | 影子表 | +| shadow_algorithm_name | 影子算法名称 | ### Shadow Algorithms -| 列 | 说明 | -| ------------------- | ------------ | -| shadow_algorithm_name | 影子算法名称 | -| type | 算法类型 | -| props | 算法参数 | -| is_default | 是否默认 | +| 列 | 说明 | +| ------------------- | ---------- | +| shadow_algorithm_name | 影子算法名称 | +| type | 算法类型 | +| props | 算法参数 | +| is_default | 是否默认 | ### Shadow Rule status -| 列 | 说明 | -| ------------------- | ------------ | -| status | 是否启用 | +| 列 | 说明 | +| ------------------- | ------- | +| status | 是否启用 | ## 示例 diff --git a/docs/document/content/user-manual/shardingsphere-proxy/distsql/syntax/rql/rule-query/shadow.en.md b/docs/document/content/user-manual/shardingsphere-proxy/distsql/syntax/rql/rule-query/shadow.en.md index 90a63c4bc52..f73d5325908 100644 --- a/docs/document/content/user-manual/shardingsphere-proxy/distsql/syntax/rql/rule-query/shadow.en.md +++ b/docs/document/content/user-manual/shardingsphere-proxy/distsql/syntax/rql/rule-query/shadow.en.md @@ -24,7 +24,7 @@ shadowRule: ### Shadow Rule | Column | Description | -| ------------ | ----------- | +| ------------ | --------------- | | rule_name | Rule name | | source_name | Source database | | shadow_name | Shadow database | @@ -48,9 +48,9 @@ shadowRule: ### Shadow Rule status -| Column | Description | -| ------------------- | ------------ | -| status | Enable | +| Column | Description | +| --------------------- | ----------- | +| status | Enable | ## Example diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/advanced/ParseDistSQLHandler.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/advanced/ParseDistSQLHandler.java index 23c390d197b..325c384b177 100644 --- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/advanced/ParseDistSQLHandler.java +++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/advanced/ParseDistSQLHandler.java @@ -51,15 +51,18 @@ public final class ParseDistSQLHandler extends QueryableRALBackendHandler<ParseS @Override protected Collection<List<Object>> getRows(final ContextManager contextManager) { + SQLStatement parsedSqlStatement = parseSQL(contextManager); + return Collections.singleton(Arrays.asList(parsedSqlStatement.getClass().getSimpleName(), new Gson().toJson(parsedSqlStatement))); + } + + private SQLStatement parseSQL(final ContextManager contextManager) { Optional<SQLParserRule> sqlParserRule = contextManager.getMetaDataContexts().getMetaData().getGlobalRuleMetaData().findSingleRule(SQLParserRule.class); Preconditions.checkState(sqlParserRule.isPresent()); - SQLStatement parsedSqlStatement; try { - parsedSqlStatement = sqlParserRule.get().getSQLParserEngine(getStorageType().getType()).parse(getSqlStatement().getSql(), false); + return sqlParserRule.get().getSQLParserEngine(getStorageType().getType()).parse(getSqlStatement().getSql(), false); } catch (final SQLParsingException ex) { throw new SQLParsingException("You have a syntax error in your parsed statement"); } - return Collections.singleton(Arrays.asList(parsedSqlStatement.getClass().getSimpleName(), new Gson().toJson(parsedSqlStatement))); } private DatabaseType getStorageType() {