Repository: apache/shardingsphere
Issue: Wrong result set for `select between and` when using encrypt data source

## Bug Report

**For English only**, other languages will not accept.

Before report a bug, make sure you have:

- Searched open and closed [GitHub issues](https://github.com/sharding-sphere/sharding-sphere/issues).
- Read documentation: [ShardingSphere Doc](http://shardingsphere.io/document/current/en/overview/).

Please pay attention on issues you submitted, because we maybe need more details. 
If no response **more than 7 days** and we cannot reproduce it on current information, we will **close it**.

Please answer these questions before submitting your issue. Thanks!

### Which version of ShardingSphere did you use?

### Which project did you use? Sharding-JDBC or Sharding-Proxy?

### Expected behavior
get correct result set for `select between and` when using encrypt data source
### Actual behavior
get wrong result set for `select between and` when using encrypt data source
### Reason analyze (If you can)
Actually, when data is encrypted and stored in db, user can not use `select encrypted column between value1 an value2` to get correct result set. The reason is that encrypted data in db is different from the original data.
Therefore when ss finds this scenario, it will throw exception.
### Steps to reproduce the behavior, such as: SQL to execute, sharding rule configuration, when exception occur etc.

### Example codes for reproduce this issue (such as a github link).


Changed files:
sharding-core/sharding-core-parse/sharding-core-parse-common/src/main/java/org/apache/shardingsphere/core/parse/sql/token/impl/SchemaToken.java
sharding-core/sharding-core-rewrite/src/test/java/org/apache/shardingsphere/core/rewrite/placeholder/WhereEncryptColumnPlaceholderTest.java
sharding-core/sharding-core-parse/sharding-core-parse-common/src/main/java/org/apache/shardingsphere/core/parse/sql/token/impl/IndexToken.java
sharding-core/sharding-core-rewrite/src/test/java/org/apache/shardingsphere/core/rewrite/SQLBuilderTest.java
sharding-core/sharding-core-rewrite/src/main/java/org/apache/shardingsphere/core/rewrite/placeholder/WhereEncryptColumnPlaceholder.java
sharding-core/sharding-core-parse/sharding-core-parse-common/src/main/java/org/apache/shardingsphere/core/parse/extractor/impl/common/index/IndexExtractor.java
sharding-core/sharding-core-rewrite/src/main/java/org/apache/shardingsphere/core/rewrite/placeholder/IndexPlaceholder.java
sharding-core/sharding-core-route/src/test/java/org/apache/shardingsphere/core/route/type/broadcast/TableBroadcastRoutingEngineTest.java
sharding-core/sharding-core-rewrite/src/main/java/org/apache/shardingsphere/core/rewrite/placeholder/SchemaPlaceholder.java
sharding-core/sharding-core-rewrite/src/main/java/org/apache/shardingsphere/core/rewrite/engine/MasterSlaveSQLRewriteEngine.java
sharding-core/sharding-core-parse/sharding-core-parse-common/src/main/java/org/apache/shardingsphere/core/parse/SQLJudgeEngine.java
sharding-core/sharding-core-rewrite/src/main/java/org/apache/shardingsphere/core/rewrite/engine/ShardingSQLRewriteEngine.java
sharding-core/sharding-core-rewrite/src/test/java/org/apache/shardingsphere/core/rewrite/engine/ShardingSQLRewriteEngineTest.java
sharding-core/sharding-core-parse/sharding-core-parse-common/src/main/java/org/apache/shardingsphere/core/parse/filler/common/dal/SchemaFiller.java

diff --git a/sharding-core/sharding-core-parse/sharding-core-parse-common/src/main/java/org/apache/shardingsphere/core/parse/SQLJudgeEngine.java b/sharding-core/sharding-core-parse/sharding-core-parse-common/src/main/java/org/apache/shardingsphere/core/parse/SQLJudgeEngine.java
index 8f945a0f9dc..c0ec2bf6ac1 100644
--- a/sharding-core/sharding-core-parse/sharding-core-parse-common/src/main/java/org/apache/shardingsphere/core/parse/SQLJudgeEngine.java
+++ b/sharding-core/sharding-core-parse/sharding-core-parse-common/src/main/java/org/apache/shardingsphere/core/parse/SQLJudgeEngine.java
@@ -179,7 +179,7 @@ public final class SQLJudgeEngine {
         lexerEngine.nextToken();
         if (lexerEngine.skipIfEqual(DefaultKeyword.FROM, DefaultKeyword.IN)) {
             int beginPosition = lexerEngine.getCurrentToken().getEndPosition() - lexerEngine.getCurrentToken().getLiterals().length();
-            result.addSQLToken(new SchemaToken(beginPosition, lexerEngine.getCurrentToken().getEndPosition() - 1, null));
+            result.addSQLToken(new SchemaToken(beginPosition, lexerEngine.getCurrentToken().getEndPosition() - 1, lexerEngine.getCurrentToken().getLiterals(), null));
         }
         return result;
     }
@@ -188,7 +188,7 @@ public final class SQLJudgeEngine {
         DALStatement result = new ShowTablesStatement();
         if (lexerEngine.skipIfEqual(DefaultKeyword.FROM, DefaultKeyword.IN)) {
             int beginPosition = lexerEngine.getCurrentToken().getEndPosition() - lexerEngine.getCurrentToken().getLiterals().length();
-            result.addSQLToken(new SchemaToken(beginPosition, lexerEngine.getCurrentToken().getEndPosition() - 1, null));
+            result.addSQLToken(new SchemaToken(beginPosition, lexerEngine.getCurrentToken().getEndPosition() - 1, lexerEngine.getCurrentToken().getLiterals(), null));
         }
         return result;
     }
@@ -199,7 +199,7 @@ public final class SQLJudgeEngine {
         parseSingleTableWithSchema(lexerEngine, result);
         if (lexerEngine.skipIfEqual(DefaultKeyword.FROM, DefaultKeyword.IN)) {
             int beginPosition = lexerEngine.getCurrentToken().getEndPosition() - lexerEngine.getCurrentToken().getLiterals().length();
-            result.addSQLToken(new SchemaToken(beginPosition, lexerEngine.getCurrentToken().getEndPosition() - 1, null));
+            result.addSQLToken(new SchemaToken(beginPosition, lexerEngine.getCurrentToken().getEndPosition() - 1, lexerEngine.getCurrentToken().getLiterals(), null));
         }
         return result;
     }
@@ -216,7 +216,7 @@ public final class SQLJudgeEngine {
         parseSingleTableWithSchema(lexerEngine, result);
         if (lexerEngine.skipIfEqual(DefaultKeyword.FROM, DefaultKeyword.IN)) {
             int beginPosition = lexerEngine.getCurrentToken().getEndPosition() - lexerEngine.getCurrentToken().getLiterals().length();
-            result.addSQLToken(new SchemaToken(beginPosition, lexerEngine.getCurrentToken().getEndPosition() - 1, null));
+            result.addSQLToken(new SchemaToken(beginPosition, lexerEngine.getCurrentToken().getEndPosition() - 1, lexerEngine.getCurrentToken().getLiterals(), null));
         }
         return result;
     }
@@ -225,7 +225,7 @@ public final class SQLJudgeEngine {
         int beginPosition = lexerEngine.getCurrentToken().getEndPosition() - lexerEngine.getCurrentToken().getLiterals().length();
         lexerEngine.nextToken();
         if (lexerEngine.skipIfEqual(Symbol.DOT)) {
-            sqlStatement.addSQLToken(new SchemaToken(beginPosition, lexerEngine.getCurrentToken().getEndPosition() - 1, null));
+            sqlStatement.addSQLToken(new SchemaToken(beginPosition, lexerEngine.getCurrentToken().getEndPosition() - 1, lexerEngine.getCurrentToken().getLiterals(), null));
             lexerEngine.nextToken();
         }
     }
diff --git a/sharding-core/sharding-core-parse/sharding-core-parse-common/src/main/java/org/apache/shardingsphere/core/parse/extractor/impl/common/index/IndexExtractor.java b/sharding-core/sharding-core-parse/sharding-core-parse-common/src/main/java/org/apache/shardingsphere/core/parse/extractor/impl/common/index/IndexExtractor.java
index 74600c2d4f6..d1f2c568a3a 100644
--- a/sharding-core/sharding-core-parse/sharding-core-parse-common/src/main/java/org/apache/shardingsphere/core/parse/extractor/impl/common/index/IndexExtractor.java
+++ b/sharding-core/sharding-core-parse/sharding-core-parse-common/src/main/java/org/apache/shardingsphere/core/parse/extractor/impl/common/index/IndexExtractor.java
@@ -41,6 +41,6 @@ public final class IndexExtractor implements OptionalSQLSegmentExtractor {
     }
     
     private IndexToken getIndexToken(final ParserRuleContext indexNameNode) {
-        return new IndexToken(indexNameNode.getStart().getStartIndex(), indexNameNode.getStop().getStopIndex());
+        return new IndexToken(indexNameNode.getStart().getStartIndex(), indexNameNode.getStop().getStopIndex(), indexNameNode.getText());
     }
 }
diff --git a/sharding-core/sharding-core-parse/sharding-core-parse-common/src/main/java/org/apache/shardingsphere/core/parse/filler/common/dal/SchemaFiller.java b/sharding-core/sharding-core-parse/sharding-core-parse-common/src/main/java/org/apache/shardingsphere/core/parse/filler/common/dal/SchemaFiller.java
index edf45812d25..403654df9d7 100644
--- a/sharding-core/sharding-core-parse/sharding-core-parse-common/src/main/java/org/apache/shardingsphere/core/parse/filler/common/dal/SchemaFiller.java
+++ b/sharding-core/sharding-core-parse/sharding-core-parse-common/src/main/java/org/apache/shardingsphere/core/parse/filler/common/dal/SchemaFiller.java
@@ -37,7 +37,7 @@ public final class SchemaFiller implements SQLSegmentFiller<SchemaSegment> {
         if (sqlStatement instanceof UseStatement) {
             ((UseStatement) sqlStatement).setSchema(sqlSegment.getName());
         } else if (sqlStatement instanceof ShowColumnsStatement || sqlStatement instanceof ShowIndexStatement) {
-            sqlStatement.addSQLToken(new SchemaToken(sqlSegment.getStartIndex(), sqlSegment.getStopIndex(), sqlStatement.getTables().getSingleTableName()));
+            sqlStatement.addSQLToken(new SchemaToken(sqlSegment.getStartIndex(), sqlSegment.getStopIndex(), sqlSegment.getName(), sqlStatement.getTables().getSingleTableName()));
         }
     }
 }
diff --git a/sharding-core/sharding-core-parse/sharding-core-parse-common/src/main/java/org/apache/shardingsphere/core/parse/sql/token/impl/IndexToken.java b/sharding-core/sharding-core-parse/sharding-core-parse-common/src/main/java/org/apache/shardingsphere/core/parse/sql/token/impl/IndexToken.java
index fdfddd36b1e..370bfde9d84 100644
--- a/sharding-core/sharding-core-parse/sharding-core-parse-common/src/main/java/org/apache/shardingsphere/core/parse/sql/token/impl/IndexToken.java
+++ b/sharding-core/sharding-core-parse/sharding-core-parse-common/src/main/java/org/apache/shardingsphere/core/parse/sql/token/impl/IndexToken.java
@@ -20,6 +20,7 @@ package org.apache.shardingsphere.core.parse.sql.token.impl;
 import lombok.Getter;
 import lombok.Setter;
 import lombok.ToString;
+import org.apache.shardingsphere.core.parse.constant.QuoteCharacter;
 import org.apache.shardingsphere.core.parse.sql.token.SQLToken;
 import org.apache.shardingsphere.core.parse.sql.token.Substitutable;
 import org.apache.shardingsphere.core.parse.util.SQLUtil;
@@ -35,17 +36,23 @@ import org.apache.shardingsphere.core.parse.util.SQLUtil;
 @ToString
 public final class IndexToken extends SQLToken implements Substitutable {
     
-    private String tableName;
+    private final String indexName;
     
     private final int stopIndex;
     
-    public IndexToken(final int startIndex, final int stopIndex) {
+    private String tableName;
+    
+    private final QuoteCharacter quoteCharacter;
+    
+    public IndexToken(final int startIndex, final int stopIndex, final String indexName) {
         super(startIndex);
+        this.indexName = SQLUtil.getExactlyValue(indexName);
         this.stopIndex = stopIndex;
+        quoteCharacter = QuoteCharacter.getQuoteCharacter(indexName);
     }
     
-    public IndexToken(final int startIndex, final int stopIndex, final String tableName) {
-        this(startIndex, stopIndex);
+    public IndexToken(final int startIndex, final int stopIndex, final String indexName, final String tableName) {
+        this(startIndex, stopIndex, indexName);
         this.tableName = tableName;
     }
     
diff --git a/sharding-core/sharding-core-parse/sharding-core-parse-common/src/main/java/org/apache/shardingsphere/core/parse/sql/token/impl/SchemaToken.java b/sharding-core/sharding-core-parse/sharding-core-parse-common/src/main/java/org/apache/shardingsphere/core/parse/sql/token/impl/SchemaToken.java
index 929522e54c1..c1a97ce3407 100644
--- a/sharding-core/sharding-core-parse/sharding-core-parse-common/src/main/java/org/apache/shardingsphere/core/parse/sql/token/impl/SchemaToken.java
+++ b/sharding-core/sharding-core-parse/sharding-core-parse-common/src/main/java/org/apache/shardingsphere/core/parse/sql/token/impl/SchemaToken.java
@@ -19,6 +19,7 @@ package org.apache.shardingsphere.core.parse.sql.token.impl;
 
 import lombok.Getter;
 import lombok.ToString;
+import org.apache.shardingsphere.core.parse.constant.QuoteCharacter;
 import org.apache.shardingsphere.core.parse.sql.token.SQLToken;
 import org.apache.shardingsphere.core.parse.sql.token.Substitutable;
 import org.apache.shardingsphere.core.parse.util.SQLUtil;
@@ -29,18 +30,24 @@ import org.apache.shardingsphere.core.parse.util.SQLUtil;
  * @author zhangliang
  * @author panjuan
  */
+@Getter
 @ToString
 public final class SchemaToken extends SQLToken implements Substitutable {
     
+    private final String schemaName;
+    
     private final String tableName;
     
-    @Getter
+    private final QuoteCharacter quoteCharacter;
+    
     private final int stopIndex;
     
-    public SchemaToken(final int startIndex, final int stopIndex, final String tableName) {
+    public SchemaToken(final int startIndex, final int stopIndex, final String schemaName, final String tableName) {
         super(startIndex);
+        this.schemaName = SQLUtil.getExactlyValue(schemaName);
         this.tableName = tableName;
         this.stopIndex = stopIndex;
+        this.quoteCharacter = QuoteCharacter.getQuoteCharacter(schemaName);
     }
     
     /**
diff --git a/sharding-core/sharding-core-rewrite/src/main/java/org/apache/shardingsphere/core/rewrite/engine/MasterSlaveSQLRewriteEngine.java b/sharding-core/sharding-core-rewrite/src/main/java/org/apache/shardingsphere/core/rewrite/engine/MasterSlaveSQLRewriteEngine.java
index 0c5366322b3..38c9306ae05 100644
--- a/sharding-core/sharding-core-rewrite/src/main/java/org/apache/shardingsphere/core/rewrite/engine/MasterSlaveSQLRewriteEngine.java
+++ b/sharding-core/sharding-core-rewrite/src/main/java/org/apache/shardingsphere/core/rewrite/engine/MasterSlaveSQLRewriteEngine.java
@@ -75,8 +75,7 @@ public final class MasterSlaveSQLRewriteEngine implements SQLRewriteEngine {
     }
     
     private void appendSchemaPlaceholder(final SQLBuilder sqlBuilder, final SchemaToken schemaToken, final int count) {
-        String schemaName = originalSQL.substring(schemaToken.getStartIndex(), schemaToken.getStopIndex() + 1);
-        sqlBuilder.appendPlaceholder(new SchemaPlaceholder(schemaName.toLowerCase(), schemaToken.getTableName().toLowerCase(), masterSlaveRule, dataSourceMetaData));
+        sqlBuilder.appendPlaceholder(new SchemaPlaceholder(schemaToken.getSchemaName().toLowerCase(), schemaToken.getTableName().toLowerCase(), schemaToken.getQuoteCharacter(), masterSlaveRule, dataSourceMetaData));
         appendRest(sqlBuilder, count, schemaToken.getStopIndex() + 1);
     }
     
diff --git a/sharding-core/sharding-core-rewrite/src/main/java/org/apache/shardingsphere/core/rewrite/engine/ShardingSQLRewriteEngine.java b/sharding-core/sharding-core-rewrite/src/main/java/org/apache/shardingsphere/core/rewrite/engine/ShardingSQLRewriteEngine.java
index 2795cd73e0f..84f1a2936e0 100644
--- a/sharding-core/sharding-core-rewrite/src/main/java/org/apache/shardingsphere/core/rewrite/engine/ShardingSQLRewriteEngine.java
+++ b/sharding-core/sharding-core-rewrite/src/main/java/org/apache/shardingsphere/core/rewrite/engine/ShardingSQLRewriteEngine.java
@@ -211,18 +211,17 @@ public final class ShardingSQLRewriteEngine implements SQLRewriteEngine {
     }
     
     private void appendSchemaPlaceholder(final SQLBuilder sqlBuilder, final SchemaToken schemaToken, final int count) {
-        String schemaName = originalSQL.substring(schemaToken.getStartIndex(), schemaToken.getStopIndex() + 1);
-        sqlBuilder.appendPlaceholder(new SchemaPlaceholder(schemaName.toLowerCase(), schemaToken.getTableName().toLowerCase(), shardingRule, dataSourceMetaData));
+        sqlBuilder.appendPlaceholder(
+                new SchemaPlaceholder(schemaToken.getSchemaName().toLowerCase(), schemaToken.getTableName().toLowerCase(), schemaToken.getQuoteCharacter(), shardingRule, dataSourceMetaData));
         appendRest(sqlBuilder, count, schemaToken.getStopIndex() + 1);
     }
     
     private void appendIndexPlaceholder(final SQLBuilder sqlBuilder, final IndexToken indexToken, final int count) {
-        String indexName = originalSQL.substring(indexToken.getStartIndex(), indexToken.getStopIndex() + 1);
         String logicTableName = indexToken.getTableName().toLowerCase();
         if (Strings.isNullOrEmpty(logicTableName)) {
-            logicTableName = shardingRule.getLogicTableName(indexName);
+            logicTableName = shardingRule.getLogicTableName(indexToken.getIndexName());
         }
-        sqlBuilder.appendPlaceholder(new IndexPlaceholder(indexName, logicTableName));
+        sqlBuilder.appendPlaceholder(new IndexPlaceholder(indexToken.getIndexName(), logicTableName, indexToken.getQuoteCharacter()));
         appendRest(sqlBuilder, count, indexToken.getStopIndex() + 1);
     }
     
diff --git a/sharding-core/sharding-core-rewrite/src/main/java/org/apache/shardingsphere/core/rewrite/placeholder/IndexPlaceholder.java b/sharding-core/sharding-core-rewrite/src/main/java/org/apache/shardingsphere/core/rewrite/placeholder/IndexPlaceholder.java
index fbac3002f4e..e072c71a4d3 100644
--- a/sharding-core/sharding-core-rewrite/src/main/java/org/apache/shardingsphere/core/rewrite/placeholder/IndexPlaceholder.java
+++ b/sharding-core/sharding-core-rewrite/src/main/java/org/apache/shardingsphere/core/rewrite/placeholder/IndexPlaceholder.java
@@ -19,8 +19,8 @@ package org.apache.shardingsphere.core.rewrite.placeholder;
 
 import com.google.common.base.Strings;
 import lombok.Getter;
+import lombok.RequiredArgsConstructor;
 import org.apache.shardingsphere.core.parse.constant.QuoteCharacter;
-import org.apache.shardingsphere.core.parse.util.SQLUtil;
 import org.apache.shardingsphere.core.route.type.RoutingUnit;
 
 import java.util.Map;
@@ -31,6 +31,7 @@ import java.util.Map;
  * @author zhangliang
  * @author panjuan
  */
+@RequiredArgsConstructor
 @Getter
 public final class IndexPlaceholder implements ShardingPlaceholder, Alterable {
     
@@ -40,12 +41,6 @@ public final class IndexPlaceholder implements ShardingPlaceholder, Alterable {
     
     private final QuoteCharacter quoteCharacter;
     
-    public IndexPlaceholder(final String logicIndexLiteral, final String logicTableName) {
-        logicIndexName = SQLUtil.getExactlyValue(logicIndexLiteral);
-        this.logicTableName = logicTableName;
-        quoteCharacter = QuoteCharacter.getQuoteCharacter(logicIndexLiteral);
-    }
-    
     @Override
     public String toString(final RoutingUnit routingUnit, final Map<String, String> logicAndActualTables) {
         StringBuilder result = new StringBuilder();
diff --git a/sharding-core/sharding-core-rewrite/src/main/java/org/apache/shardingsphere/core/rewrite/placeholder/SchemaPlaceholder.java b/sharding-core/sharding-core-rewrite/src/main/java/org/apache/shardingsphere/core/rewrite/placeholder/SchemaPlaceholder.java
index 62057b2d451..a717ce48e3c 100644
--- a/sharding-core/sharding-core-rewrite/src/main/java/org/apache/shardingsphere/core/rewrite/placeholder/SchemaPlaceholder.java
+++ b/sharding-core/sharding-core-rewrite/src/main/java/org/apache/shardingsphere/core/rewrite/placeholder/SchemaPlaceholder.java
@@ -21,6 +21,7 @@ import com.google.common.base.Strings;
 import lombok.Getter;
 import lombok.RequiredArgsConstructor;
 import org.apache.shardingsphere.core.metadata.datasource.ShardingDataSourceMetaData;
+import org.apache.shardingsphere.core.parse.constant.QuoteCharacter;
 import org.apache.shardingsphere.core.route.type.RoutingUnit;
 import org.apache.shardingsphere.core.rule.BaseRule;
 
@@ -40,15 +41,16 @@ public final class SchemaPlaceholder implements ShardingPlaceholder, Alterable {
     
     private final String logicTableName;
     
+    private final QuoteCharacter quoteCharacter;
+    
     private final BaseRule baseRule;
     
     private final ShardingDataSourceMetaData dataSourceMetaData;
     
     @Override
     public String toString(final RoutingUnit routingUnit, final Map<String, String> logicAndActualTables) {
-        if (Strings.isNullOrEmpty(logicTableName)) {
-            return logicTableName;
-        }
-        return dataSourceMetaData.getActualDataSourceMetaData(baseRule.getActualDataSourceName(logicAndActualTables.get(logicTableName))).getSchemaName();
+        String actualSchemaName = Strings.isNullOrEmpty(logicTableName) 
+                ? logicSchemaName : dataSourceMetaData.getActualDataSourceMetaData(baseRule.getActualDataSourceName(logicAndActualTables.get(logicTableName))).getSchemaName();
+        return quoteCharacter.getStartDelimiter() + actualSchemaName + quoteCharacter.getEndDelimiter();
     }
 }
diff --git a/sharding-core/sharding-core-rewrite/src/main/java/org/apache/shardingsphere/core/rewrite/placeholder/WhereEncryptColumnPlaceholder.java b/sharding-core/sharding-core-rewrite/src/main/java/org/apache/shardingsphere/core/rewrite/placeholder/WhereEncryptColumnPlaceholder.java
index d6b42f63ea9..5addadefcec 100644
--- a/sharding-core/sharding-core-rewrite/src/main/java/org/apache/shardingsphere/core/rewrite/placeholder/WhereEncryptColumnPlaceholder.java
+++ b/sharding-core/sharding-core-rewrite/src/main/java/org/apache/shardingsphere/core/rewrite/placeholder/WhereEncryptColumnPlaceholder.java
@@ -47,8 +47,6 @@ public final class WhereEncryptColumnPlaceholder implements ShardingPlaceholder
         switch (operator) {
             case EQUAL:
                 return parameterMarkerIndexes.isEmpty() ? String.format("%s = '%s'", columnName, indexValues.get(0)) : String.format("%s = ?", columnName);
-            case BETWEEN:
-                return toStringFromBetween();
             case IN:
                 return toStringFromIn();
             default:
@@ -56,19 +54,6 @@ public final class WhereEncryptColumnPlaceholder implements ShardingPlaceholder
         }
     }
     
-    private String toStringFromBetween() {
-        if (parameterMarkerIndexes.isEmpty()) {
-            return String.format("%s %s '%s' AND '%s'", columnName, operator.name(), indexValues.get(0), indexValues.get(1));
-        }
-        if (2 == parameterMarkerIndexes.size()) {
-            return String.format("%s %s ? AND ?", columnName, operator.name());
-        }
-        if (0 == parameterMarkerIndexes.iterator().next()) {
-            return String.format("%s %s ? AND '%s'", columnName, operator.name(), indexValues.get(0));
-        }
-        return String.format("%s %s '%s' AND ?", columnName, operator.name(), indexValues.get(0));
-    }
-    
     private String toStringFromIn() {
         StringBuilder stringBuilder = new StringBuilder();
         stringBuilder.append(columnName).append(" ").append(operator.name()).append(" (");
diff --git a/sharding-core/sharding-core-rewrite/src/test/java/org/apache/shardingsphere/core/rewrite/SQLBuilderTest.java b/sharding-core/sharding-core-rewrite/src/test/java/org/apache/shardingsphere/core/rewrite/SQLBuilderTest.java
index 794788ab886..42be742c835 100644
--- a/sharding-core/sharding-core-rewrite/src/test/java/org/apache/shardingsphere/core/rewrite/SQLBuilderTest.java
+++ b/sharding-core/sharding-core-rewrite/src/test/java/org/apache/shardingsphere/core/rewrite/SQLBuilderTest.java
@@ -91,7 +91,7 @@ public final class SQLBuilderTest {
     public void assertIndexPlaceholderAppendTableWithoutTableToken() {
         SQLBuilder sqlBuilder = new SQLBuilder();
         sqlBuilder.appendLiterals("CREATE INDEX ");
-        sqlBuilder.appendPlaceholder(new IndexPlaceholder("index_name", "index_name"));
+        sqlBuilder.appendPlaceholder(new IndexPlaceholder("index_name", "index_name", QuoteCharacter.NONE));
         sqlBuilder.appendLiterals(" ON ");
         sqlBuilder.appendPlaceholder(new TablePlaceholder("table_x", QuoteCharacter.NONE));
         sqlBuilder.appendLiterals(" ('column')");
@@ -102,7 +102,7 @@ public final class SQLBuilderTest {
     public void assertIndexPlaceholderAppendTableWithTableToken() {
         SQLBuilder sqlBuilder = new SQLBuilder();
         sqlBuilder.appendLiterals("CREATE INDEX ");
-        sqlBuilder.appendPlaceholder(new IndexPlaceholder("index_name", "table_x"));
+        sqlBuilder.appendPlaceholder(new IndexPlaceholder("index_name", "table_x", QuoteCharacter.NONE));
         sqlBuilder.appendLiterals(" ON ");
         sqlBuilder.appendPlaceholder(new TablePlaceholder("table_x", QuoteCharacter.NONE));
         sqlBuilder.appendLiterals(" ('column')");
@@ -118,7 +118,7 @@ public final class SQLBuilderTest {
         sqlBuilder.appendLiterals("CREATE TABLE ");
         sqlBuilder.appendPlaceholder(new TablePlaceholder("table_x", QuoteCharacter.NONE));
         sqlBuilder.appendLiterals("ON ");
-        sqlBuilder.appendPlaceholder(new SchemaPlaceholder("dx", "table_x", createShardingRule(), null));
+        sqlBuilder.appendPlaceholder(new SchemaPlaceholder("dx", "table_x", QuoteCharacter.NONE, createShardingRule(), null));
         sqlBuilder.toSQL(null, Collections.<String, String>emptyMap());
     }
     
@@ -129,7 +129,7 @@ public final class SQLBuilderTest {
         sqlBuilder.appendLiterals("CREATE TABLE ");
         sqlBuilder.appendPlaceholder(new TablePlaceholder("table_0", QuoteCharacter.NONE));
         sqlBuilder.appendLiterals(" ON ");
-        sqlBuilder.appendPlaceholder(new SchemaPlaceholder("ds0", "table_0", createShardingRule(), shardingDataSourceMetaData));
+        sqlBuilder.appendPlaceholder(new SchemaPlaceholder("ds0", "table_0", QuoteCharacter.NONE, createShardingRule(), shardingDataSourceMetaData));
         Map<String, String> tableTokens = new HashMap<>(1, 1);
         tableTokens.put("table_0", "table_1");
 //        ShardingDataSourceMetaData shardingDataSourceMetaData = Mockito.mock(ShardingDataSourceMetaData.class);
@@ -165,7 +165,7 @@ public final class SQLBuilderTest {
     public void assertIndexPlaceholderAppendTableWithoutTableTokenWithBackQuotes() {
         SQLBuilder sqlBuilder = new SQLBuilder();
         sqlBuilder.appendLiterals("CREATE INDEX ");
-        sqlBuilder.appendPlaceholder(new IndexPlaceholder("index_name", "index_name"));
+        sqlBuilder.appendPlaceholder(new IndexPlaceholder("index_name", "index_name", QuoteCharacter.NONE));
         sqlBuilder.appendLiterals(" ON ");
         sqlBuilder.appendPlaceholder(new TablePlaceholder("table_x", QuoteCharacter.BACK_QUOTE));
         sqlBuilder.appendLiterals(" ('column')");
@@ -176,7 +176,7 @@ public final class SQLBuilderTest {
     public void assertIndexPlaceholderAppendTableWithTableTokenWithBackQuotes() {
         SQLBuilder sqlBuilder = new SQLBuilder();
         sqlBuilder.appendLiterals("CREATE INDEX ");
-        sqlBuilder.appendPlaceholder(new IndexPlaceholder("index_name", "table_x"));
+        sqlBuilder.appendPlaceholder(new IndexPlaceholder("index_name", "table_x", QuoteCharacter.NONE));
         sqlBuilder.appendLiterals(" ON ");
         sqlBuilder.appendPlaceholder(new TablePlaceholder("table_x", QuoteCharacter.BACK_QUOTE));
         sqlBuilder.appendLiterals(" ('column')");
@@ -192,7 +192,7 @@ public final class SQLBuilderTest {
         sqlBuilder.appendLiterals("CREATE TABLE ");
         sqlBuilder.appendPlaceholder(new TablePlaceholder("table_0", QuoteCharacter.BACK_QUOTE));
         sqlBuilder.appendLiterals(" ON ");
-        sqlBuilder.appendPlaceholder(new SchemaPlaceholder("ds", "table_0", createShardingRule(), shardingDataSourceMetaData));
+        sqlBuilder.appendPlaceholder(new SchemaPlaceholder("ds", "table_0", QuoteCharacter.NONE, createShardingRule(), shardingDataSourceMetaData));
         Map<String, String> tableTokens = new HashMap<>(1, 1);
         tableTokens.put("table_0", "table_1");
         assertThat(sqlBuilder.toSQL(null, tableTokens).getSql(), is("SHOW CREATE TABLE `table_1` ON actual_db"));
@@ -226,7 +226,7 @@ public final class SQLBuilderTest {
     public void assertIndexPlaceholderAppendTableWithoutTableTokenWithDoubleQuotes() {
         SQLBuilder sqlBuilder = new SQLBuilder();
         sqlBuilder.appendLiterals("CREATE INDEX ");
-        sqlBuilder.appendPlaceholder(new IndexPlaceholder("index_name", "index_name"));
+        sqlBuilder.appendPlaceholder(new IndexPlaceholder("index_name", "index_name", QuoteCharacter.NONE));
         sqlBuilder.appendLiterals(" ON ");
         sqlBuilder.appendPlaceholder(new TablePlaceholder("table_x", QuoteCharacter.QUOTE));
         sqlBuilder.appendLiterals(" ('column')");
@@ -237,7 +237,7 @@ public final class SQLBuilderTest {
     public void assertIndexPlaceholderAppendTableWithTableTokenWithDoubleQuotes() {
         SQLBuilder sqlBuilder = new SQLBuilder();
         sqlBuilder.appendLiterals("CREATE INDEX ");
-        sqlBuilder.appendPlaceholder(new IndexPlaceholder("index_name", "table_x"));
+        sqlBuilder.appendPlaceholder(new IndexPlaceholder("index_name", "table_x", QuoteCharacter.NONE));
         sqlBuilder.appendLiterals(" ON ");
         sqlBuilder.appendPlaceholder(new TablePlaceholder("table_x", QuoteCharacter.QUOTE));
         sqlBuilder.appendLiterals(" ('column')");
@@ -253,7 +253,7 @@ public final class SQLBuilderTest {
         sqlBuilder.appendLiterals("CREATE TABLE ");
         sqlBuilder.appendPlaceholder(new TablePlaceholder("table_0", QuoteCharacter.QUOTE));
         sqlBuilder.appendLiterals(" ON ");
-        sqlBuilder.appendPlaceholder(new SchemaPlaceholder("ds", "table_0", createShardingRule(), shardingDataSourceMetaData));
+        sqlBuilder.appendPlaceholder(new SchemaPlaceholder("ds", "table_0", QuoteCharacter.NONE, createShardingRule(), shardingDataSourceMetaData));
         Map<String, String> tableTokens = new HashMap<>(1, 1);
         tableTokens.put("table_0", "table_1");
         assertThat(sqlBuilder.toSQL(null, tableTokens).getSql(), is("SHOW CREATE TABLE \\"table_1\\" ON actual_db"));
@@ -261,7 +261,7 @@ public final class SQLBuilderTest {
     
     @Test
     public void assertShardingPlaceholderToString() {
-        assertThat(new IndexPlaceholder("index_name", "table_x").toString(null, Collections.<String, String>emptyMap()), is("index_name"));
+        assertThat(new IndexPlaceholder("index_name", "table_x", QuoteCharacter.NONE).toString(null, Collections.<String, String>emptyMap()), is("index_name"));
         assertThat(new TablePlaceholder("table_name", QuoteCharacter.BACK_QUOTE).toString(null, Collections.<String, String>emptyMap()), is("`table_name`"));
     }
     
diff --git a/sharding-core/sharding-core-rewrite/src/test/java/org/apache/shardingsphere/core/rewrite/engine/ShardingSQLRewriteEngineTest.java b/sharding-core/sharding-core-rewrite/src/test/java/org/apache/shardingsphere/core/rewrite/engine/ShardingSQLRewriteEngineTest.java
index 28393c2ed69..8d38f632ddc 100644
--- a/sharding-core/sharding-core-rewrite/src/test/java/org/apache/shardingsphere/core/rewrite/engine/ShardingSQLRewriteEngineTest.java
+++ b/sharding-core/sharding-core-rewrite/src/test/java/org/apache/shardingsphere/core/rewrite/engine/ShardingSQLRewriteEngineTest.java
@@ -550,7 +550,7 @@ public final class ShardingSQLRewriteEngineTest {
         tableTokens = new HashMap<>(1, 1);
         tableTokens.put("table_x", "table_y");
         selectStatement.addSQLToken(new TableToken(18, 24, "table_x", QuoteCharacter.NONE));
-        selectStatement.addSQLToken(new SchemaToken(29, 35, "table_x"));
+        selectStatement.addSQLToken(new SchemaToken(29, 35, "db0", "table_x"));
         routeResult = new SQLRouteResult(selectStatement);
         routeResult.setLimit(selectStatement.getLimit());
         routeResult.setRoutingResult(new RoutingResult());
@@ -561,7 +561,7 @@ public final class ShardingSQLRewriteEngineTest {
     
     @Test
     public void assertIndexTokenForIndexNameTableName() {
-        selectStatement.addSQLToken(new IndexToken(13, 22, "table_x"));
+        selectStatement.addSQLToken(new IndexToken(13, 22, "index_name", "table_x"));
         selectStatement.addSQLToken(new TableToken(27, 33, "table_x", QuoteCharacter.NONE));
         routeResult = new SQLRouteResult(selectStatement);
         routeResult.setLimit(selectStatement.getLimit());
@@ -573,7 +573,7 @@ public final class ShardingSQLRewriteEngineTest {
     
     @Test
     public void assertIndexTokenForIndexNameTableNameWithoutLogicTableName() {
-        selectStatement.addSQLToken(new IndexToken(13, 23, ""));
+        selectStatement.addSQLToken(new IndexToken(13, 23, "logic_index", "table_x"));
         selectStatement.addSQLToken(new TableToken(28, 34, "table_x", QuoteCharacter.NONE));
         routeResult = new SQLRouteResult(selectStatement);
         routeResult.setLimit(selectStatement.getLimit());
@@ -598,7 +598,7 @@ public final class ShardingSQLRewriteEngineTest {
     @Test
     public void assertTableTokenWithoutBackQuoteFromSchemaForShow() {
         showTablesStatement.addSQLToken(new TableToken(18, 24, "table_x", QuoteCharacter.NONE));
-        showTablesStatement.addSQLToken(new SchemaToken(31, 43, "table_x"));
+        showTablesStatement.addSQLToken(new SchemaToken(31, 43, "db0", "table_x"));
         routeResult = new SQLRouteResult(showTablesStatement);
         RoutingResult routingResult = new RoutingResult();
         routingResult.getRoutingUnits().add(new RoutingUnit("ds"));
@@ -771,22 +771,6 @@ public final class ShardingSQLRewriteEngineTest {
         assertThat(parameters.get(0), is((Object) "encryptValue"));
     }
     
-    @Test
-    public void assertSelectBetweenWithShardingEncryptor() {
-        Column column = new Column("id", "table_z");
-        selectStatement.addSQLToken(new TableToken(15, 21, "table_z", QuoteCharacter.NONE));
-        selectStatement.addSQLToken(new EncryptColumnToken(29, 46, column, true));
-        selectStatement.getEncryptCondition().getOrConditions().add(new AndCondition());
-        selectStatement.getEncryptCondition().getOrConditions().get(0).getConditions().add(new Condition(column, new SQLNumberExpression(3), new SQLNumberExpression(5)));
-        routeResult = new SQLRouteResult(selectStatement);
-        routeResult.setLimit(selectStatement.getLimit());
-        routeResult.setRoutingResult(new RoutingResult());
-        ShardingSQLRewriteEngine rewriteEngine = new ShardingSQLRewriteEngine(shardingRule,
-                "SELECT id FROM table_z WHERE id between 3 and 5", DatabaseType.MySQL, routeResult, new LinkedList<>(), shardingDataSourceMetaData);
-        assertThat(rewriteEngine.rewrite().toSQL(null, tableTokens).getSql(), 
-                is("SELECT id FROM table_z WHERE id BETWEEN 'encryptValue' AND 'encryptValue'"));
-    }
-    
     @Test
     public void assertSelectInWithShardingEncryptor() {
         Column column = new Column("id", "table_z");
@@ -886,27 +870,4 @@ public final class ShardingSQLRewriteEngineTest {
         assertThat(rewriteEngine.rewrite().toSQL(null, tableTokens).getSql(), 
                 is("UPDATE table_z SET id = 'encryptValue' WHERE id = 'encryptValue'"));
     }
-    
-    @Test
-    public void assertUpdateWithQueryAssistedShardingEncryptor() {
-        List<Object> parameters = new ArrayList<>(2);
-        parameters.add(1);
-        parameters.add(5);
-        Column column = new Column("id", "table_k");
-        updateStatement.addSQLToken(new TableToken(7, 13, "table_k", QuoteCharacter.NONE));
-        updateStatement.addSQLToken(new EncryptColumnToken(19, 24, column, false));
-        updateStatement.getAssignments().put(column, new SQLParameterMarkerExpression(0));
-        updateStatement.addSQLToken(new EncryptColumnToken(32, 49, column, true));
-        updateStatement.getEncryptCondition().getOrConditions().add(new AndCondition());
-        updateStatement.getEncryptCondition().getOrConditions().get(0).getConditions().add(new Condition(column, new SQLNumberExpression(3), new SQLParameterMarkerExpression(1)));
-        routeResult = new SQLRouteResult(updateStatement);
-        routeResult.setRoutingResult(new RoutingResult());
-        ShardingSQLRewriteEngine rewriteEngine = new ShardingSQLRewriteEngine(shardingRule,
-                "UPDATE table_k SET id = ? WHERE id between 3 and ?", DatabaseType.MySQL, routeResult, parameters, shardingDataSourceMetaData);
-        assertThat(rewriteEngine.rewrite().toSQL(null, tableTokens).getSql(), 
-                is("UPDATE table_k SET id = ?, query_id = ? WHERE query_id BETWEEN 'assistedEncryptValue' AND ?"));
-        assertThat(parameters.get(0), is((Object) "encryptValue"));
-        assertThat(parameters.get(1), is((Object) "assistedEncryptValue"));
-        assertThat(parameters.get(1), is((Object) "assistedEncryptValue"));
-    }
 }
diff --git a/sharding-core/sharding-core-rewrite/src/test/java/org/apache/shardingsphere/core/rewrite/placeholder/WhereEncryptColumnPlaceholderTest.java b/sharding-core/sharding-core-rewrite/src/test/java/org/apache/shardingsphere/core/rewrite/placeholder/WhereEncryptColumnPlaceholderTest.java
index 1bccadb63e1..4d276d9aa5d 100644
--- a/sharding-core/sharding-core-rewrite/src/test/java/org/apache/shardingsphere/core/rewrite/placeholder/WhereEncryptColumnPlaceholderTest.java
+++ b/sharding-core/sharding-core-rewrite/src/test/java/org/apache/shardingsphere/core/rewrite/placeholder/WhereEncryptColumnPlaceholderTest.java
@@ -17,7 +17,6 @@
 
 package org.apache.shardingsphere.core.rewrite.placeholder;
 
-import com.google.common.collect.Lists;
 import org.apache.shardingsphere.core.constant.ShardingOperator;
 import org.junit.Before;
 import org.junit.Test;
@@ -55,37 +54,6 @@ public class WhereEncryptColumnPlaceholderTest {
         assertThat(whereEncryptColumnPlaceholder.toString(), is("column_x = ?"));
     }
     
-    @Test
-    public void assertToStringWithoutPlaceholderWithBetween() {
-        Map<Integer, Comparable<?>> indexValues = new LinkedHashMap<>();
-        indexValues.put(0, "a");
-        indexValues.put(1, "b");
-        whereEncryptColumnPlaceholder = new WhereEncryptColumnPlaceholder("column_x", indexValues, Collections.<Integer>emptyList(), ShardingOperator.BETWEEN);
-        assertThat(whereEncryptColumnPlaceholder.toString(), is("column_x BETWEEN 'a' AND 'b'"));
-    }
-    
-    @Test
-    public void assertToStringWithFirstPlaceholderWithBetween() {
-        Map<Integer, Comparable<?>> indexValues = new LinkedHashMap<>();
-        indexValues.put(0, "a");
-        whereEncryptColumnPlaceholder = new WhereEncryptColumnPlaceholder("column_x", indexValues, Collections.singletonList(1), ShardingOperator.BETWEEN);
-        assertThat(whereEncryptColumnPlaceholder.toString(), is("column_x BETWEEN 'a' AND ?"));
-    }
-    
-    @Test
-    public void assertToStringWithSecondPlaceholderWithBetween() {
-        Map<Integer, Comparable<?>> indexValues = new LinkedHashMap<>();
-        indexValues.put(0, "a");
-        whereEncryptColumnPlaceholder = new WhereEncryptColumnPlaceholder("column_x", indexValues, Collections.singletonList(0), ShardingOperator.BETWEEN);
-        assertThat(whereEncryptColumnPlaceholder.toString(), is("column_x BETWEEN ? AND 'a'"));
-    }
-    
-    @Test
-    public void assertToStringWithTwoPlaceholderWithBetween() {
-        whereEncryptColumnPlaceholder = new WhereEncryptColumnPlaceholder("column_x", Collections.<Integer, Comparable<?>>emptyMap(), Lists.newArrayList(0, 1), ShardingOperator.BETWEEN);
-        assertThat(whereEncryptColumnPlaceholder.toString(), is("column_x BETWEEN ? AND ?"));
-    }
-    
     @Test
     public void assertToStringWithoutPlaceholderWithIn() {
         Map<Integer, Comparable<?>> indexValues = new LinkedHashMap<>();
diff --git a/sharding-core/sharding-core-route/src/test/java/org/apache/shardingsphere/core/route/type/broadcast/TableBroadcastRoutingEngineTest.java b/sharding-core/sharding-core-route/src/test/java/org/apache/shardingsphere/core/route/type/broadcast/TableBroadcastRoutingEngineTest.java
index 2d49b498bd3..7f50bdccd4f 100644
--- a/sharding-core/sharding-core-route/src/test/java/org/apache/shardingsphere/core/route/type/broadcast/TableBroadcastRoutingEngineTest.java
+++ b/sharding-core/sharding-core-route/src/test/java/org/apache/shardingsphere/core/route/type/broadcast/TableBroadcastRoutingEngineTest.java
@@ -87,7 +87,7 @@ public final class TableBroadcastRoutingEngineTest {
     private RoutingResult createDDLStatementRoutingResult() {
         DDLStatement ddlStatement = new DDLStatement();
         ddlStatement.setLogicSQL("CREATE INDEX t_order_index on t_order");
-        ddlStatement.addSQLToken(new IndexToken(13, 25, "t_order"));
+        ddlStatement.addSQLToken(new IndexToken(13, 25, "t_order_index", "t_order"));
         TableBroadcastRoutingEngine tableBroadcastRoutingEngine = new TableBroadcastRoutingEngine(shardingRule, ddlStatement);
         return tableBroadcastRoutingEngine.route();
     }