Skip to content

Commit

Permalink
Merge branch 'apache:master' into graalvm-native-image
Browse files Browse the repository at this point in the history
  • Loading branch information
linghengqian authored Sep 22, 2022
2 parents ee50250 + b0cb897 commit dff6b28
Show file tree
Hide file tree
Showing 321 changed files with 3,090 additions and 1,887 deletions.
30 changes: 30 additions & 0 deletions docs/document/content/user-manual/error-code/sql-error-code.cn.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,12 @@ SQL 错误码以标准的 SQL State,Vendor Code 和详细错误信息提供,
| 44000 | 18001 | Created process configuration already existed |
| 44000 | 18002 | Altered process configuration does not exist |
| HY000 | 18020 | Failed to get DDL for table \`%s\` |
| 42S01 | 18030 | Duplicate resource names \`%s\` |
| 42S02 | 18031 | Resource names \`%s\` do not exist |
| HY000 | 18050 | Before data record is \`%s\`, after data record is \`%s\` |
| 08000 | 18051 | Data check table \`%s\` failed |
| 0A000 | 18052 | Unsupported pipeline database type \`%s\` |
| 0A000 | 18053 | Unsupported CRC32 data consistency calculate algorithm with database type \`%s\` |
| HY000 | 18080 | Can not find pipeline job \`%s\` |
| HY000 | 18081 | Job has already started |
| HY000 | 18082 | Sharding count of job \`%s\` is 0 |
Expand All @@ -110,6 +114,26 @@ SQL 错误码以标准的 SQL State,Vendor Code 和详细错误信息提供,
| HY000 | 18093 | Can not poll event because of binlog sync channel already closed |
| HY000 | 18094 | Task \`%s\` execute failed |

### DistSQL

| SQL State | Vendor Code | 错误信息 |
| --------- | ----------- | ------ |
| 44000 | 19000 | Can not process invalid resources, error message is: %s |
| 44000 | 19001 | Resources \`%s\` do not exist in database \`%s\` |
| 44000 | 19002 | There is no resource in the database \`%s\` |
| 44000 | 19003 | Resource \`%s\` is still used by \`%s\` |
| 44000 | 19004 | Duplicate resource names \`%s\` |
| 44000 | 19100 | Invalid \`%s\` rule \`%s\`, error message is: %s |
| 44000 | 19101 | %s rules \`%s\` do not exist in database \`%s\` |
| 44000 | 19102 | %s rules \`%s\` in database \`%s\` are still in used |
| 44000 | 19103 | %s rule \`%s\` has been enabled in database \`%s\` |
| 44000 | 19104 | %s rule \`%s\` has been disabled in database \`%s\` |
| 44000 | 19105 | Duplicate %s rule names \`%s\` in database \`%s\` |
| 44000 | 19150 | Invalid %s algorithm(s) \`%s\` |
| 44000 | 19151 | %s algorithm(s) \`%s\` do not exist in database \`%s\` |
| 44000 | 19152 | %s algorithms \`%s\` in database \`%s\` are still in used |
| 44000 | 19153 | Duplicate %s algorithms \`%s\` in database \`%s\` |

## 功能异常

### 数据分片
Expand Down Expand Up @@ -147,6 +171,12 @@ SQL 错误码以标准的 SQL State,Vendor Code 和详细错误信息提供,
| 44000 | 20082 | Inline sharding algorithms expression \`%s\` and sharding column \`%s\` do not match |
| 44000 | 20090 | Can not find strategy for generate keys with table \`%s\` |

### 读写分离

| SQL State | Vendor Code | 错误信息 |
| --------- | ----------- | ------ |
| HY004 | 20280 | Invalid read database weight \`%s\` |

### 数据库高可用

| SQL State | Vendor Code | 错误信息 |
Expand Down
30 changes: 30 additions & 0 deletions docs/document/content/user-manual/error-code/sql-error-code.en.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,12 @@ SQL error codes provide by standard `SQL State`, `Vendor Code` and `Reason`, whi
| 44000 | 18001 | Created process configuration already existed |
| 44000 | 18002 | Altered process configuration does not exist |
| HY000 | 18020 | Failed to get DDL for table \`%s\` |
| 42S01 | 18030 | Duplicate resource names \`%s\` |
| 42S02 | 18031 | Resource names \`%s\` do not exist |
| HY000 | 18050 | Before data record is \`%s\`, after data record is \`%s\` |
| 08000 | 18051 | Data check table \`%s\` failed |
| 0A000 | 18052 | Unsupported pipeline database type \`%s\` |
| 0A000 | 18053 | Unsupported CRC32 data consistency calculate algorithm with database type \`%s\` |
| HY000 | 18080 | Can not find pipeline job \`%s\` |
| HY000 | 18081 | Job has already started |
| HY000 | 18082 | Sharding count of job \`%s\` is 0 |
Expand All @@ -110,6 +114,26 @@ SQL error codes provide by standard `SQL State`, `Vendor Code` and `Reason`, whi
| HY000 | 18093 | Can not poll event because of binlog sync channel already closed |
| HY000 | 18094 | Task \`%s\` execute failed |

### DistSQL

| SQL State | Vendor Code | Reason |
| --------- | ----------- | ------ |
| 44000 | 19000 | Can not process invalid resources, error message is: %s |
| 44000 | 19001 | Resources \`%s\` do not exist in database \`%s\` |
| 44000 | 19002 | There is no resource in the database \`%s\` |
| 44000 | 19003 | Resource \`%s\` is still used by \`%s\` |
| 44000 | 19004 | Duplicate resource names \`%s\` |
| 44000 | 19100 | Invalid \`%s\` rule \`%s\`, error message is: %s |
| 44000 | 19101 | %s rules \`%s\` do not exist in database \`%s\` |
| 44000 | 19102 | %s rules \`%s\` in database \`%s\` are still in used |
| 44000 | 19103 | %s rule \`%s\` has been enabled in database \`%s\` |
| 44000 | 19104 | %s rule \`%s\` has been disabled in database \`%s\` |
| 44000 | 19105 | Duplicate %s rule names \`%s\` in database \`%s\` |
| 44000 | 19150 | Invalid %s algorithm(s) \`%s\` |
| 44000 | 19151 | %s algorithm(s) \`%s\` do not exist in database \`%s\` |
| 44000 | 19152 | %s algorithms \`%s\` in database \`%s\` are still in used |
| 44000 | 19153 | Duplicate %s algorithms \`%s\` in database \`%s\` |

## Feature Exception

### Data Sharding
Expand Down Expand Up @@ -147,6 +171,12 @@ SQL error codes provide by standard `SQL State`, `Vendor Code` and `Reason`, whi
| 44000 | 20082 | Inline sharding algorithms expression \`%s\` and sharding column \`%s\` do not match |
| 44000 | 20090 | Can not find strategy for generate keys with table \`%s\` |

### Readwrite Splitting

| SQL State | Vendor Code | Reason |
| --------- | ----------- | ------ |
| HY004 | 20280 | Invalid read database weight \`%s\` |

### Database HA

| SQL State | Vendor Code | Reason |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ RAL (Resource & Rule Administration Language) 为 Apache ShardingSphere 的管
|:--------------------------------------------------------------------------|:------------------------------------------------------------------------------------------------------------------|:----------------------------------------------------------|
| SHOW INSTANCE INFO | 查询当前 proxy 的实例信息 | SHOW INSTANCE INFO |
| SHOW MODE INFO | 查询当前 proxy 的 mode 配置 | SHOW MODE INFO |
| 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 |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ RAL (Resource & Rule Administration Language) responsible for hint, circuit brea
|:--------------------------------------------------------------------------|:--------------------------------------------------------------------------------------------------------------------------------------------------------|:--------------------------------------------------------- |
| SHOW INSTANCE INFO | Query the instance information of the proxy | SHOW INSTANCE INFO |
| SHOW MODE INFO | Query the mode configuration of the proxy | SHOW MODE INFO |
| 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 |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

package org.apache.shardingsphere.db.protocol.mysql.constant;

import com.google.common.base.Preconditions;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import org.apache.shardingsphere.db.protocol.binary.BinaryColumnType;
Expand Down Expand Up @@ -142,10 +143,8 @@ public enum MySQLBinaryColumnType implements BinaryColumnType {
* @return column type enum
*/
public static MySQLBinaryColumnType valueOfJDBCType(final int jdbcType) {
if (JDBC_TYPE_AND_COLUMN_TYPE_MAP.containsKey(jdbcType)) {
return JDBC_TYPE_AND_COLUMN_TYPE_MAP.get(jdbcType);
}
throw new IllegalArgumentException(String.format("Cannot find JDBC type '%s' in column type", jdbcType));
Preconditions.checkArgument(JDBC_TYPE_AND_COLUMN_TYPE_MAP.containsKey(jdbcType), "Can not find JDBC type `%s` in column type", jdbcType);
return JDBC_TYPE_AND_COLUMN_TYPE_MAP.get(jdbcType);
}

/**
Expand All @@ -155,9 +154,7 @@ public static MySQLBinaryColumnType valueOfJDBCType(final int jdbcType) {
* @return column type
*/
public static MySQLBinaryColumnType valueOf(final int value) {
if (VALUE_AND_COLUMN_TYPE_MAP.containsKey(value)) {
return VALUE_AND_COLUMN_TYPE_MAP.get(value);
}
throw new IllegalArgumentException(String.format("Cannot find value '%s' in column type", value));
Preconditions.checkArgument(VALUE_AND_COLUMN_TYPE_MAP.containsKey(value), "Can not find value `%s` in column type", value);
return VALUE_AND_COLUMN_TYPE_MAP.get(value);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

package org.apache.shardingsphere.db.protocol.mysql.constant;

import com.google.common.base.Preconditions;
import lombok.Getter;
import lombok.RequiredArgsConstructor;

Expand Down Expand Up @@ -121,9 +122,7 @@ public enum MySQLBinlogEventType {
* @return MySQL binlog event type
*/
public static MySQLBinlogEventType valueOf(final int value) {
if (VALUE_AND_EVENT_TYPE_MAP.containsKey(value)) {
return VALUE_AND_EVENT_TYPE_MAP.get(value);
}
throw new IllegalArgumentException(String.format("Cannot find value '%s' in binlog event type", value));
Preconditions.checkArgument(VALUE_AND_EVENT_TYPE_MAP.containsKey(value), "Can not find value `%s` in binlog event type", value);
return VALUE_AND_EVENT_TYPE_MAP.get(value);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,6 @@ public static MySQLNewParametersBoundFlag valueOf(final int value) {
return each;
}
}
throw new IllegalArgumentException(String.format("Cannot find value '%s' in new parameters bound flag", value));
throw new IllegalArgumentException(String.format("Can not find value `%s` in new parameters bound flag", value));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public Object read(final MySQLPacketPayload payload) throws SQLException {
result.setNanos(payload.readInt4() * 1000);
return result;
default:
throw new IllegalArgumentException(String.format("Wrong length '%d' of MYSQL_TYPE_TIME", length));
throw new IllegalArgumentException(String.format("Wrong length `%d` of MYSQL_TYPE_TIME", length));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public Object read(final MySQLPacketPayload payload) {
result.setNanos(payload.readInt4());
return result;
default:
throw new IllegalArgumentException(String.format("Wrong length '%d' of MYSQL_TYPE_DATE", length));
throw new IllegalArgumentException(String.format("Wrong length `%d` of MYSQL_TYPE_DATE", length));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public static PostgreSQLCommandPacketType valueOf(final int value) {
return each;
}
}
throw new IllegalArgumentException(String.format("Cannot find '%s' in PostgreSQL command packet type", value));
throw new IllegalArgumentException(String.format("Can not find `%s` in PostgreSQL command packet type", value));
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

package org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.extended;

import com.google.common.base.Preconditions;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import org.apache.shardingsphere.db.protocol.binary.BinaryColumnType;
Expand Down Expand Up @@ -183,10 +184,8 @@ public enum PostgreSQLColumnType implements BinaryColumnType {
* @return PostgreSQL column type enum
*/
public static PostgreSQLColumnType valueOfJDBCType(final int jdbcType) {
if (JDBC_TYPE_AND_COLUMN_TYPE_MAP.containsKey(jdbcType)) {
return JDBC_TYPE_AND_COLUMN_TYPE_MAP.get(jdbcType);
}
throw new IllegalArgumentException(String.format("Cannot find JDBC type '%s' in PostgreSQL column type", jdbcType));
Preconditions.checkArgument(JDBC_TYPE_AND_COLUMN_TYPE_MAP.containsKey(jdbcType), "Can not find JDBC type `%s` in PostgreSQL column type", jdbcType);
return JDBC_TYPE_AND_COLUMN_TYPE_MAP.get(jdbcType);
}

/**
Expand All @@ -201,6 +200,6 @@ public static PostgreSQLColumnType valueOf(final int value) {
return each;
}
}
throw new IllegalArgumentException(String.format("Cannot find value '%s' in PostgreSQL column type", value));
throw new IllegalArgumentException(String.format("Can not find value `%s` in PostgreSQL column type", value));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

package org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.extended.bind.protocol;

import com.google.common.base.Preconditions;
import org.apache.shardingsphere.infra.util.exception.ShardingSpherePreconditions;
import org.apache.shardingsphere.infra.util.exception.external.sql.type.generic.UnsupportedSQLOperationException;

Expand Down Expand Up @@ -168,12 +169,8 @@ public String[] decodeStringArray(final byte[] parameterBytes, final boolean isB
* @return decoded parameter value elements
*/
private Collection<String> decodeText(final String value) {
if (value.length() < 2) {
throw new IllegalArgumentException("value length less than 2");
}
if ('{' != value.charAt(0) || '}' != value.charAt(value.length() - 1)) {
throw new IllegalArgumentException("value not start with '{' or not end with '}'");
}
Preconditions.checkArgument(value.length() >= 2, "value length less than 2");
Preconditions.checkArgument('{' == value.charAt(0) && '}' == value.charAt(value.length() - 1), "value not start with '{' or not end with '}'");
String[] elements = value.substring(1, value.length() - 1).split(",");
return Arrays.stream(elements).map(each -> {
if ("NULL".equals(each)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,9 @@ public static Number numeric(final byte[] bytes) {
*/
public static Number numeric(final byte[] bytes, final int pos) {
short sign = readShort2(bytes, pos + 4);
Preconditions.checkArgument(0x0000 == sign || NUMERIC_NEG == sign || NUMERIC_NAN == sign, "invalid sign in \"numeric\" value");
short scale = readShort2(bytes, pos + 6);
validator(sign, scale);
Preconditions.checkArgument((scale & 0x00003FFF) == scale, "invalid scale in \"numeric\" value");
if (NUMERIC_NAN == sign) {
return Double.NaN;
}
Expand Down Expand Up @@ -358,15 +359,6 @@ private static Number initBigDecimal(final byte[] bytes, final int pos, final sh
return new BigDecimal(unscaledBI, scale);
}

private static void validator(final short sign, final short scale) {
if (!(0x0000 == sign || NUMERIC_NEG == sign || NUMERIC_NAN == sign)) {
throw new IllegalArgumentException("invalid sign in \"numeric\" value");
}
if ((scale & 0x00003FFF) != scale) {
throw new IllegalArgumentException("invalid scale in \"numeric\" value");
}
}

private static BigInteger tenPower(final int exponent) {
return BI_TEN_POWERS.length > exponent ? BI_TEN_POWERS[exponent] : BigInteger.TEN.pow(exponent);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,6 @@ public static PostgreSQLMessagePacketType valueOf(final int value) {
return each;
}
}
throw new IllegalArgumentException(String.format("Cannot find '%s' in PostgreSQL identifier tag type", value));
throw new IllegalArgumentException(String.format("Can not find `%s` in PostgreSQL identifier tag type", value));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,6 @@ showSingleTable
: SHOW SINGLE (TABLES | TABLE tableName) (FROM databaseName)?
;

countDatabaseRules
: COUNT DATABASE RULES (FROM databaseName)?
;

showRulesUsedResource
: SHOW RULES USED RESOURCE resourceName (FROM databaseName)?
;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ execute
| unlabelInstance
| countSingleTableRule
| alterInstance
| countDatabaseRules
| prepareDistSQL
| applyDistSQL
| discardDistSQL
Expand Down
Loading

0 comments on commit dff6b28

Please sign in to comment.