forked from apache/shardingsphere
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'apache:master' into master
- Loading branch information
Showing
76 changed files
with
1,466 additions
and
346 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
...ent/user-manual/shardingsphere-proxy/distsql/syntax/ral/lock-cluster-with.cn.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
+++ | ||
title = "LOCK CLUSTER WITH" | ||
weight = 16 | ||
+++ | ||
|
||
### 描述 | ||
|
||
`LOCK CLUSTER WITH` 语法用于向 `CLUSTER` 施加特定算法的锁。 | ||
|
||
### 语法 | ||
|
||
{{< tabs >}} | ||
{{% tab name="语法" %}} | ||
|
||
```sql | ||
LockClusterWith ::= | ||
'LOCK' 'CLUSTER' 'WITH' lockStrategy ('TIMEOUT' timeoutMillis)? | ||
|
||
timeoutmillis ::= | ||
long | ||
``` | ||
|
||
{{% /tab %}} | ||
{{% tab name="铁路图" %}} | ||
<iframe frameborder="0" name="diagram" id="diagram" width="100%" height="100%"></iframe> | ||
{{% /tab %}} | ||
{{< /tabs >}} | ||
|
||
### 补充说明 | ||
|
||
- 当 `CLUSTER` 已经处于被锁状态时,无法重复加锁,否则会抛出异常。 | ||
- `lockStrategy` 当前支持两种锁策略,分别是排他锁 `WRITE` 与读写锁 `READ_WRITE`。 | ||
- `timeoutMillis` 用于表明尝试加锁的超时时间,其单位为毫秒,未指定时,默认为 3000 毫秒。 | ||
|
||
### 示例 | ||
|
||
- 采用排他锁锁定 `CLUSTER` ,不设置超时时间 | ||
|
||
```sql | ||
LOCK CLUSTER WITH WRITE; | ||
``` | ||
|
||
- 采用读写锁锁定 `CLUSTER` ,并设置超时时间为 2000 毫秒 | ||
|
||
```sql | ||
LOCK CLUSTER WITH READ_WRITE TIMEOUT 2000; | ||
``` | ||
|
||
### 保留字 | ||
|
||
`LOCK`、`CLUSTER`、`WITH` | ||
|
||
### 相关链接 | ||
|
||
- [保留字](/cn/user-manual/shardingsphere-proxy/distsql/syntax/reserved-word/) |
54 changes: 54 additions & 0 deletions
54
...ent/user-manual/shardingsphere-proxy/distsql/syntax/ral/lock-cluster-with.en.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
+++ | ||
title = "LOCK CLUSTER WITH" | ||
weight = 16 | ||
+++ | ||
|
||
### Description | ||
|
||
The `LOCK CLUSTER WITH` syntax is utilized to apply a lock with a specific algorithm to the `CLUSTER`. | ||
|
||
### Syntax | ||
|
||
{{< tabs >}} | ||
{{% tab name="Grammar" %}} | ||
|
||
```sql | ||
LockClusterWith ::= | ||
'LOCK' 'CLUSTER' 'WITH' lockStrategy ('TIMEOUT' timeoutMillis)? | ||
|
||
timeoutmillis ::= | ||
long | ||
``` | ||
|
||
{{% /tab %}} | ||
{{% tab name="Railroad diagram" %}} | ||
|
||
<iframe frameborder="0" name="diagram" id="diagram" width="100%" height="100%"></iframe>{{% /tab %}}{{< /tabs >}} | ||
|
||
### Supplement | ||
|
||
- When the `CLUSTER` is already locked, it is impossible to re-lock it, otherwise an exception will be thrown. | ||
- Currently, the `lockStrategy` supports two lock strategies, namely the exclusive lock `WRITE` and the read-write lock `READ_WRITE` . | ||
- The `timeoutMillis` is used to indicate the timeout period for attempting to acquire the lock, with the unit being milliseconds. When not specified, the default value is 3,000 milliseconds. | ||
|
||
### Example | ||
|
||
- Lock the `CLUSTER` with an exclusive lock without setting the timeout. | ||
- | ||
```sql | ||
LOCK CLUSTER WITH WRITE; | ||
``` | ||
|
||
- Lock the CLUSTER with a read-write lock and set the timeout to 2000 milliseconds. | ||
- | ||
```sql | ||
LOCK CLUSTER WITH READ_WRITE TIMEOUT 2000; | ||
``` | ||
|
||
### Reserved words | ||
|
||
`LOCK`,`CLUSTER`,`WITH` | ||
|
||
### Related links | ||
|
||
- [Reserved word](/en/user-manual/shardingsphere-proxy/distsql/syntax/reserved-word/) |
54 changes: 54 additions & 0 deletions
54
...ontent/user-manual/shardingsphere-proxy/distsql/syntax/ral/unlock-cluster.cn.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
+++ | ||
title = "UNLOCK CLUSTER" | ||
weight = 17 | ||
+++ | ||
|
||
### 描述 | ||
|
||
`UNLOCK CLUSTER` 语法用于解除通过 `LOCK CLUSTER WITH` 语句施加在 `CLUSTER` 上的锁。 | ||
|
||
### 语法 | ||
|
||
{{< tabs >}} | ||
{{% tab name="语法" %}} | ||
|
||
```sql | ||
UnlockCluster ::= | ||
'UNLOCK' 'CLUSTER' ('TIMEOUT' timeoutMillis)? | ||
|
||
timeoutmillis ::= | ||
long | ||
``` | ||
|
||
{{% /tab %}} | ||
{{% tab name="铁路图" %}} | ||
<iframe frameborder="0" name="diagram" id="diagram" width="100%" height="100%"></iframe> | ||
{{% /tab %}} | ||
{{< /tabs >}} | ||
|
||
### 补充说明 | ||
|
||
- 当 `CLUSTER` 不处于被锁状态时,无法解除锁,否则会抛出异常。 | ||
- `timeoutMillis` 表明尝试解锁的超时时间,其单位为毫秒,未指定时,默认为 3000 毫秒。 | ||
|
||
### 示例 | ||
|
||
- 解锁 `CLUSTER` ,不设置超时时间。 | ||
|
||
```sql | ||
UNLOCK CLUSTER; | ||
``` | ||
|
||
- 解锁 `CLUSTER` ,并设置超时时间为 2000 毫秒。 | ||
|
||
```sql | ||
UNLOCK CLUSTER TIMEOUT 2000; | ||
``` | ||
|
||
### 保留字 | ||
|
||
`UNLOCK`、`CLUSTER` | ||
|
||
### 相关链接 | ||
|
||
- [保留字](/cn/user-manual/shardingsphere-proxy/distsql/syntax/reserved-word/) |
53 changes: 53 additions & 0 deletions
53
...ontent/user-manual/shardingsphere-proxy/distsql/syntax/ral/unlock-cluster.en.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
+++ | ||
title = "UNLOCK CLUSTER" | ||
weight = 17 | ||
+++ | ||
|
||
### Description | ||
|
||
The `UNLOCK CLUSTER` syntax is used to release the lock applied to the `CLUSTER` by the `LOCK CLUSTER WITH` statement. | ||
|
||
### Syntax | ||
|
||
{{< tabs >}} | ||
{{% tab name="Grammar" %}} | ||
|
||
```sql | ||
UnlockCluster ::= | ||
'UNLOCK' 'CLUSTER' ('TIMEOUT' timeoutMillis)? | ||
|
||
timeoutmillis ::= | ||
long | ||
``` | ||
|
||
{{% /tab %}} | ||
{{% tab name="Railroad diagram" %}} | ||
|
||
<iframe frameborder="0" name="diagram" id="diagram" width="100%" height="100%"></iframe>{{% /tab %}}{{< /tabs >}} | ||
|
||
### Supplement | ||
|
||
- When the `CLUSTER` is not in a locked state, it is impossible to release the lock; otherwise, an exception will be thrown. | ||
- `timeoutMillis` is used to indicate the timeout duration for attempting to unlock, with the unit being milliseconds. When not specified, the default value is 3,000 milliseconds. | ||
|
||
### Example | ||
|
||
- Unlock the `CLUSTER` without setting a timeout. | ||
- | ||
```sql | ||
UNLOCK CLUSTER; | ||
``` | ||
|
||
- Unlock the `CLUSTER` and set the timeout to 2000 milliseconds. | ||
|
||
```sql | ||
UNLOCK CLUSTER TIMEOUT 2000; | ||
``` | ||
|
||
### Reserved words | ||
|
||
`UNLOCK`,`CLUSTER` | ||
|
||
### Related links | ||
|
||
- [Reserved word](/en/user-manual/shardingsphere-proxy/distsql/syntax/reserved-word/) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
63 changes: 63 additions & 0 deletions
63
...ache/shardingsphere/encrypt/checker/sql/combine/EncryptCombineClauseSupportedChecker.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.apache.shardingsphere.encrypt.checker.sql.combine; | ||
|
||
import org.apache.shardingsphere.encrypt.exception.syntax.UnsupportedEncryptSQLException; | ||
import org.apache.shardingsphere.encrypt.rule.EncryptRule; | ||
import org.apache.shardingsphere.infra.annotation.HighFrequencyInvocation; | ||
import org.apache.shardingsphere.infra.binder.context.extractor.SQLStatementContextExtractor; | ||
import org.apache.shardingsphere.infra.binder.context.statement.SQLStatementContext; | ||
import org.apache.shardingsphere.infra.binder.context.statement.dml.SelectStatementContext; | ||
import org.apache.shardingsphere.infra.checker.SupportedSQLChecker; | ||
import org.apache.shardingsphere.infra.exception.core.ShardingSpherePreconditions; | ||
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase; | ||
import org.apache.shardingsphere.infra.metadata.database.schema.model.ShardingSphereSchema; | ||
|
||
import java.util.Collection; | ||
|
||
/** | ||
* Combine clause supported checker for encrypt. | ||
*/ | ||
@HighFrequencyInvocation | ||
public final class EncryptCombineClauseSupportedChecker implements SupportedSQLChecker<SQLStatementContext, EncryptRule> { | ||
|
||
@Override | ||
public boolean isCheck(final SQLStatementContext sqlStatementContext) { | ||
if (isContainsCombine(sqlStatementContext)) { | ||
return true; | ||
} | ||
for (SelectStatementContext each : SQLStatementContextExtractor.getAllSubqueryContexts(sqlStatementContext)) { | ||
if (isContainsCombine(each)) { | ||
return true; | ||
} | ||
} | ||
return false; | ||
} | ||
|
||
private static boolean isContainsCombine(final SQLStatementContext sqlStatementContext) { | ||
return sqlStatementContext instanceof SelectStatementContext && ((SelectStatementContext) sqlStatementContext).isContainsCombine(); | ||
} | ||
|
||
@Override | ||
public void check(final EncryptRule rule, final ShardingSphereDatabase database, final ShardingSphereSchema currentSchema, final SQLStatementContext sqlStatementContext) { | ||
Collection<String> tableNames = SQLStatementContextExtractor.getTableNames(database, sqlStatementContext); | ||
for (String each : tableNames) { | ||
ShardingSpherePreconditions.checkState(!rule.findEncryptTable(each).isPresent(), () -> new UnsupportedEncryptSQLException("COMBINE")); | ||
} | ||
} | ||
} |
51 changes: 51 additions & 0 deletions
51
...apache/shardingsphere/encrypt/checker/sql/insert/EncryptInsertSelectSupportedChecker.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.apache.shardingsphere.encrypt.checker.sql.insert; | ||
|
||
import org.apache.shardingsphere.encrypt.exception.syntax.UnsupportedEncryptSQLException; | ||
import org.apache.shardingsphere.encrypt.rule.EncryptRule; | ||
import org.apache.shardingsphere.infra.annotation.HighFrequencyInvocation; | ||
import org.apache.shardingsphere.infra.binder.context.extractor.SQLStatementContextExtractor; | ||
import org.apache.shardingsphere.infra.binder.context.statement.SQLStatementContext; | ||
import org.apache.shardingsphere.infra.binder.context.statement.dml.InsertStatementContext; | ||
import org.apache.shardingsphere.infra.checker.SupportedSQLChecker; | ||
import org.apache.shardingsphere.infra.exception.core.ShardingSpherePreconditions; | ||
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase; | ||
import org.apache.shardingsphere.infra.metadata.database.schema.model.ShardingSphereSchema; | ||
|
||
import java.util.Collection; | ||
|
||
/** | ||
* Insert select supported checker for encrypt. | ||
*/ | ||
@HighFrequencyInvocation | ||
public final class EncryptInsertSelectSupportedChecker implements SupportedSQLChecker<InsertStatementContext, EncryptRule> { | ||
|
||
@Override | ||
public boolean isCheck(final SQLStatementContext sqlStatementContext) { | ||
return sqlStatementContext instanceof InsertStatementContext && ((InsertStatementContext) sqlStatementContext).getSqlStatement().getInsertSelect().isPresent(); | ||
} | ||
|
||
@Override | ||
public void check(final EncryptRule rule, final ShardingSphereDatabase database, final ShardingSphereSchema currentSchema, final InsertStatementContext sqlStatementContext) { | ||
Collection<String> tableNames = SQLStatementContextExtractor.getTableNames(database, sqlStatementContext); | ||
for (String each : tableNames) { | ||
ShardingSpherePreconditions.checkState(!rule.findEncryptTable(each).isPresent(), () -> new UnsupportedEncryptSQLException("INSERT ... SELECT ...")); | ||
} | ||
} | ||
} |
Oops, something went wrong.