diff --git a/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/engine/segment/dml/from/type/SimpleTableSegmentBinder.java b/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/engine/segment/dml/from/type/SimpleTableSegmentBinder.java index b611f51151287..6b2561ce90a15 100644 --- a/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/engine/segment/dml/from/type/SimpleTableSegmentBinder.java +++ b/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/engine/segment/dml/from/type/SimpleTableSegmentBinder.java @@ -85,10 +85,8 @@ public static SimpleTableSegment bind(final SimpleTableSegment segment, final SQ IdentifierValue tableName = segment.getTableName().getIdentifier(); ShardingSphereSchema schema = binderContext.getMetaData().getDatabase(databaseName.getValue()).getSchema(schemaName.getValue()); checkTableExists(binderContext, schema, schemaName.getValue(), tableName.getValue()); - if (null != tableBinderContexts) { - tableBinderContexts.put(new CaseInsensitiveString(segment.getAliasName().orElseGet(tableName::getValue)), - createSimpleTableBinderContext(segment, schema, databaseName, schemaName, binderContext)); - } + tableBinderContexts.put(new CaseInsensitiveString(segment.getAliasName().orElseGet(tableName::getValue)), + createSimpleTableBinderContext(segment, schema, databaseName, schemaName, binderContext)); TableNameSegment tableNameSegment = new TableNameSegment(segment.getTableName().getStartIndex(), segment.getTableName().getStopIndex(), tableName); tableNameSegment.setTableBoundInfo(new TableSegmentBoundInfo(databaseName, schemaName)); SimpleTableSegment result = new SimpleTableSegment(tableNameSegment); diff --git a/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/engine/statement/ddl/AlterIndexStatementBinder.java b/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/engine/statement/ddl/AlterIndexStatementBinder.java index 983d881060b61..848755e5ac1e6 100644 --- a/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/engine/statement/ddl/AlterIndexStatementBinder.java +++ b/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/engine/statement/ddl/AlterIndexStatementBinder.java @@ -17,12 +17,15 @@ package org.apache.shardingsphere.infra.binder.engine.statement.ddl; +import com.cedarsoftware.util.CaseInsensitiveMap; +import com.google.common.collect.LinkedHashMultimap; +import com.google.common.collect.Multimap; import lombok.SneakyThrows; -import org.apache.shardingsphere.infra.binder.engine.segment.from.type.SimpleTableSegmentBinder; +import org.apache.shardingsphere.infra.binder.engine.segment.dml.from.context.TableSegmentBinderContext; +import org.apache.shardingsphere.infra.binder.engine.segment.dml.from.type.SimpleTableSegmentBinder; import org.apache.shardingsphere.infra.binder.engine.statement.SQLStatementBinder; import org.apache.shardingsphere.infra.binder.engine.statement.SQLStatementBinderContext; import org.apache.shardingsphere.sql.parser.statement.core.statement.ddl.AlterIndexStatement; -import org.apache.shardingsphere.sql.parser.statement.sqlserver.ddl.SQLServerAlterIndexStatement; /** * Alter index statement binder. @@ -31,21 +34,18 @@ public class AlterIndexStatementBinder implements SQLStatementBinder tableBinderContexts = LinkedHashMultimap.create(); + result.setSimpleTable(SimpleTableSegmentBinder.bind(sqlStatement.getSimpleTable().get(), binderContext, tableBinderContexts)); + return result; } @SneakyThrows(ReflectiveOperationException.class) - private static SQLServerAlterIndexStatement copy(final SQLServerAlterIndexStatement sqlStatement) { - SQLServerAlterIndexStatement result = sqlStatement.getClass().getDeclaredConstructor().newInstance(); + private static AlterIndexStatement copy(final AlterIndexStatement sqlStatement) { + AlterIndexStatement result = sqlStatement.getClass().getDeclaredConstructor().newInstance(); sqlStatement.getIndex().ifPresent(result::setIndex); sqlStatement.getSimpleTable().ifPresent(result::setSimpleTable); result.addParameterMarkerSegments(sqlStatement.getParameterMarkerSegments()); diff --git a/parser/sql/statement/core/src/main/java/org/apache/shardingsphere/sql/parser/statement/core/statement/ddl/AlterIndexStatement.java b/parser/sql/statement/core/src/main/java/org/apache/shardingsphere/sql/parser/statement/core/statement/ddl/AlterIndexStatement.java index 0d9e8d35264aa..481d18aff54d0 100644 --- a/parser/sql/statement/core/src/main/java/org/apache/shardingsphere/sql/parser/statement/core/statement/ddl/AlterIndexStatement.java +++ b/parser/sql/statement/core/src/main/java/org/apache/shardingsphere/sql/parser/statement/core/statement/ddl/AlterIndexStatement.java @@ -49,6 +49,14 @@ public Optional getIndex() { public Optional getSimpleTable() { return Optional.empty(); } + + /** + * Set simple table segment. + * + * @param simpleTableSegment simple table segment + */ + public void setSimpleTable(final SimpleTableSegment simpleTableSegment) { + } /** * Get rename index segment. diff --git a/parser/sql/statement/type/sqlserver/src/main/java/org/apache/shardingsphere/sql/parser/statement/sqlserver/ddl/SQLServerAlterIndexStatement.java b/parser/sql/statement/type/sqlserver/src/main/java/org/apache/shardingsphere/sql/parser/statement/sqlserver/ddl/SQLServerAlterIndexStatement.java index 5a93b3ffc4eef..76dd0ba562f07 100644 --- a/parser/sql/statement/type/sqlserver/src/main/java/org/apache/shardingsphere/sql/parser/statement/sqlserver/ddl/SQLServerAlterIndexStatement.java +++ b/parser/sql/statement/type/sqlserver/src/main/java/org/apache/shardingsphere/sql/parser/statement/sqlserver/ddl/SQLServerAlterIndexStatement.java @@ -36,4 +36,9 @@ public final class SQLServerAlterIndexStatement extends AlterIndexStatement impl public Optional getSimpleTable() { return Optional.ofNullable(simpleTable); } + + @Override + public void setSimpleTable(final SimpleTableSegment simpleTable) { + this.simpleTable = simpleTable; + } }