#1459 if no sharding table config autoincrementcolumn, the value produce by dble (#1608)

This commit is contained in:
tiger.yan
2020-01-06 13:41:54 +08:00
committed by GitHub
parent 8f8e511a82
commit 12ea71b0fd
2 changed files with 11 additions and 1 deletions
@@ -12,7 +12,6 @@ import com.actiontech.dble.config.ServerPrivileges;
import com.actiontech.dble.config.ServerPrivileges.CheckType;
import com.actiontech.dble.config.model.SchemaConfig;
import com.actiontech.dble.config.model.TableConfig;
import com.actiontech.dble.singleton.ProxyMeta;
import com.actiontech.dble.meta.protocol.StructureMeta;
import com.actiontech.dble.net.ConnectionException;
import com.actiontech.dble.plan.common.ptr.StringPtr;
@@ -25,6 +24,7 @@ import com.actiontech.dble.server.ServerConnection;
import com.actiontech.dble.server.handler.ExplainHandler;
import com.actiontech.dble.server.util.SchemaUtil;
import com.actiontech.dble.server.util.SchemaUtil.SchemaInfo;
import com.actiontech.dble.singleton.ProxyMeta;
import com.actiontech.dble.singleton.SequenceManager;
import com.actiontech.dble.util.StringUtil;
import com.alibaba.druid.sql.SQLUtils;
@@ -119,6 +119,11 @@ public class DruidInsertParser extends DruidInsertReplaceParser {
MySqlInsertStatement insert) throws SQLException {
String noShardingNode = RouterUtil.isNoSharding(schemaInfo.getSchemaConfig(), schemaInfo.getTable());
if (noShardingNode != null) {
// table with single datanode and has autoIncrement property
TableConfig tbConfig = schemaInfo.getSchemaConfig().getTables().get(schemaInfo.getTable());
if (tbConfig != null && tbConfig.isAutoIncrement()) {
return false;
}
StringPtr noShardingNodePr = new StringPtr(noShardingNode);
Set<String> schemas = new HashSet<>();
if (insert.getQuery() != null) {
@@ -136,6 +136,11 @@ public class DruidReplaceParser extends DruidInsertReplaceParser {
private boolean parserNoSharding(ServerConnection sc, String contextSchema, SchemaInfo schemaInfo, RouteResultset rrs, SQLReplaceStatement replace) throws SQLException {
String noShardingNode = RouterUtil.isNoSharding(schemaInfo.getSchemaConfig(), schemaInfo.getTable());
if (noShardingNode != null) {
// table with single datanode and has autoIncrement property
TableConfig tbConfig = schemaInfo.getSchemaConfig().getTables().get(schemaInfo.getTable());
if (tbConfig != null && tbConfig.isAutoIncrement()) {
return false;
}
StringPtr noShardingNodePr = new StringPtr(noShardingNode);
Set<String> schemas = new HashSet<>();
if (replace.getQuery() != null) {