Skip to content

Commit

Permalink
Redefine EncryptSQLException's vendor codes (apache#20923)
Browse files Browse the repository at this point in the history
  • Loading branch information
terrymanu authored Sep 11, 2022
1 parent 3fab394 commit 9dc6872
Show file tree
Hide file tree
Showing 24 changed files with 46 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -155,12 +155,12 @@ SQL 错误码以标准的 SQL State,Vendor Code 和详细错误信息提供,

| SQL State | Vendor Code | 错误信息 |
| --------- | ----------- | ------ |
| HY004 | 27000 | Encrypt algorithm \`%s\` initialize failed, reason is: %s |
| 0A000 | 27001 | The SQL clause \`%s\` is unsupported in encrypt rule |
| 44000 | 27000 | Can not find logic encrypt column by \`%s\` |
| 44000 | 27001 | Fail to find encrypt column \`%s\` from table \`%s\` |
| 44000 | 27002 | Altered column \`%s\` must use same encrypt algorithm with previous column \`%s\` in table \`%s\` |
| 42000 | 27003 | Insert value of index \`%s\` can not support for encrypt |
| 44000 | 27004 | Can not find logic encrypt column by \`%s\` |
| 44000 | 27005 | Fail to find encrypt column \`%s\` from table \`%s\` |
| 42000 | 27020 | Insert value of index \`%s\` can not support for encrypt |
| 0A000 | 27021 | The SQL clause \`%s\` is unsupported in encrypt rule |
| HY004 | 27080 | Encrypt algorithm \`%s\` initialization failed, reason is: %s |

### 影子库

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,12 +155,12 @@ SQL error codes provide by standard `SQL State`, `Vendor Code` and `Reason`, whi

| SQL State | Vendor Code | Reason |
| --------- | ----------- | ------ |
| HY004 | 27000 | Encrypt algorithm \`%s\` initialize failed, reason is: %s |
| 0A000 | 27001 | The SQL clause \`%s\` is unsupported in encrypt rule |
| 44000 | 27000 | Can not find logic encrypt column by \`%s\` |
| 44000 | 27001 | Fail to find encrypt column \`%s\` from table \`%s\` |
| 44000 | 27002 | Altered column \`%s\` must use same encrypt algorithm with previous column \`%s\` in table \`%s\` |
| 42000 | 27003 | Insert value of index \`%s\` can not support for encrypt |
| 44000 | 27004 | Can not find logic encrypt column by \`%s\` |
| 44000 | 27005 | Fail to find encrypt column \`%s\` from table \`%s\` |
| 42000 | 27020 | Insert value of index \`%s\` can not support for encrypt |
| 0A000 | 27021 | The SQL clause \`%s\` is unsupported in encrypt rule |
| HY004 | 27080 | Encrypt algorithm \`%s\` initialization failed, reason is: %s |

### Shadow Database

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

import lombok.Getter;
import org.apache.commons.codec.binary.Base64;
import org.apache.shardingsphere.encrypt.exception.EncryptAlgorithmInitializationException;
import org.apache.shardingsphere.encrypt.exception.algorithm.EncryptAlgorithmInitializationException;
import org.apache.shardingsphere.encrypt.spi.EncryptAlgorithm;
import org.apache.shardingsphere.encrypt.spi.context.EncryptContext;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@
* limitations under the License.
*/

package org.apache.shardingsphere.encrypt.exception;
package org.apache.shardingsphere.encrypt.exception.algorithm;

import org.apache.shardingsphere.encrypt.exception.EncryptSQLException;
import org.apache.shardingsphere.infra.util.exception.external.sql.sqlstate.XOpenSQLState;

/**
Expand All @@ -27,6 +28,6 @@ public final class EncryptAlgorithmInitializationException extends EncryptSQLExc
private static final long serialVersionUID = -2004166948563207100L;

public EncryptAlgorithmInitializationException(final String encryptorType, final String reason) {
super(XOpenSQLState.GENERAL_ERROR, 0, "Encrypt algorithm `%s` initialization failed, reason is: %s", encryptorType, reason);
super(XOpenSQLState.GENERAL_ERROR, 80, "Encrypt algorithm `%s` initialization failed, reason is: %s", encryptorType, reason);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@
* limitations under the License.
*/

package org.apache.shardingsphere.encrypt.exception;
package org.apache.shardingsphere.encrypt.exception.metadata;

import org.apache.shardingsphere.encrypt.exception.EncryptSQLException;
import org.apache.shardingsphere.infra.util.exception.external.sql.sqlstate.XOpenSQLState;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@
* limitations under the License.
*/

package org.apache.shardingsphere.encrypt.exception;
package org.apache.shardingsphere.encrypt.exception.metadata;

import org.apache.shardingsphere.encrypt.exception.EncryptSQLException;
import org.apache.shardingsphere.infra.util.exception.external.sql.sqlstate.XOpenSQLState;

/**
Expand All @@ -27,6 +28,6 @@ public final class EncryptColumnNotFoundException extends EncryptSQLException {
private static final long serialVersionUID = -8481487069938556675L;

public EncryptColumnNotFoundException(final String tableName, final String columnName) {
super(XOpenSQLState.CHECK_OPTION_VIOLATION, 5, "Fail to find encrypt column `%s` from table `%s`", columnName, tableName);
super(XOpenSQLState.CHECK_OPTION_VIOLATION, 1, "Fail to find encrypt column `%s` from table `%s`", columnName, tableName);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@
* limitations under the License.
*/

package org.apache.shardingsphere.encrypt.exception;
package org.apache.shardingsphere.encrypt.exception.metadata;

import org.apache.shardingsphere.encrypt.exception.EncryptSQLException;
import org.apache.shardingsphere.infra.util.exception.external.sql.sqlstate.XOpenSQLState;

/**
Expand All @@ -27,6 +28,6 @@ public final class EncryptLogicColumnNotFoundException extends EncryptSQLExcepti
private static final long serialVersionUID = 3934531389314348880L;

public EncryptLogicColumnNotFoundException(final String actualColumn) {
super(XOpenSQLState.CHECK_OPTION_VIOLATION, 4, "Can not find logic encrypt column by `%s`", actualColumn);
super(XOpenSQLState.CHECK_OPTION_VIOLATION, 0, "Can not find logic encrypt column by `%s`", actualColumn);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@
* limitations under the License.
*/

package org.apache.shardingsphere.encrypt.exception;
package org.apache.shardingsphere.encrypt.exception.syntax;

import org.apache.shardingsphere.encrypt.exception.EncryptSQLException;
import org.apache.shardingsphere.infra.util.exception.external.sql.sqlstate.XOpenSQLState;

/**
Expand All @@ -27,6 +28,6 @@ public final class UnsupportedEncryptInsertValueException extends EncryptSQLExce
private static final long serialVersionUID = 5004882561157380582L;

public UnsupportedEncryptInsertValueException(final int columnIndex) {
super(XOpenSQLState.SYNTAX_ERROR, 3, "Insert value of index `%s` can not support for encrypt", String.valueOf(columnIndex));
super(XOpenSQLState.SYNTAX_ERROR, 20, "Insert value of index `%s` can not support for encrypt", String.valueOf(columnIndex));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@
* limitations under the License.
*/

package org.apache.shardingsphere.encrypt.exception;
package org.apache.shardingsphere.encrypt.exception.syntax;

import org.apache.shardingsphere.encrypt.exception.EncryptSQLException;
import org.apache.shardingsphere.infra.util.exception.external.sql.sqlstate.XOpenSQLState;

/**
Expand All @@ -27,6 +28,6 @@ public final class UnsupportedEncryptSQLException extends EncryptSQLException {
private static final long serialVersionUID = 8391663664617661217L;

public UnsupportedEncryptSQLException(final String sqlClause) {
super(XOpenSQLState.SYNTAX_ERROR, 1, "The SQL clause `%s` is unsupported in encrypt rule", sqlClause);
super(XOpenSQLState.SYNTAX_ERROR, 21, "The SQL clause `%s` is unsupported in encrypt rule", sqlClause);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
package org.apache.shardingsphere.encrypt.rewrite.condition;

import lombok.RequiredArgsConstructor;
import org.apache.shardingsphere.encrypt.exception.UnsupportedEncryptSQLException;
import org.apache.shardingsphere.encrypt.exception.syntax.UnsupportedEncryptSQLException;
import org.apache.shardingsphere.encrypt.rewrite.condition.impl.EncryptEqualCondition;
import org.apache.shardingsphere.encrypt.rewrite.condition.impl.EncryptInCondition;
import org.apache.shardingsphere.encrypt.rule.EncryptColumn;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import com.google.common.base.Preconditions;
import lombok.Setter;
import org.apache.shardingsphere.encrypt.context.EncryptContextBuilder;
import org.apache.shardingsphere.encrypt.exception.UnsupportedEncryptInsertValueException;
import org.apache.shardingsphere.encrypt.exception.syntax.UnsupportedEncryptInsertValueException;
import org.apache.shardingsphere.encrypt.rewrite.aware.DatabaseNameAware;
import org.apache.shardingsphere.encrypt.rule.EncryptRule;
import org.apache.shardingsphere.encrypt.rule.aware.EncryptRuleAware;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
package org.apache.shardingsphere.encrypt.rewrite.token.generator;

import lombok.Setter;
import org.apache.shardingsphere.encrypt.exception.EncryptColumnAlterException;
import org.apache.shardingsphere.encrypt.exception.EncryptColumnNotFoundException;
import org.apache.shardingsphere.encrypt.exception.metadata.EncryptColumnAlterException;
import org.apache.shardingsphere.encrypt.exception.metadata.EncryptColumnNotFoundException;
import org.apache.shardingsphere.encrypt.rewrite.token.pojo.EncryptAlterTableToken;
import org.apache.shardingsphere.encrypt.rule.EncryptColumn;
import org.apache.shardingsphere.encrypt.rule.EncryptRule;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

import com.google.common.base.Preconditions;
import lombok.Setter;
import org.apache.shardingsphere.encrypt.exception.UnsupportedEncryptSQLException;
import org.apache.shardingsphere.encrypt.exception.syntax.UnsupportedEncryptSQLException;
import org.apache.shardingsphere.encrypt.rewrite.aware.DatabaseNameAware;
import org.apache.shardingsphere.encrypt.rewrite.token.pojo.EncryptAssignmentToken;
import org.apache.shardingsphere.encrypt.rewrite.token.pojo.EncryptFunctionAssignmentToken;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

import lombok.Setter;
import org.apache.shardingsphere.encrypt.context.EncryptContextBuilder;
import org.apache.shardingsphere.encrypt.exception.UnsupportedEncryptInsertValueException;
import org.apache.shardingsphere.encrypt.exception.syntax.UnsupportedEncryptInsertValueException;
import org.apache.shardingsphere.encrypt.rewrite.aware.DatabaseNameAware;
import org.apache.shardingsphere.encrypt.rewrite.token.pojo.EncryptInsertValuesToken;
import org.apache.shardingsphere.encrypt.rule.EncryptRule;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

import org.apache.shardingsphere.encrypt.api.config.rule.EncryptColumnRuleConfiguration;
import org.apache.shardingsphere.encrypt.api.config.rule.EncryptTableRuleConfiguration;
import org.apache.shardingsphere.encrypt.exception.EncryptLogicColumnNotFoundException;
import org.apache.shardingsphere.encrypt.exception.metadata.EncryptLogicColumnNotFoundException;

import java.util.Collection;
import java.util.HashMap;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

package org.apache.shardingsphere.encrypt.algorithm;

import org.apache.shardingsphere.encrypt.exception.EncryptAlgorithmInitializationException;
import org.apache.shardingsphere.encrypt.exception.algorithm.EncryptAlgorithmInitializationException;
import org.apache.shardingsphere.encrypt.factory.EncryptAlgorithmFactory;
import org.apache.shardingsphere.encrypt.spi.EncryptAlgorithm;
import org.apache.shardingsphere.encrypt.spi.context.EncryptContext;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

import org.apache.shardingsphere.encrypt.api.config.rule.EncryptColumnRuleConfiguration;
import org.apache.shardingsphere.encrypt.api.config.rule.EncryptTableRuleConfiguration;
import org.apache.shardingsphere.encrypt.exception.EncryptLogicColumnNotFoundException;
import org.apache.shardingsphere.encrypt.exception.metadata.EncryptLogicColumnNotFoundException;
import org.junit.Before;
import org.junit.Test;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

import lombok.AccessLevel;
import lombok.NoArgsConstructor;
import org.apache.shardingsphere.shadow.exception.UnsupportedShadowColumnTypeException;
import org.apache.shardingsphere.shadow.exception.data.UnsupportedShadowColumnTypeException;

import java.util.Date;
import java.util.HashSet;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@
* limitations under the License.
*/

package org.apache.shardingsphere.shadow.exception;
package org.apache.shardingsphere.shadow.exception.data;

import org.apache.shardingsphere.infra.util.exception.external.sql.sqlstate.XOpenSQLState;
import org.apache.shardingsphere.shadow.exception.ShadowSQLException;

/**
* Unsupported shadow column type exception.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@
* limitations under the License.
*/

package org.apache.shardingsphere.shadow.exception;
package org.apache.shardingsphere.shadow.exception.syntax;

import org.apache.shardingsphere.infra.util.exception.external.sql.sqlstate.XOpenSQLState;
import org.apache.shardingsphere.shadow.exception.ShadowSQLException;

/**
* Unsupported shadow insert value exception.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import org.apache.shardingsphere.infra.binder.statement.dml.InsertStatementContext;
import org.apache.shardingsphere.shadow.api.shadow.ShadowOperationType;
import org.apache.shardingsphere.shadow.condition.ShadowColumnCondition;
import org.apache.shardingsphere.shadow.exception.UnsupportedShadowInsertValueException;
import org.apache.shardingsphere.shadow.exception.syntax.UnsupportedShadowInsertValueException;
import org.apache.shardingsphere.sql.parser.sql.common.segment.generic.table.SimpleTableSegment;

import java.util.Collection;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
package org.apache.shardingsphere.shadow.algorithm.shadow.column;

import org.apache.shardingsphere.infra.config.algorithm.AlgorithmConfiguration;
import org.apache.shardingsphere.shadow.exception.UnsupportedShadowColumnTypeException;
import org.apache.shardingsphere.shadow.exception.data.UnsupportedShadowColumnTypeException;
import org.apache.shardingsphere.shadow.factory.ShadowAlgorithmFactory;
import org.junit.Test;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
package org.apache.shardingsphere.shadow.algorithm.shadow.column;

import org.apache.shardingsphere.infra.config.algorithm.AlgorithmConfiguration;
import org.apache.shardingsphere.shadow.exception.UnsupportedShadowColumnTypeException;
import org.apache.shardingsphere.shadow.exception.data.UnsupportedShadowColumnTypeException;
import org.apache.shardingsphere.shadow.factory.ShadowAlgorithmFactory;
import org.junit.Test;

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

package org.apache.shardingsphere.shadow.algorithm.shadow.validator;

import org.apache.shardingsphere.shadow.exception.UnsupportedShadowColumnTypeException;
import org.apache.shardingsphere.shadow.exception.data.UnsupportedShadowColumnTypeException;
import org.junit.Test;

import java.util.Date;
Expand Down

0 comments on commit 9dc6872

Please sign in to comment.