Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ SQL 错误码以标准的 SQL State,Vendor Code 和详细错误信息提供,
| HY004 | 10004 | Unsupported conversion data type \`%s\` for value \`%s\` |
| HY004 | 10100 | Can not register driver, reason is: %s |
| 34000 | 10200 | Can not get cursor name from fetch statement |
| HY000 | 10300 | Could not support variable \`%s\` |
| HY004 | 10301 | Invalid value \`%s\` |
| 42000 | 11000 | You have an error in your SQL syntax: %s |
| 42000 | 11001 | configuration error |
| 42000 | 11002 | Resource does not exist |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ SQL error codes provide by standard `SQL State`, `Vendor Code` and `Reason`, whi
| HY004 | 10004 | Unsupported conversion data type \`%s\` for value \`%s\` |
| HY004 | 10100 | Can not register driver, reason is: %s |
| 34000 | 10200 | Can not get cursor name from fetch statement |
| HY000 | 10300 | Could not support variable \`%s\` |
| HY004 | 10301 | Invalid value \`%s\` |
| 42000 | 11000 | You have an error in your SQL syntax: %s |
| 42000 | 11001 | configuration error |
| 42000 | 11002 | Resource does not exist |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,19 @@
* limitations under the License.
*/

package org.apache.shardingsphere.proxy.backend.handler.distsql.ral.common.exception;
package org.apache.shardingsphere.proxy.backend.exception;

import org.apache.shardingsphere.infra.util.exception.sql.ShardingSphereSQLException;
import org.apache.shardingsphere.infra.util.exception.sql.sqlstate.XOpenSQLState;

/**
* Invalid value exception.
*/
public final class InvalidValueException extends DistSQLException {
public final class InvalidValueException extends ShardingSphereSQLException {

private static final long serialVersionUID = 1840341880422454371L;

public InvalidValueException(final String value) {
super(value);
super(XOpenSQLState.INVALID_DATA_TYPE, 10301, "Invalid value `%s`", value);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,19 @@
* limitations under the License.
*/

package org.apache.shardingsphere.proxy.backend.handler.distsql.ral.common.exception;
package org.apache.shardingsphere.proxy.backend.exception;

import org.apache.shardingsphere.infra.util.exception.sql.ShardingSphereSQLException;
import org.apache.shardingsphere.infra.util.exception.sql.sqlstate.XOpenSQLState;

/**
* Unsupported variable exception.
*/
public final class UnsupportedVariableException extends DistSQLException {
public final class UnsupportedVariableException extends ShardingSphereSQLException {

private static final long serialVersionUID = 1955281568807066737L;

public UnsupportedVariableException(final String variable) {
super(variable);
super(XOpenSQLState.GENERAL_ERROR, 10301, "Could not support variable `%s`", variable);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

package org.apache.shardingsphere.proxy.backend.handler.distsql.ral.common.enums;

import org.apache.shardingsphere.proxy.backend.handler.distsql.ral.common.exception.UnsupportedVariableException;
import org.apache.shardingsphere.proxy.backend.exception.UnsupportedVariableException;

/**
* Variable enum.
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.JDBCBackendConnection;
import org.apache.shardingsphere.proxy.backend.handler.distsql.ral.QueryableRALBackendHandler;
import org.apache.shardingsphere.proxy.backend.handler.distsql.ral.common.enums.VariableEnum;
import org.apache.shardingsphere.proxy.backend.handler.distsql.ral.common.exception.UnsupportedVariableException;
import org.apache.shardingsphere.proxy.backend.exception.UnsupportedVariableException;
import org.apache.shardingsphere.proxy.backend.util.SystemPropertyUtil;
import org.apache.shardingsphere.transaction.core.TransactionType;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@
import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
import org.apache.shardingsphere.proxy.backend.handler.distsql.ral.UpdatableRALBackendHandler;
import org.apache.shardingsphere.proxy.backend.handler.distsql.ral.common.enums.VariableEnum;
import org.apache.shardingsphere.proxy.backend.handler.distsql.ral.common.exception.InvalidValueException;
import org.apache.shardingsphere.proxy.backend.handler.distsql.ral.common.exception.UnsupportedVariableException;
import org.apache.shardingsphere.proxy.backend.exception.InvalidValueException;
import org.apache.shardingsphere.proxy.backend.exception.UnsupportedVariableException;
import org.apache.shardingsphere.proxy.backend.util.SystemPropertyUtil;
import org.apache.shardingsphere.transaction.core.TransactionType;

Expand Down Expand Up @@ -77,7 +77,7 @@ private void handleConfigurationProperty(final ConfigurationPropertyKey property
private Object getValue(final ConfigurationPropertyKey propertyKey, final String value) {
try {
return new TypedPropertyValue(propertyKey, value).getValue();
} catch (TypedPropertyValueException ex) {
} catch (final TypedPropertyValueException ex) {
throw new InvalidValueException(value);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
import org.apache.shardingsphere.proxy.backend.response.header.query.QueryResponseHeader;
import org.apache.shardingsphere.proxy.backend.session.ConnectionSession;
import org.apache.shardingsphere.proxy.backend.handler.distsql.ral.common.enums.VariableEnum;
import org.apache.shardingsphere.proxy.backend.handler.distsql.ral.common.exception.UnsupportedVariableException;
import org.apache.shardingsphere.proxy.backend.exception.UnsupportedVariableException;
import org.apache.shardingsphere.proxy.backend.util.ProxyContextRestorer;
import org.apache.shardingsphere.proxy.backend.util.SystemPropertyUtil;
import org.apache.shardingsphere.transaction.core.TransactionType;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
import org.apache.shardingsphere.mode.metadata.persist.MetaDataPersistService;
import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
import org.apache.shardingsphere.proxy.backend.handler.distsql.ral.common.enums.VariableEnum;
import org.apache.shardingsphere.proxy.backend.handler.distsql.ral.common.exception.UnsupportedVariableException;
import org.apache.shardingsphere.proxy.backend.exception.UnsupportedVariableException;
import org.apache.shardingsphere.proxy.backend.response.header.ResponseHeader;
import org.apache.shardingsphere.proxy.backend.response.header.update.UpdateResponseHeader;
import org.apache.shardingsphere.proxy.backend.session.ConnectionSession;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import org.apache.shardingsphere.infra.config.exception.ShardingSphereConfigurationException;
import org.apache.shardingsphere.infra.util.exception.ShardingSphereException;
import org.apache.shardingsphere.infra.util.exception.ShardingSphereInsideException;
import org.apache.shardingsphere.proxy.backend.handler.distsql.ral.common.exception.DistSQLException;
import org.apache.shardingsphere.sql.parser.exception.SQLParsingException;

import java.util.Collection;
Expand All @@ -41,7 +40,6 @@ public final class ExpectedExceptions {
EXCEPTIONS.add(ShardingSphereInsideException.class);
EXCEPTIONS.add(ShardingSphereConfigurationException.class);
EXCEPTIONS.add(SQLParsingException.class);
EXCEPTIONS.add(DistSQLException.class);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import org.apache.shardingsphere.infra.config.exception.ShardingSphereConfigurationException;
import org.apache.shardingsphere.infra.util.exception.ShardingSphereException;
import org.apache.shardingsphere.infra.util.exception.ShardingSphereInsideException;
import org.apache.shardingsphere.proxy.backend.handler.distsql.ral.common.exception.DistSQLException;
import org.apache.shardingsphere.sql.parser.exception.SQLParsingException;
import org.junit.Test;

Expand All @@ -36,7 +35,6 @@ public void assertIsExpected() {
assertTrue(ExpectedExceptions.isExpected(ShardingSphereInsideException.class));
assertTrue(ExpectedExceptions.isExpected(ShardingSphereConfigurationException.class));
assertTrue(ExpectedExceptions.isExpected(SQLParsingException.class));
assertTrue(ExpectedExceptions.isExpected(DistSQLException.class));
assertTrue(ExpectedExceptions.isExpected(NoDatabaseSelectedException.class));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@
import org.apache.shardingsphere.dialect.mysql.vendor.MySQLVendorError;
import org.apache.shardingsphere.infra.util.exception.sql.ShardingSphereSQLException;
import org.apache.shardingsphere.infra.util.exception.sql.UnknownSQLException;
import org.apache.shardingsphere.proxy.backend.handler.distsql.ral.common.exception.DistSQLException;
import org.apache.shardingsphere.proxy.backend.handler.distsql.ral.common.exception.DistSQLVendorError;

import java.sql.SQLException;

Expand All @@ -54,10 +52,6 @@ public static MySQLErrPacket newInstance(final Exception cause) {
if (cause instanceof SQLDialectException) {
return createErrPacket(SQLDialectExceptionMapperFactory.getInstance("MySQL").convert((SQLDialectException) cause));
}
if (cause instanceof DistSQLException) {
DistSQLException distSQLException = (DistSQLException) cause;
return new MySQLErrPacket(1, DistSQLVendorError.valueOf(distSQLException), distSQLException.getVariable());
}
return createErrPacket(new UnknownSQLException(cause).toSQLException());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import org.apache.shardingsphere.db.protocol.mysql.packet.generic.MySQLErrPacket;
import org.apache.shardingsphere.dialect.exception.syntax.database.UnknownDatabaseException;
import org.apache.shardingsphere.infra.util.exception.sql.sqlstate.XOpenSQLState;
import org.apache.shardingsphere.proxy.backend.handler.distsql.ral.common.exception.UnsupportedVariableException;
import org.apache.shardingsphere.proxy.frontend.exception.CircuitBreakException;
import org.junit.Test;

Expand Down Expand Up @@ -68,15 +67,6 @@ public void assertNewInstanceWithSQLDialectException() {
assertThat(actual.getErrorMessage(), is("Unknown database 'foo_db'"));
}

@Test
public void assertNewInstanceWithDistException() {
MySQLErrPacket actual = MySQLErrPacketFactory.newInstance(new UnsupportedVariableException("test"));
assertThat(actual.getSequenceId(), is(1));
assertThat(actual.getErrorCode(), is(11001));
assertThat(actual.getSqlState(), is(XOpenSQLState.GENERAL_ERROR.getValue()));
assertThat(actual.getErrorMessage(), is("Could not support variable `test`"));
}

@Test
public void assertNewInstanceWithUnknownException() {
MySQLErrPacket actual = MySQLErrPacketFactory.newInstance(new RuntimeException("No reason"));
Expand Down