This is an automated email from the ASF dual-hosted git repository.
panjuan pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git
The following commit(s) were added to refs/heads/master by this push:
new b79b994 optimize drop table & drop index post validate logic (#10540)
b79b994 is described below
commit b79b994442d39c10bcc1a8e949515b485b227280
Author: Zhengqiang Duan <[email protected]>
AuthorDate: Sat May 29 15:03:40 2021 +0800
optimize drop table & drop index post validate logic (#10540)
* optimize drop table & drop index post validate logic
* modify variable name
* fix rewrite test case
---
.../src/test/resources/sharding/drop.xml | 30 ----
.../ddl/ShardingDDLStatementValidator.java | 14 +-
.../impl/ShardingAlterTableStatementValidator.java | 2 +-
.../ShardingCreateTableStatementValidator.java | 4 +-
.../impl/ShardingDropIndexStatementValidator.java | 12 +-
.../impl/ShardingDropTableStatementValidator.java | 10 +-
.../ShardingCreateTableStatementValidatorTest.java | 8 +-
.../CreateTableStatementSchemaRefresherTest.java | 8 +-
.../impl/MySQLDDLStatementSQLVisitor.java | 4 +-
.../src/main/antlr4/imports/postgresql/BaseRule.g4 | 9 +-
.../main/antlr4/imports/postgresql/DCLStatement.g4 | 10 +-
.../main/antlr4/imports/postgresql/DDLStatement.g4 | 158 +++++++++------------
.../impl/PostgreSQLDDLStatementSQLVisitor.java | 5 +-
.../impl/SQLServerDDLStatementSQLVisitor.java | 3 +-
.../sql/common/extractor/TableExtractor.java | 2 +-
.../handler/ddl/CreateTableStatementHandler.java | 10 +-
.../handler/ddl/DropIndexStatementHandler.java | 18 +++
.../handler/ddl/DropTableStatementHandler.java | 12 +-
.../mysql/ddl/MySQLCreateTableStatement.java | 2 +-
.../mysql/ddl/MySQLDropTableStatement.java | 2 +-
.../ddl/PostgreSQLCreateTableStatement.java | 2 +-
.../ddl/PostgreSQLDropIndexStatement.java | 6 +
.../ddl/PostgreSQLDropTableStatement.java | 2 +-
.../sqlserver/ddl/SQLServerDropIndexStatement.java | 4 +
.../sqlserver/ddl/SQLServerDropTableStatement.java | 2 +-
.../ddl/CreateTableStatementHandlerTest.java | 22 +--
.../handler/ddl/DropTableStatementHandlerTest.java | 28 ++--
27 files changed, 192 insertions(+), 197 deletions(-)
diff --git
a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-rewrite/src/test/resources/sharding/drop.xml
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-rewrite/src/test/resources/sharding/drop.xml
index 9f103f7..cb7a288 100644
---
a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-rewrite/src/test/resources/sharding/drop.xml
+++
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-rewrite/src/test/resources/sharding/drop.xml
@@ -25,11 +25,6 @@
<input sql="DROP TABLE IF EXISTS t_order, t_order_extend" />
<output sql="DROP TABLE IF EXISTS t_order_0, t_order_extend_0" />
</rewrite-assertion>
- <rewrite-assertion
id="drop_table_with_multi_data_node_and_single_data_node_table_for_postgresql"
db-type="PostgreSQL">
- <input sql="DROP TABLE IF EXISTS t_account_detail, t_order" />
- <output sql="DROP TABLE IF EXISTS t_account_detail_0, t_order_0" />
- <output sql="DROP TABLE IF EXISTS t_account_detail_1, t_order_0" />
- </rewrite-assertion>
<rewrite-assertion
id="drop_table_with_multi_data_node_binding_table_for_postgresql"
db-type="PostgreSQL">
<input sql="DROP TABLE IF EXISTS t_account_detail, t_account_detail" />
<output sql="DROP TABLE IF EXISTS t_account_detail_0,
t_account_detail_0" />
@@ -39,20 +34,10 @@
<input sql="DROP TABLE IF EXISTS t_order, t_config" />
<output sql="DROP TABLE IF EXISTS t_order_0, t_config" />
</rewrite-assertion>
- <rewrite-assertion
id="drop_table_with_multi_data_node_and_broadcast_table_for_postgresql"
db-type="PostgreSQL">
- <input sql="DROP TABLE IF EXISTS t_account_detail, t_config" />
- <output sql="DROP TABLE IF EXISTS t_account_detail_0, t_config" />
- <output sql="DROP TABLE IF EXISTS t_account_detail_1, t_config" />
- </rewrite-assertion>
<rewrite-assertion
id="drop_table_with_single_data_node_and_single_table_for_postgresql"
db-type="PostgreSQL">
<input sql="DROP TABLE IF EXISTS t_order, t_single" />
<output sql="DROP TABLE IF EXISTS t_order_0, t_single" />
</rewrite-assertion>
- <rewrite-assertion
id="drop_table_with_multi_data_node_and_single_table_for_postgresql"
db-type="PostgreSQL">
- <input sql="DROP TABLE IF EXISTS t_account_detail, t_single" />
- <output sql="DROP TABLE IF EXISTS t_account_detail_0, t_single" />
- <output sql="DROP TABLE IF EXISTS t_account_detail_1, t_single" />
- </rewrite-assertion>
<rewrite-assertion
id="drop_table_with_broadcast_and_single_data_node_table_for_postgresql"
db-type="PostgreSQL">
<input sql="DROP TABLE IF EXISTS t_config, t_order" />
<output sql="DROP TABLE IF EXISTS t_config, t_order_0" />
@@ -85,11 +70,6 @@
<input sql="DROP TABLE IF EXISTS t_order, t_order_extend" />
<output sql="DROP TABLE IF EXISTS t_order_0, t_order_extend_0" />
</rewrite-assertion>
- <rewrite-assertion
id="drop_table_with_multi_data_node_and_single_data_node_table_for_mysql"
db-type="MySQL">
- <input sql="DROP TABLE IF EXISTS t_account_detail, t_order" />
- <output sql="DROP TABLE IF EXISTS t_account_detail_0, t_order_0" />
- <output sql="DROP TABLE IF EXISTS t_account_detail_1, t_order_0" />
- </rewrite-assertion>
<rewrite-assertion
id="drop_table_with_multi_data_node_binding_table_for_mysql" db-type="MySQL">
<input sql="DROP TABLE IF EXISTS t_account_detail, t_account_detail" />
<output sql="DROP TABLE IF EXISTS t_account_detail_0,
t_account_detail_0" />
@@ -99,20 +79,10 @@
<input sql="DROP TABLE IF EXISTS t_order, t_config" />
<output sql="DROP TABLE IF EXISTS t_order_0, t_config" />
</rewrite-assertion>
- <rewrite-assertion
id="drop_table_with_multi_data_node_and_broadcast_table_for_mysql"
db-type="MySQL">
- <input sql="DROP TABLE IF EXISTS t_account_detail, t_config" />
- <output sql="DROP TABLE IF EXISTS t_account_detail_0, t_config" />
- <output sql="DROP TABLE IF EXISTS t_account_detail_1, t_config" />
- </rewrite-assertion>
<rewrite-assertion
id="drop_table_with_single_data_node_and_single_table_for_mysql"
db-type="MySQL">
<input sql="DROP TABLE IF EXISTS t_order, t_single" />
<output sql="DROP TABLE IF EXISTS t_order_0, t_single" />
</rewrite-assertion>
- <rewrite-assertion
id="drop_table_with_multi_data_node_and_single_table_for_mysql" db-type="MySQL">
- <input sql="DROP TABLE IF EXISTS t_account_detail, t_single" />
- <output sql="DROP TABLE IF EXISTS t_account_detail_0, t_single" />
- <output sql="DROP TABLE IF EXISTS t_account_detail_1, t_single" />
- </rewrite-assertion>
<rewrite-assertion
id="drop_table_with_broadcast_and_single_data_node_table_for_mysql"
db-type="MySQL">
<input sql="DROP TABLE IF EXISTS t_config, t_order" />
<output sql="DROP TABLE IF EXISTS t_config, t_order_0" />
diff --git
a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-route/src/main/java/org/apache/shardingsphere/sharding/route/engine/validator/ddl/ShardingDDLStatementValidator.java
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-route/src/main/java/org/apache/shardingsphere/sharding/route/engine/validator/ddl/ShardingDDLStatementValidator.java
index f38d8a9..22cc14e 100644
---
a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-route/src/main/java/org/apache/shardingsphere/sharding/route/engine/validator/ddl/ShardingDDLStatementValidator.java
+++
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-route/src/main/java/org/apache/shardingsphere/sharding/route/engine/validator/ddl/ShardingDDLStatementValidator.java
@@ -81,17 +81,17 @@ public abstract class ShardingDDLStatementValidator<T
extends DDLStatement> impl
}
/**
- * Judge whether route unit and primary table data node are different size
or not.
+ * Judge whether route unit and data node are different size or not.
*
* @param shardingRule sharding rule
* @param routeContext route context
- * @param primaryTable primary table
- * @return whether route unit and primary table data node are different
size or not
+ * @param tableName table name
+ * @return whether route unit and data node are different size or not
*/
- protected boolean isRouteUnitPrimaryTableDataNodeDifferentSize(final
ShardingRule shardingRule, final RouteContext routeContext, final String
primaryTable) {
- int primaryTableDataNodeSize =
shardingRule.isShardingTable(primaryTable) ||
shardingRule.isBroadcastTable(primaryTable)
- ?
shardingRule.getTableRule(primaryTable).getActualDataNodes().size() : 1;
- return primaryTableDataNodeSize != routeContext.getRouteUnits().size();
+ protected boolean isRouteUnitDataNodeDifferentSize(final ShardingRule
shardingRule, final RouteContext routeContext, final String tableName) {
+ int dataNodeSize = shardingRule.isShardingTable(tableName) ||
shardingRule.isBroadcastTable(tableName)
+ ?
shardingRule.getTableRule(tableName).getActualDataNodes().size() : 1;
+ return dataNodeSize != routeContext.getRouteUnits().size();
}
/**
diff --git
a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-route/src/main/java/org/apache/shardingsphere/sharding/route/engine/validator/ddl/impl/ShardingAlterTableStatementValidator.java
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-route/src/main/java/org/apache/shardingsphere/sharding/route/engine/validator/ddl/impl/ShardingAlterTableStatementValidator.java
index 07d5db7..b9d2e70 100644
---
a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-route/src/main/java/org/apache/shardingsphere/sharding/route/engine/validator/ddl/impl/ShardingAlterTableStatementValidator.java
+++
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-route/src/main/java/org/apache/shardingsphere/sharding/route/engine/validator/ddl/impl/ShardingAlterTableStatementValidator.java
@@ -60,7 +60,7 @@ public final class ShardingAlterTableStatementValidator
extends ShardingDDLState
public void postValidate(final ShardingRule shardingRule, final
SQLStatementContext<AlterTableStatement> sqlStatementContext,
final RouteContext routeContext, final
ShardingSphereSchema schema) {
String primaryTable =
sqlStatementContext.getSqlStatement().getTable().getTableName().getIdentifier().getValue();
- if (isRouteUnitPrimaryTableDataNodeDifferentSize(shardingRule,
routeContext, primaryTable)) {
+ if (isRouteUnitDataNodeDifferentSize(shardingRule, routeContext,
primaryTable)) {
throw new ShardingSphereException("ALTER TABLE ... statement can
not route correctly for tables %s.",
sqlStatementContext.getTablesContext().getTableNames());
}
}
diff --git
a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-route/src/main/java/org/apache/shardingsphere/sharding/route/engine/validator/ddl/impl/ShardingCreateTableStatementValidator.java
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-route/src/main/java/org/apache/shardingsphere/sharding/route/engine/validator/ddl/impl/ShardingCreateTableStatementValidator.java
index d261058..27da253 100644
---
a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-route/src/main/java/org/apache/shardingsphere/sharding/route/engine/validator/ddl/impl/ShardingCreateTableStatementValidator.java
+++
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-route/src/main/java/org/apache/shardingsphere/sharding/route/engine/validator/ddl/impl/ShardingCreateTableStatementValidator.java
@@ -37,7 +37,7 @@ public final class ShardingCreateTableStatementValidator
extends ShardingDDLStat
@Override
public void preValidate(final ShardingRule shardingRule, final
SQLStatementContext<CreateTableStatement> sqlStatementContext,
final List<Object> parameters, final
ShardingSphereSchema schema) {
- if
(!CreateTableStatementHandler.containsIfNotExistClause(sqlStatementContext.getSqlStatement()))
{
+ if
(!CreateTableStatementHandler.containsNotExistClause(sqlStatementContext.getSqlStatement()))
{
validateTableNotExist(schema,
Collections.singletonList(sqlStatementContext.getSqlStatement().getTable()));
}
}
@@ -46,7 +46,7 @@ public final class ShardingCreateTableStatementValidator
extends ShardingDDLStat
public void postValidate(final ShardingRule shardingRule, final
SQLStatementContext<CreateTableStatement> sqlStatementContext,
final RouteContext routeContext, final
ShardingSphereSchema schema) {
String primaryTable =
sqlStatementContext.getSqlStatement().getTable().getTableName().getIdentifier().getValue();
- if (isRouteUnitPrimaryTableDataNodeDifferentSize(shardingRule,
routeContext, primaryTable)) {
+ if (isRouteUnitDataNodeDifferentSize(shardingRule, routeContext,
primaryTable)) {
throw new ShardingSphereException("CREATE TABLE ... statement can
not route correctly for tables %s.",
sqlStatementContext.getTablesContext().getTableNames());
}
}
diff --git
a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-route/src/main/java/org/apache/shardingsphere/sharding/route/engine/validator/ddl/impl/ShardingDropIndexStatementValidator.java
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-route/src/main/java/org/apache/shardingsphere/sharding/route/engine/validator/ddl/impl/ShardingDropIndexStatementValidator.java
index ecc2e55..c5de414 100644
---
a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-route/src/main/java/org/apache/shardingsphere/sharding/route/engine/validator/ddl/impl/ShardingDropIndexStatementValidator.java
+++
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-route/src/main/java/org/apache/shardingsphere/sharding/route/engine/validator/ddl/impl/ShardingDropIndexStatementValidator.java
@@ -25,6 +25,7 @@ import
org.apache.shardingsphere.sharding.route.engine.validator.ddl.ShardingDDL
import org.apache.shardingsphere.sharding.rule.ShardingRule;
import
org.apache.shardingsphere.sql.parser.sql.common.segment.ddl.index.IndexSegment;
import
org.apache.shardingsphere.sql.parser.sql.common.statement.ddl.DropIndexStatement;
+import
org.apache.shardingsphere.sql.parser.sql.dialect.handler.ddl.DropIndexStatementHandler;
import java.util.Collection;
import java.util.List;
@@ -39,6 +40,9 @@ public final class ShardingDropIndexStatementValidator
extends ShardingDDLStatem
@Override
public void preValidate(final ShardingRule shardingRule, final
SQLStatementContext<DropIndexStatement> sqlStatementContext,
final List<Object> parameters, final
ShardingSphereSchema schema) {
+ if
(DropIndexStatementHandler.containsExistClause(sqlStatementContext.getSqlStatement()))
{
+ return;
+ }
for (IndexSegment each :
sqlStatementContext.getSqlStatement().getIndexes()) {
if (!isSchemaContainsIndex(schema, each)) {
throw new ShardingSphereException("Index '%s' does not
exist.", each.getIdentifier().getValue());
@@ -50,9 +54,11 @@ public final class ShardingDropIndexStatementValidator
extends ShardingDDLStatem
public void postValidate(final ShardingRule shardingRule, final
SQLStatementContext<DropIndexStatement> sqlStatementContext,
final RouteContext routeContext, final
ShardingSphereSchema schema) {
Collection<String> indexNames =
sqlStatementContext.getSqlStatement().getIndexes().stream().map(each ->
each.getIdentifier().getValue()).collect(Collectors.toList());
- Optional<String> primaryTable =
schema.getAllTableNames().stream().filter(each ->
schema.get(each).getIndexes().containsKey(indexNames.iterator().next())).findFirst();
- if (primaryTable.isPresent() &&
isRouteUnitPrimaryTableDataNodeDifferentSize(shardingRule, routeContext,
primaryTable.get())) {
- throw new ShardingSphereException("DROP INDEX ... statement can
not route correctly for indexes %s.", indexNames);
+ for (String each : indexNames) {
+ Optional<String> logicTableName =
schema.getAllTableNames().stream().filter(tableName ->
schema.get(tableName).getIndexes().containsKey(each)).findFirst();
+ if (logicTableName.isPresent() &&
isRouteUnitDataNodeDifferentSize(shardingRule, routeContext,
logicTableName.get())) {
+ throw new ShardingSphereException("DROP INDEX ... statement
can not route correctly for indexes %s.", indexNames);
+ }
}
}
}
diff --git
a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-route/src/main/java/org/apache/shardingsphere/sharding/route/engine/validator/ddl/impl/ShardingDropTableStatementValidator.java
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-route/src/main/java/org/apache/shardingsphere/sharding/route/engine/validator/ddl/impl/ShardingDropTableStatementValidator.java
index cd97411..3870690 100644
---
a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-route/src/main/java/org/apache/shardingsphere/sharding/route/engine/validator/ddl/impl/ShardingDropTableStatementValidator.java
+++
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-route/src/main/java/org/apache/shardingsphere/sharding/route/engine/validator/ddl/impl/ShardingDropTableStatementValidator.java
@@ -25,6 +25,7 @@ import
org.apache.shardingsphere.infra.route.context.RouteContext;
import org.apache.shardingsphere.infra.route.context.RouteMapper;
import
org.apache.shardingsphere.sharding.route.engine.validator.ddl.ShardingDDLStatementValidator;
import org.apache.shardingsphere.sharding.rule.ShardingRule;
+import
org.apache.shardingsphere.sql.parser.sql.common.segment.generic.table.SimpleTableSegment;
import
org.apache.shardingsphere.sql.parser.sql.common.statement.ddl.DropTableStatement;
import
org.apache.shardingsphere.sql.parser.sql.dialect.handler.ddl.DropTableStatementHandler;
@@ -42,7 +43,7 @@ public final class ShardingDropTableStatementValidator
extends ShardingDDLStatem
@Override
public void preValidate(final ShardingRule shardingRule, final
SQLStatementContext<DropTableStatement> sqlStatementContext,
final List<Object> parameters, final
ShardingSphereSchema schema) {
- if
(!DropTableStatementHandler.containsIfExistClause(sqlStatementContext.getSqlStatement()))
{
+ if
(!DropTableStatementHandler.containsExistClause(sqlStatementContext.getSqlStatement()))
{
validateTableExist(schema,
sqlStatementContext.getTablesContext().getTables());
}
}
@@ -51,9 +52,10 @@ public final class ShardingDropTableStatementValidator
extends ShardingDDLStatem
public void postValidate(final ShardingRule shardingRule, final
SQLStatementContext<DropTableStatement> sqlStatementContext,
final RouteContext routeContext, final
ShardingSphereSchema schema) {
checkTableInUsed(shardingRule, sqlStatementContext.getSqlStatement(),
routeContext);
- String primaryTable =
sqlStatementContext.getSqlStatement().getTables().iterator().next().getTableName().getIdentifier().getValue();
- if (isRouteUnitPrimaryTableDataNodeDifferentSize(shardingRule,
routeContext, primaryTable)) {
- throw new ShardingSphereException("DROP TABLE ... statement can
not route correctly for tables %s.",
sqlStatementContext.getTablesContext().getTableNames());
+ for (SimpleTableSegment each :
sqlStatementContext.getSqlStatement().getTables()) {
+ if (isRouteUnitDataNodeDifferentSize(shardingRule, routeContext,
each.getTableName().getIdentifier().getValue())) {
+ throw new ShardingSphereException("DROP TABLE ... statement
can not route correctly for tables %s.",
sqlStatementContext.getTablesContext().getTableNames());
+ }
}
}
diff --git
a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-route/src/test/java/org/apache/shardingsphere/sharding/route/engine/validator/ddl/ShardingCreateTableStatementValidatorTest.java
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-route/src/test/java/org/apache/shardingsphere/sharding/route/engine/validator/ddl/ShardingCreateTableStatementValidatorTest.java
index ccc836d..54055f7 100644
---
a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-route/src/test/java/org/apache/shardingsphere/sharding/route/engine/validator/ddl/ShardingCreateTableStatementValidatorTest.java
+++
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-route/src/test/java/org/apache/shardingsphere/sharding/route/engine/validator/ddl/ShardingCreateTableStatementValidatorTest.java
@@ -65,7 +65,7 @@ public final class ShardingCreateTableStatementValidatorTest {
public void assertValidateMySQLCreateTable() {
MySQLCreateTableStatement sqlStatement = new
MySQLCreateTableStatement();
sqlStatement.setTable(new SimpleTableSegment(1, 2, new
IdentifierValue("t_order")));
- sqlStatement.setNotExisted(false);
+ sqlStatement.setContainsNotExistClause(false);
assertValidateCreateTable(sqlStatement);
}
@@ -80,7 +80,7 @@ public final class ShardingCreateTableStatementValidatorTest {
public void assertValidatePostgreSQLCreateTable() {
PostgreSQLCreateTableStatement sqlStatement = new
PostgreSQLCreateTableStatement();
sqlStatement.setTable(new SimpleTableSegment(1, 2, new
IdentifierValue("t_order")));
- sqlStatement.setNotExisted(false);
+ sqlStatement.setContainsNotExistClause(false);
assertValidateCreateTable(sqlStatement);
}
@@ -109,7 +109,7 @@ public final class
ShardingCreateTableStatementValidatorTest {
public void assertValidateMySQLCreateTableIfNotExists() {
MySQLCreateTableStatement sqlStatement = new
MySQLCreateTableStatement();
sqlStatement.setTable(new SimpleTableSegment(1, 2, new
IdentifierValue("t_order")));
- sqlStatement.setNotExisted(true);
+ sqlStatement.setContainsNotExistClause(true);
assertValidateCreateTableIfNotExists(sqlStatement);
}
@@ -117,7 +117,7 @@ public final class
ShardingCreateTableStatementValidatorTest {
public void assertValidatePostgreSQLCreateTableIfNotExists() {
PostgreSQLCreateTableStatement sqlStatement = new
PostgreSQLCreateTableStatement();
sqlStatement.setTable(new SimpleTableSegment(1, 2, new
IdentifierValue("t_order")));
- sqlStatement.setNotExisted(true);
+ sqlStatement.setContainsNotExistClause(true);
assertValidateCreateTableIfNotExists(sqlStatement);
}
diff --git
a/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/metadata/schema/refresher/type/CreateTableStatementSchemaRefresherTest.java
b/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/metadata/schema/refresher/type/CreateTableStatementSchemaRefresherTest.java
index 7a10a62..15f8378 100644
---
a/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/metadata/schema/refresher/type/CreateTableStatementSchemaRefresherTest.java
+++
b/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/metadata/schema/refresher/type/CreateTableStatementSchemaRefresherTest.java
@@ -62,7 +62,7 @@ public final class CreateTableStatementSchemaRefresherTest {
@Test
public void refreshForMySQL() throws SQLException {
MySQLCreateTableStatement createTableStatement = new
MySQLCreateTableStatement();
- createTableStatement.setNotExisted(false);
+ createTableStatement.setContainsNotExistClause(false);
when(materials.getDatabaseType()).thenReturn(new MySQLDatabaseType());
refresh(createTableStatement);
}
@@ -77,7 +77,7 @@ public final class CreateTableStatementSchemaRefresherTest {
@Test
public void refreshForPostgreSQL() throws SQLException {
PostgreSQLCreateTableStatement createTableStatement = new
PostgreSQLCreateTableStatement();
- createTableStatement.setNotExisted(false);
+ createTableStatement.setContainsNotExistClause(false);
when(materials.getDatabaseType()).thenReturn(new
PostgreSQLDatabaseType());
refresh(createTableStatement);
}
@@ -99,7 +99,7 @@ public final class CreateTableStatementSchemaRefresherTest {
@Test
public void refreshWithTableRuleForMySQL() throws SQLException {
MySQLCreateTableStatement createTableStatement = new
MySQLCreateTableStatement();
- createTableStatement.setNotExisted(false);
+ createTableStatement.setContainsNotExistClause(false);
when(materials.getDatabaseType()).thenReturn(new MySQLDatabaseType());
refreshWithTableRule(createTableStatement);
}
@@ -114,7 +114,7 @@ public final class CreateTableStatementSchemaRefresherTest {
@Test
public void refreshWithTableRuleForPostgreSQL() throws SQLException {
PostgreSQLCreateTableStatement createTableStatement = new
PostgreSQLCreateTableStatement();
- createTableStatement.setNotExisted(false);
+ createTableStatement.setContainsNotExistClause(false);
when(materials.getDatabaseType()).thenReturn(new
PostgreSQLDatabaseType());
refreshWithTableRule(createTableStatement);
}
diff --git
a/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-mysql/src/main/java/org/apache/shardingsphere/sql/parser/mysql/visitor/statement/impl/MySQLDDLStatementSQLVisitor.java
b/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-mysql/src/main/java/org/apache/shardingsphere/sql/parser/mysql/visitor/statement/impl/MySQLDDLStatementSQLVisitor.java
index 9bcc6b9..63a535e 100644
---
a/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-mysql/src/main/java/org/apache/shardingsphere/sql/parser/mysql/visitor/statement/impl/MySQLDDLStatementSQLVisitor.java
+++
b/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-mysql/src/main/java/org/apache/shardingsphere/sql/parser/mysql/visitor/statement/impl/MySQLDDLStatementSQLVisitor.java
@@ -202,7 +202,7 @@ public final class MySQLDDLStatementSQLVisitor extends
MySQLStatementSQLVisitor
public ASTNode visitCreateTable(final CreateTableContext ctx) {
MySQLCreateTableStatement result = new MySQLCreateTableStatement();
result.setTable((SimpleTableSegment) visit(ctx.tableName()));
- result.setNotExisted(null != ctx.notExistClause());
+ result.setContainsNotExistClause(null != ctx.notExistClause());
if (null != ctx.createDefinitionClause()) {
CollectionValue<CreateDefinitionSegment> createDefinitions =
(CollectionValue<CreateDefinitionSegment>) visit(ctx.createDefinitionClause());
for (CreateDefinitionSegment each : createDefinitions.getValue()) {
@@ -437,7 +437,7 @@ public final class MySQLDDLStatementSQLVisitor extends
MySQLStatementSQLVisitor
public ASTNode visitDropTable(final DropTableContext ctx) {
MySQLDropTableStatement result = new MySQLDropTableStatement();
result.getTables().addAll(((CollectionValue<SimpleTableSegment>)
visit(ctx.tableList())).getValue());
- result.setContainsIfExistClause(null != ctx.existClause());
+ result.setContainsExistClause(null != ctx.existClause());
return result;
}
diff --git
a/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-postgresql/src/main/antlr4/imports/postgresql/BaseRule.g4
b/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-postgresql/src/main/antlr4/imports/postgresql/BaseRule.g4
index 2bf7428..856abc0 100644
---
a/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-postgresql/src/main/antlr4/imports/postgresql/BaseRule.g4
+++
b/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-postgresql/src/main/antlr4/imports/postgresql/BaseRule.g4
@@ -1831,4 +1831,11 @@ event
typeNameList
: typeName (COMMA_ typeName)*
;
-
+
+notExistClause
+ : IF NOT EXISTS
+ ;
+
+existClause
+ : IF EXISTS
+ ;
diff --git
a/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-postgresql/src/main/antlr4/imports/postgresql/DCLStatement.g4
b/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-postgresql/src/main/antlr4/imports/postgresql/DCLStatement.g4
index a42d49e..10fa494 100644
---
a/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-postgresql/src/main/antlr4/imports/postgresql/DCLStatement.g4
+++
b/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-postgresql/src/main/antlr4/imports/postgresql/DCLStatement.g4
@@ -120,7 +120,7 @@ alterOptRoleElem
;
dropUser
- : DROP USER (IF EXISTS)? roleList
+ : DROP USER existClause? roleList
;
alterUser
@@ -143,7 +143,7 @@ createRole
;
dropRole
- : DROP ROLE (IF EXISTS)? roleList
+ : DROP ROLE existClause? roleList
;
alterRole
@@ -159,7 +159,7 @@ createGroup
;
createSchema
- : CREATE SCHEMA (IF NOT EXISTS)? createSchemaClauses
+ : CREATE SCHEMA notExistClause? createSchemaClauses
;
createSchemaClauses
@@ -176,11 +176,11 @@ schemaStmt
;
dropDroup
- : DROP GROUP (IF EXISTS)? roleList
+ : DROP GROUP existClause? roleList
;
dropSchema
- : DROP SCHEMA (IF EXISTS)? nameList dropBehavior?
+ : DROP SCHEMA existClause? nameList dropBehavior?
;
reassignOwned
diff --git
a/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-postgresql/src/main/antlr4/imports/postgresql/DDLStatement.g4
b/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-postgresql/src/main/antlr4/imports/postgresql/DDLStatement.g4
index 7738ec2..3d89495 100644
---
a/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-postgresql/src/main/antlr4/imports/postgresql/DDLStatement.g4
+++
b/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-postgresql/src/main/antlr4/imports/postgresql/DDLStatement.g4
@@ -20,7 +20,7 @@ grammar DDLStatement;
import Symbol, Keyword, PostgreSQLKeyword, Literals, BaseRule, DMLStatement;
createTable
- : CREATE createTableSpecification TABLE tableNotExistClause? tableName
+ : CREATE createTableSpecification TABLE notExistClause? tableName
(createDefinitionClause | (OF anyName (LP_ typedTableElementList RP_)?)
| (PARTITION OF qualifiedName (LP_ typedTableElementList RP_)?
partitionBoundSpec))
inheritClause partitionSpec? tableAccessMethodClause? withOption?
onCommitOption? tableSpace?
(AS select withData?)?
@@ -88,7 +88,7 @@ accessMethod
;
createIndex
- : CREATE createIndexSpecification INDEX concurrentlyClause
(indexNotExistClause indexName)? ON onlyClause tableName
+ : CREATE createIndexSpecification INDEX concurrentlyClause
(notExistClause? indexName)? ON onlyClause tableName
accessMethodClause? LP_ indexParams RP_ include? (WITH reloptions)?
tableSpace? whereClause?
;
@@ -125,7 +125,7 @@ columnElem
;
dropDatabase
- : DROP DATABASE (IF EXISTS)? name
+ : DROP DATABASE existClause? name
;
createDatabaseSpecification
@@ -144,16 +144,16 @@ createdbOptName
alterTable
: ALTER TABLE
- ( tableExistClause onlyClause tableNameClause alterDefinitionClause
+ ( existClause? onlyClause tableNameClause alterDefinitionClause
| ALL IN TABLESPACE tableNameClause (OWNED BY roleList)? SET TABLESPACE
name NOWAIT?)
;
alterIndex
- : ALTER INDEX (indexExistClause | ALL IN TABLESPACE) indexName
alterIndexDefinitionClause
+ : ALTER INDEX (existClause? | ALL IN TABLESPACE) indexName
alterIndexDefinitionClause
;
dropTable
- : DROP TABLE tableExistClause tableNames dropTableOpt?
+ : DROP TABLE existClause? tableNames dropTableOpt?
;
dropTableOpt
@@ -161,7 +161,7 @@ dropTableOpt
;
dropIndex
- : DROP INDEX concurrentlyClause indexExistClause indexNames dropIndexOpt?
+ : DROP INDEX concurrentlyClause existClause? indexNames dropIndexOpt?
;
dropIndexOpt
@@ -181,10 +181,6 @@ createTableSpecification
: ((GLOBAL | LOCAL)? (TEMPORARY | TEMP) | UNLOGGED)?
;
-tableNotExistClause
- : IF NOT EXISTS
- ;
-
createDefinitionClause
: LP_ (createDefinition (COMMA_ createDefinition)*)? RP_
;
@@ -319,18 +315,10 @@ concurrentlyClause
: CONCURRENTLY?
;
-indexNotExistClause
- : (IF NOT EXISTS)?
- ;
-
onlyClause
: ONLY?
;
-tableExistClause
- : (IF EXISTS)?
- ;
-
asteriskClause
: ASTERISK_?
;
@@ -388,7 +376,7 @@ alterTableAction
| addConstraintSpecification
| ALTER CONSTRAINT ignoredIdentifier constraintOptionalParam
| VALIDATE CONSTRAINT ignoredIdentifier
- | DROP CONSTRAINT indexExistClause ignoredIdentifier (RESTRICT | CASCADE)?
+ | DROP CONSTRAINT existClause? ignoredIdentifier (RESTRICT | CASCADE)?
| (DISABLE | ENABLE) TRIGGER (ignoredIdentifier | ALL | USER)?
| ENABLE (REPLICA | ALWAYS) TRIGGER ignoredIdentifier
| (DISABLE | ENABLE) RULE ignoredIdentifier
@@ -410,15 +398,11 @@ alterTableAction
;
addColumnSpecification
- : ADD COLUMN? (IF NOT EXISTS)? columnDefinition
+ : ADD COLUMN? notExistClause? columnDefinition
;
dropColumnSpecification
- : DROP COLUMN? columnExistClause columnName (RESTRICT | CASCADE)?
- ;
-
-columnExistClause
- : (IF EXISTS)?
+ : DROP COLUMN? existClause? columnName (RESTRICT | CASCADE)?
;
modifyColumnSpecification
@@ -428,7 +412,7 @@ modifyColumnSpecification
| modifyColumn (SET | DROP) NOT NULL
| modifyColumn ADD GENERATED (ALWAYS | (BY DEFAULT)) AS IDENTITY (LP_
sequenceOptions RP_)?
| modifyColumn alterColumnSetOption alterColumnSetOption*
- | modifyColumn DROP IDENTITY columnExistClause
+ | modifyColumn DROP IDENTITY existClause?
| modifyColumn SET STATISTICS NUMBER_
| modifyColumn SET LP_ attributeOptions RP_
| modifyColumn RESET LP_ attributeOptions RP_
@@ -479,10 +463,6 @@ renameTableSpecification
: RENAME TO identifier
;
-indexExistClause
- : (IF EXISTS)?
- ;
-
indexNames
: indexName (COMMA_ indexName)*
;
@@ -514,7 +494,7 @@ alterTableCmds
;
alterTableCmd
- : ADD COLUMN? (IF NOT EXISTS)? columnDef
+ : ADD COLUMN? notExistClause? columnDef
| ALTER COLUMN? colId alterColumnDefault
| ALTER COLUMN? colId DROP NOT NULL
| ALTER COLUMN? colId SET NOT NULL
@@ -526,15 +506,15 @@ alterTableCmd
| ALTER COLUMN? colId ADD GENERATED generatedWhen AS IDENTITY
parenthesizedSeqOptList?
| ALTER COLUMN? colId alterIdentityColumnOptionList
| ALTER COLUMN? colId DROP IDENTITY
- | ALTER COLUMN? colId DROP IDENTITY IF EXISTS
- | DROP COLUMN? IF EXISTS colId dropBehavior?
+ | ALTER COLUMN? colId DROP IDENTITY existClause
+ | DROP COLUMN? existClause colId dropBehavior?
| DROP COLUMN? colId dropBehavior?
| ALTER COLUMN? colId setData? TYPE typeName collateClause? alterUsing?
| ALTER COLUMN? colId alterGenericOptions
| ADD tableConstraint
| ALTER CONSTRAINT name constraintAttributeSpec
| VALIDATE CONSTRAINT name
- | DROP CONSTRAINT IF EXISTS name dropBehavior?
+ | DROP CONSTRAINT existClause name dropBehavior?
| DROP CONSTRAINT name dropBehavior?
| SET WITHOUT OIDS
| CLUSTER ON name
@@ -812,7 +792,7 @@ alterDomain
alterDomainClause
: anyName (SET | DROP) NOT NULL
| anyName ADD tableConstraint
- | anyName DROP CONSTRAINT (IF EXISTS)? name dropBehavior?
+ | anyName DROP CONSTRAINT existClause? name dropBehavior?
| anyName VALIDATE CONSTRAINT name
| anyName RENAME CONSTRAINT constraintName TO constraintName
| anyName OWNER TO roleSpec
@@ -956,11 +936,11 @@ alterMaterializedView
;
alterMaterializedViewClauses
- : (IF EXISTS)? qualifiedName alterTableCmds
+ : existClause? qualifiedName alterTableCmds
| qualifiedName DEPENDS ON EXTENSION name
- | (IF EXISTS)? qualifiedName RENAME COLUMN? columnName TO columnName
- | (IF EXISTS)? qualifiedName RENAME TO qualifiedName
- | (IF EXISTS)? qualifiedName SET SCHEMA schemaName
+ | existClause? qualifiedName RENAME COLUMN? columnName TO columnName
+ | existClause? qualifiedName RENAME TO qualifiedName
+ | existClause? qualifiedName SET SCHEMA schemaName
| ALL IN TABLESPACE name (OWNED BY roleList) SET TABLESPACE name NOWAIT?
;
@@ -984,7 +964,7 @@ executeStmt
;
createMaterializedView
- : CREATE UNLOGGED? MATERIALIZED VIEW (IF NOT EXISTS)? createMvTarget AS
select (WITH DATA | WITH NO DATA)?
+ : CREATE UNLOGGED? MATERIALIZED VIEW notExistClause? createMvTarget AS
select (WITH DATA | WITH NO DATA)?
;
createMvTarget
@@ -996,7 +976,7 @@ refreshMatViewStmt
;
alterPolicy
- : ALTER POLICY (IF EXISTS)? name ON qualifiedName alterPolicyClauses
+ : ALTER POLICY existClause? name ON qualifiedName alterPolicyClauses
;
alterPolicyClauses
@@ -1049,7 +1029,7 @@ alterRule
;
alterSequence
- : ALTER SEQUENCE (IF EXISTS)? qualifiedName alterSequenceClauses
+ : ALTER SEQUENCE existClause? qualifiedName alterSequenceClauses
;
alterSequenceClauses
@@ -1071,7 +1051,7 @@ foreignServerVersion
alterStatistics
: ALTER STATISTICS
- ( (IF EXISTS)? anyName SET STATISTICS signedIconst
+ ( existClause? anyName SET STATISTICS signedIconst
| anyName RENAME TO name
| anyName SET SCHEMA name
| anyName OWNER TO roleSpec)
@@ -1117,7 +1097,7 @@ alterTextSearchConfigurationClauses
| OWNER TO roleSpec
| (ADD | ALTER) MAPPING FOR nameList WITH? anyNameList
| ALTER MAPPING (FOR nameList)? REPLACE anyName WITH anyName
- | DROP MAPPING (IF EXISTS)? FOR nameList
+ | DROP MAPPING existClause? FOR nameList
;
anyNameList
@@ -1150,7 +1130,7 @@ alterType
alterTypeClauses
: alterTypeCmds
- | ADD VALUE (IF NOT EXISTS)? STRING_ ((BEFORE | AFTER) STRING_)?
+ | ADD VALUE notExistClause? STRING_ ((BEFORE | AFTER) STRING_)?
| RENAME VALUE STRING_ TO STRING_
| RENAME TO name
| RENAME ATTRIBUTE name TO name dropBehavior?
@@ -1165,7 +1145,7 @@ alterTypeCmds
alterTypeCmd
: ADD ATTRIBUTE tableFuncElement dropBehavior?
- | DROP ATTRIBUTE IF EXISTS colId dropBehavior?
+ | DROP ATTRIBUTE existClause colId dropBehavior?
| DROP ATTRIBUTE colId dropBehavior?
| ALTER ATTRIBUTE colId setData? TYPE typeName collateClause? dropBehavior?
;
@@ -1179,7 +1159,7 @@ authIdent
;
alterView
- : ALTER VIEW (IF EXISTS)? qualifiedName alterViewClauses
+ : ALTER VIEW existClause? qualifiedName alterViewClauses
;
alterViewClauses
@@ -1301,7 +1281,7 @@ castContext
;
createCollation
- : CREATE COLLATION (IF NOT EXISTS)? (anyName definition | anyName FROM
anyName)
+ : CREATE COLLATION notExistClause? (anyName definition | anyName FROM
anyName)
;
createConversion
@@ -1329,7 +1309,7 @@ eventTriggerValueList
;
createExtension
- : CREATE EXTENSION (IF NOT EXISTS)? name WITH? createExtensionOptList
+ : CREATE EXTENSION notExistClause? name WITH? createExtensionOptList
;
createExtensionOptList
@@ -1352,9 +1332,9 @@ createForeignTable
;
createForeignTableClauses
- : (IF NOT EXISTS)? qualifiedName LP_ tableElementList? RP_
+ : notExistClause? qualifiedName LP_ tableElementList? RP_
(INHERITS LP_ qualifiedNameList RP_)? SERVER name createGenericOptions?
- | (IF NOT EXISTS)? qualifiedName PARTITION OF qualifiedName (LP_
typedTableElementList RP_)? partitionBoundSpec
+ | notExistClause? qualifiedName PARTITION OF qualifiedName (LP_
typedTableElementList RP_)? partitionBoundSpec
SERVER name createGenericOptions?
;
@@ -1561,7 +1541,7 @@ transitionOldOrNew
;
createSequence
- : CREATE tempOption? SEQUENCE (IF NOT EXISTS)? qualifiedName seqOptList?
+ : CREATE tempOption? SEQUENCE notExistClause? qualifiedName seqOptList?
;
tempOption
@@ -1569,11 +1549,11 @@ tempOption
;
createServer
- : CREATE SERVER (IF NOT EXISTS)? name (TYPE STRING_)?
foreignServerVersion? FOREIGN DATA WRAPPER name createGenericOptions
+ : CREATE SERVER notExistClause? name (TYPE STRING_)? foreignServerVersion?
FOREIGN DATA WRAPPER name createGenericOptions
;
createStatistics
- : CREATE STATISTICS (IF NOT EXISTS)? anyName optNameList ON exprList FROM
fromList
+ : CREATE STATISTICS notExistClause? anyName optNameList ON exprList FROM
fromList
;
createSubscription
@@ -1608,7 +1588,7 @@ enumValList
;
createUserMapping
- : CREATE USER MAPPING (IF NOT EXISTS)? FOR authIdent SERVER name
createGenericOptions
+ : CREATE USER MAPPING notExistClause? FOR authIdent SERVER name
createGenericOptions
;
discard
@@ -1616,11 +1596,11 @@ discard
;
dropAccessMethod
- : DROP ACCESS METHOD (IF EXISTS)? name dropBehavior?
+ : DROP ACCESS METHOD existClause? name dropBehavior?
;
dropAggregate
- : DROP AGGREGATE (IF EXISTS)? aggregateWithArgtypesList dropBehavior?
+ : DROP AGGREGATE existClause? aggregateWithArgtypesList dropBehavior?
;
aggregateWithArgtypesList
@@ -1628,39 +1608,39 @@ aggregateWithArgtypesList
;
dropCast
- : DROP CAST (IF EXISTS)? LP_ typeName AS typeName RP_ dropBehavior?
+ : DROP CAST existClause? LP_ typeName AS typeName RP_ dropBehavior?
;
dropCollation
- : DROP COLLATION (IF EXISTS)? name dropBehavior?
+ : DROP COLLATION existClause? name dropBehavior?
;
dropConversion
- : DROP CONVERSION (IF EXISTS)? name dropBehavior?
+ : DROP CONVERSION existClause? name dropBehavior?
;
dropDomain
- : DROP DOMAIN (IF EXISTS)? nameList dropBehavior?
+ : DROP DOMAIN existClause? nameList dropBehavior?
;
dropEventTrigger
- : DROP EVENT TRIGGER (IF EXISTS)? name dropBehavior?
+ : DROP EVENT TRIGGER existClause? name dropBehavior?
;
dropExtension
- : DROP EXTENSION (IF EXISTS)? nameList dropBehavior?
+ : DROP EXTENSION existClause? nameList dropBehavior?
;
dropForeignDataWrapper
- : DROP FOREIGN DATA WRAPPER (IF EXISTS)? nameList dropBehavior?
+ : DROP FOREIGN DATA WRAPPER existClause? nameList dropBehavior?
;
dropForeignTable
- : DROP FOREIGN TABLE (IF EXISTS)? tableName (COMMA_ tableName)*
dropBehavior?
+ : DROP FOREIGN TABLE existClause? tableName (COMMA_ tableName)*
dropBehavior?
;
dropFunction
- : DROP FUNCTION (IF EXISTS)? functionWithArgtypesList dropBehavior?
+ : DROP FUNCTION existClause? functionWithArgtypesList dropBehavior?
;
functionWithArgtypesList
@@ -1668,15 +1648,15 @@ functionWithArgtypesList
;
dropLanguage
- : DROP PROCEDURAL? LANGUAGE (IF EXISTS)? name dropBehavior?
+ : DROP PROCEDURAL? LANGUAGE existClause? name dropBehavior?
;
dropMaterializedView
- : DROP MATERIALIZED VIEW (IF EXISTS)? anyNameList dropBehavior?
+ : DROP MATERIALIZED VIEW existClause? anyNameList dropBehavior?
;
dropOperator
- : DROP OPERATOR (IF EXISTS)? operatorWithArgtypesList dropBehavior?
+ : DROP OPERATOR existClause? operatorWithArgtypesList dropBehavior?
;
operatorWithArgtypesList
@@ -1684,11 +1664,11 @@ operatorWithArgtypesList
;
dropOperatorClass
- : DROP OPERATOR CLASS (IF EXISTS)? anyName USING name dropBehavior?
+ : DROP OPERATOR CLASS existClause? anyName USING name dropBehavior?
;
dropOperatorFamily
- : DROP OPERATOR FAMILY (IF EXISTS)? anyName USING name dropBehavior?
+ : DROP OPERATOR FAMILY existClause? anyName USING name dropBehavior?
;
dropOwned
@@ -1696,67 +1676,67 @@ dropOwned
;
dropPolicy
- : DROP POLICY (IF EXISTS)? name ON tableName dropBehavior?
+ : DROP POLICY existClause? name ON tableName dropBehavior?
;
dropProcedure
- : DROP PROCEDURE (IF EXISTS)? functionWithArgtypesList dropBehavior?
+ : DROP PROCEDURE existClause? functionWithArgtypesList dropBehavior?
;
dropPublication
- : DROP PUBLICATION (IF EXISTS)? anyNameList dropBehavior?
+ : DROP PUBLICATION existClause? anyNameList dropBehavior?
;
dropRoutine
- : DROP ROUTINE (IF EXISTS)? functionWithArgtypesList dropBehavior?
+ : DROP ROUTINE existClause? functionWithArgtypesList dropBehavior?
;
dropRule
- : DROP RULE (IF EXISTS)? name ON tableName dropBehavior?
+ : DROP RULE existClause? name ON tableName dropBehavior?
;
dropSequence
- : DROP SEQUENCE (IF EXISTS)? qualifiedNameList dropBehavior?
+ : DROP SEQUENCE existClause? qualifiedNameList dropBehavior?
;
dropServer
- : DROP SERVER (IF EXISTS)? qualifiedNameList dropBehavior?
+ : DROP SERVER existClause? qualifiedNameList dropBehavior?
;
dropStatistics
- : DROP STATISTICS (IF EXISTS)? qualifiedNameList
+ : DROP STATISTICS existClause? qualifiedNameList
;
dropSubscription
- : DROP SUBSCRIPTION (IF EXISTS)? qualifiedName dropBehavior?
+ : DROP SUBSCRIPTION existClause? qualifiedName dropBehavior?
;
dropTablespace
- : DROP TABLESPACE (IF EXISTS)? qualifiedName
+ : DROP TABLESPACE existClause? qualifiedName
;
dropTextSearch
- : DROP TEXT SEARCH (CONFIGURATION | DICTIONARY | PARSER | TEMPLATE) (IF
EXISTS)? name dropBehavior?
+ : DROP TEXT SEARCH (CONFIGURATION | DICTIONARY | PARSER | TEMPLATE)
existClause? name dropBehavior?
;
dropTransform
- : DROP TRANSFORM (IF EXISTS)? FOR typeName LANGUAGE name dropBehavior?
+ : DROP TRANSFORM existClause? FOR typeName LANGUAGE name dropBehavior?
;
dropTrigger
- : DROP TRIGGER (IF EXISTS)? qualifiedName ON tableName dropBehavior?
+ : DROP TRIGGER existClause? qualifiedName ON tableName dropBehavior?
;
dropType
- : DROP TYPE (IF EXISTS)? anyNameList dropBehavior?
+ : DROP TYPE existClause? anyNameList dropBehavior?
;
dropUserMapping
- : DROP USER MAPPING (IF EXISTS)? FOR authIdent SERVER name
+ : DROP USER MAPPING existClause? FOR authIdent SERVER name
;
dropView
- : DROP VIEW (IF EXISTS)? nameList dropBehavior?
+ : DROP VIEW existClause? nameList dropBehavior?
;
importForeignSchema
@@ -1823,7 +1803,7 @@ reindexTargetType
;
alterForeignTable
- : ALTER FOREIGN TABLE (IF EXISTS)? relationExpr alterForeignTableClauses
+ : ALTER FOREIGN TABLE existClause? relationExpr alterForeignTableClauses
;
alterForeignTableClauses
diff --git
a/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-postgresql/src/main/java/org/apache/shardingsphere/sql/parser/postgresql/visitor/statement/impl/PostgreSQLDDLStatementSQLVisitor.java
b/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-postgresql/src/main/java/org/apache/shardingsphere/sql/parser/postgresql/visitor/statement/impl/PostgreSQLDDLStatementSQLVisitor.java
index dcb5c58..90e4a5e 100644
---
a/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-postgresql/src/main/java/org/apache/shardingsphere/sql/parser/postgresql/visitor/statement/impl/PostgreSQLDDLStatementSQLVisitor.java
+++
b/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-postgresql/src/main/java/org/apache/shardingsphere/sql/parser/postgresql/visitor/statement/impl/PostgreSQLDDLStatementSQLVisitor.java
@@ -123,7 +123,7 @@ public final class PostgreSQLDDLStatementSQLVisitor extends
PostgreSQLStatementS
public ASTNode visitCreateTable(final CreateTableContext ctx) {
PostgreSQLCreateTableStatement result = new
PostgreSQLCreateTableStatement();
result.setTable((SimpleTableSegment) visit(ctx.tableName()));
- result.setNotExisted(null != ctx.tableNotExistClause());
+ result.setContainsNotExistClause(null != ctx.notExistClause());
if (null != ctx.createDefinitionClause()) {
CollectionValue<CreateDefinitionSegment> createDefinitions =
(CollectionValue<CreateDefinitionSegment>) visit(ctx.createDefinitionClause());
for (CreateDefinitionSegment each : createDefinitions.getValue()) {
@@ -281,7 +281,7 @@ public final class PostgreSQLDDLStatementSQLVisitor extends
PostgreSQLStatementS
public ASTNode visitDropTable(final DropTableContext ctx) {
PostgreSQLDropTableStatement result = new
PostgreSQLDropTableStatement();
result.getTables().addAll(((CollectionValue<SimpleTableSegment>)
visit(ctx.tableNames())).getValue());
- result.setContainsIfExistClause(null != ctx.tableExistClause());
+ result.setContainsExistClause(null != ctx.existClause());
return result;
}
@@ -318,6 +318,7 @@ public final class PostgreSQLDDLStatementSQLVisitor extends
PostgreSQLStatementS
public ASTNode visitDropIndex(final DropIndexContext ctx) {
PostgreSQLDropIndexStatement result = new
PostgreSQLDropIndexStatement();
result.getIndexes().addAll(((CollectionValue<IndexSegment>)
visit(ctx.indexNames())).getValue());
+ result.setContainsExistClause(null != ctx.existClause());
return result;
}
diff --git
a/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-sqlserver/src/main/java/org/apache/shardingsphere/sql/parser/sqlserver/visitor/statement/impl/SQLServerDDLStatementSQLVisitor.java
b/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-sqlserver/src/main/java/org/apache/shardingsphere/sql/parser/sqlserver/visitor/statement/impl/SQLServerDDLStatementSQLVisitor.java
index 79034b0..3dd0839 100644
---
a/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-sqlserver/src/main/java/org/apache/shardingsphere/sql/parser/sqlserver/visitor/statement/impl/SQLServerDDLStatementSQLVisitor.java
+++
b/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-sqlserver/src/main/java/org/apache/shardingsphere/sql/parser/sqlserver/visitor/statement/impl/SQLServerDDLStatementSQLVisitor.java
@@ -239,7 +239,7 @@ public final class SQLServerDDLStatementSQLVisitor extends
SQLServerStatementSQL
public ASTNode visitDropTable(final DropTableContext ctx) {
SQLServerDropTableStatement result = new SQLServerDropTableStatement();
result.getTables().addAll(((CollectionValue<SimpleTableSegment>)
visit(ctx.tableNames())).getValue());
- result.setContainsIfExistClause(null != ctx.ifExist());
+ result.setContainsExistClause(null != ctx.ifExist());
return result;
}
@@ -273,6 +273,7 @@ public final class SQLServerDDLStatementSQLVisitor extends
SQLServerStatementSQL
SQLServerDropIndexStatement result = new SQLServerDropIndexStatement();
result.getIndexes().add((IndexSegment) visit(ctx.indexName()));
result.setTable((SimpleTableSegment) visit(ctx.tableName()));
+ result.setContainsExistClause(null != ctx.ifExist());
return result;
}
}
diff --git
a/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/common/extractor/TableExtractor.java
b/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/common/extractor/TableExtractor.java
index 1106566..b2c46cb 100644
---
a/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/common/extractor/TableExtractor.java
+++
b/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/common/extractor/TableExtractor.java
@@ -303,7 +303,7 @@ public final class TableExtractor {
Collection<SimpleTableSegment> result = new LinkedList<>();
for (ValidStatementSegment each : routineBody.getValidStatements()) {
Optional<CreateTableStatement> createTable = each.getCreateTable();
- if (createTable.isPresent() &&
!CreateTableStatementHandler.containsIfNotExistClause(createTable.get())) {
+ if (createTable.isPresent() &&
!CreateTableStatementHandler.containsNotExistClause(createTable.get())) {
result.add(createTable.get().getTable());
}
}
diff --git
a/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/dialect/handler/ddl/CreateTableStatementHandler.java
b/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/dialect/handler/ddl/CreateTableStatementHandler.java
index d4332a9..0b70f43 100644
---
a/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/dialect/handler/ddl/CreateTableStatementHandler.java
+++
b/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/dialect/handler/ddl/CreateTableStatementHandler.java
@@ -33,17 +33,17 @@ import
org.apache.shardingsphere.sql.parser.sql.dialect.statement.postgresql.ddl
public final class CreateTableStatementHandler implements SQLStatementHandler {
/**
- * Judge whether contains if not exist clause.
+ * Judge whether contains not exist clause or not.
*
* @param createTableStatement create table statement
- * @return contains if not exist clause or not
+ * @return whether contains not exist clause or not
*/
- public static boolean containsIfNotExistClause(final CreateTableStatement
createTableStatement) {
+ public static boolean containsNotExistClause(final CreateTableStatement
createTableStatement) {
if (createTableStatement instanceof MySQLStatement) {
- return ((MySQLCreateTableStatement)
createTableStatement).isNotExisted();
+ return ((MySQLCreateTableStatement)
createTableStatement).isContainsNotExistClause();
}
if (createTableStatement instanceof PostgreSQLStatement) {
- return ((PostgreSQLCreateTableStatement)
createTableStatement).isNotExisted();
+ return ((PostgreSQLCreateTableStatement)
createTableStatement).isContainsNotExistClause();
}
return false;
}
diff --git
a/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/dialect/handler/ddl/DropIndexStatementHandler.java
b/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/dialect/handler/ddl/DropIndexStatementHandler.java
index 3fc25c4..51e0a75 100644
---
a/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/dialect/handler/ddl/DropIndexStatementHandler.java
+++
b/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/dialect/handler/ddl/DropIndexStatementHandler.java
@@ -24,6 +24,8 @@ import
org.apache.shardingsphere.sql.parser.sql.common.statement.ddl.DropIndexSt
import
org.apache.shardingsphere.sql.parser.sql.dialect.handler.SQLStatementHandler;
import
org.apache.shardingsphere.sql.parser.sql.dialect.statement.mysql.MySQLStatement;
import
org.apache.shardingsphere.sql.parser.sql.dialect.statement.mysql.ddl.MySQLDropIndexStatement;
+import
org.apache.shardingsphere.sql.parser.sql.dialect.statement.postgresql.PostgreSQLStatement;
+import
org.apache.shardingsphere.sql.parser.sql.dialect.statement.postgresql.ddl.PostgreSQLDropIndexStatement;
import
org.apache.shardingsphere.sql.parser.sql.dialect.statement.sqlserver.SQLServerStatement;
import
org.apache.shardingsphere.sql.parser.sql.dialect.statement.sqlserver.ddl.SQLServerDropIndexStatement;
@@ -50,4 +52,20 @@ public final class DropIndexStatementHandler implements
SQLStatementHandler {
}
return Optional.empty();
}
+
+ /**
+ * Judge whether contains exist clause or not.
+ *
+ * @param dropIndexStatement drop index statement
+ * @return whether contains exist clause or not
+ */
+ public static boolean containsExistClause(final DropIndexStatement
dropIndexStatement) {
+ if (dropIndexStatement instanceof PostgreSQLStatement) {
+ return ((PostgreSQLDropIndexStatement)
dropIndexStatement).isContainsExistClause();
+ }
+ if (dropIndexStatement instanceof SQLServerStatement) {
+ return ((SQLServerDropIndexStatement)
dropIndexStatement).isContainsExistClause();
+ }
+ return false;
+ }
}
diff --git
a/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/dialect/handler/ddl/DropTableStatementHandler.java
b/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/dialect/handler/ddl/DropTableStatementHandler.java
index cd752c3..8d22445 100644
---
a/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/dialect/handler/ddl/DropTableStatementHandler.java
+++
b/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/dialect/handler/ddl/DropTableStatementHandler.java
@@ -35,20 +35,20 @@ import
org.apache.shardingsphere.sql.parser.sql.dialect.statement.sqlserver.ddl.
public final class DropTableStatementHandler implements SQLStatementHandler {
/**
- * Judge whether contains if exist clause.
+ * Judge whether contains exist clause or not.
*
* @param dropTableStatement drop table statement
- * @return contains if exist clause or not
+ * @return whether contains exist clause or not
*/
- public static boolean containsIfExistClause(final DropTableStatement
dropTableStatement) {
+ public static boolean containsExistClause(final DropTableStatement
dropTableStatement) {
if (dropTableStatement instanceof MySQLStatement) {
- return ((MySQLDropTableStatement)
dropTableStatement).isContainsIfExistClause();
+ return ((MySQLDropTableStatement)
dropTableStatement).isContainsExistClause();
}
if (dropTableStatement instanceof PostgreSQLStatement) {
- return ((PostgreSQLDropTableStatement)
dropTableStatement).isContainsIfExistClause();
+ return ((PostgreSQLDropTableStatement)
dropTableStatement).isContainsExistClause();
}
if (dropTableStatement instanceof SQLServerStatement) {
- return ((SQLServerDropTableStatement)
dropTableStatement).isContainsIfExistClause();
+ return ((SQLServerDropTableStatement)
dropTableStatement).isContainsExistClause();
}
return false;
}
diff --git
a/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/dialect/statement/mysql/ddl/MySQLCreateTableStatement.java
b/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/dialect/statement/mysql/ddl/MySQLCreateTableStatement.java
index 1c10e38..67886ad 100644
---
a/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/dialect/statement/mysql/ddl/MySQLCreateTableStatement.java
+++
b/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/dialect/statement/mysql/ddl/MySQLCreateTableStatement.java
@@ -31,5 +31,5 @@ import
org.apache.shardingsphere.sql.parser.sql.dialect.statement.mysql.MySQLSta
@ToString
public final class MySQLCreateTableStatement extends CreateTableStatement
implements MySQLStatement {
- private boolean isNotExisted;
+ private boolean containsNotExistClause;
}
diff --git
a/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/dialect/statement/mysql/ddl/MySQLDropTableStatement.java
b/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/dialect/statement/mysql/ddl/MySQLDropTableStatement.java
index b2f3f60..f09ecc9 100644
---
a/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/dialect/statement/mysql/ddl/MySQLDropTableStatement.java
+++
b/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/dialect/statement/mysql/ddl/MySQLDropTableStatement.java
@@ -31,5 +31,5 @@ import
org.apache.shardingsphere.sql.parser.sql.dialect.statement.mysql.MySQLSta
@ToString
public final class MySQLDropTableStatement extends DropTableStatement
implements MySQLStatement {
- private boolean containsIfExistClause;
+ private boolean containsExistClause;
}
diff --git
a/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/dialect/statement/postgresql/ddl/PostgreSQLCreateTableStatement.java
b/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/dialect/statement/postgresql/ddl/PostgreSQLCreateTableStatement.java
index 0a5c3ed..58abd1b 100644
---
a/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/dialect/statement/postgresql/ddl/PostgreSQLCreateTableStatement.java
+++
b/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/dialect/statement/postgresql/ddl/PostgreSQLCreateTableStatement.java
@@ -31,5 +31,5 @@ import
org.apache.shardingsphere.sql.parser.sql.dialect.statement.postgresql.Pos
@ToString
public final class PostgreSQLCreateTableStatement extends CreateTableStatement
implements PostgreSQLStatement {
- private boolean isNotExisted;
+ private boolean containsNotExistClause;
}
diff --git
a/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/dialect/statement/postgresql/ddl/PostgreSQLDropIndexStatement.java
b/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/dialect/statement/postgresql/ddl/PostgreSQLDropIndexStatement.java
index 2b7dd9b..f273f23 100644
---
a/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/dialect/statement/postgresql/ddl/PostgreSQLDropIndexStatement.java
+++
b/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/dialect/statement/postgresql/ddl/PostgreSQLDropIndexStatement.java
@@ -17,6 +17,8 @@
package
org.apache.shardingsphere.sql.parser.sql.dialect.statement.postgresql.ddl;
+import lombok.Getter;
+import lombok.Setter;
import lombok.ToString;
import
org.apache.shardingsphere.sql.parser.sql.common.statement.ddl.DropIndexStatement;
import
org.apache.shardingsphere.sql.parser.sql.dialect.statement.postgresql.PostgreSQLStatement;
@@ -24,6 +26,10 @@ import
org.apache.shardingsphere.sql.parser.sql.dialect.statement.postgresql.Pos
/**
* PostgreSQL drop index statement.
*/
+@Getter
+@Setter
@ToString
public final class PostgreSQLDropIndexStatement extends DropIndexStatement
implements PostgreSQLStatement {
+
+ private boolean containsExistClause;
}
diff --git
a/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/dialect/statement/postgresql/ddl/PostgreSQLDropTableStatement.java
b/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/dialect/statement/postgresql/ddl/PostgreSQLDropTableStatement.java
index 0e0e3eb..65deaa1 100644
---
a/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/dialect/statement/postgresql/ddl/PostgreSQLDropTableStatement.java
+++
b/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/dialect/statement/postgresql/ddl/PostgreSQLDropTableStatement.java
@@ -31,5 +31,5 @@ import
org.apache.shardingsphere.sql.parser.sql.dialect.statement.postgresql.Pos
@ToString
public final class PostgreSQLDropTableStatement extends DropTableStatement
implements PostgreSQLStatement {
- private boolean containsIfExistClause;
+ private boolean containsExistClause;
}
diff --git
a/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/dialect/statement/sqlserver/ddl/SQLServerDropIndexStatement.java
b/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/dialect/statement/sqlserver/ddl/SQLServerDropIndexStatement.java
index ff844da..e21e26a 100644
---
a/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/dialect/statement/sqlserver/ddl/SQLServerDropIndexStatement.java
+++
b/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/dialect/statement/sqlserver/ddl/SQLServerDropIndexStatement.java
@@ -17,6 +17,7 @@
package
org.apache.shardingsphere.sql.parser.sql.dialect.statement.sqlserver.ddl;
+import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import
org.apache.shardingsphere.sql.parser.sql.common.segment.generic.table.SimpleTableSegment;
@@ -28,12 +29,15 @@ import java.util.Optional;
/**
* SQLServer drop index statement.
*/
+@Getter
@Setter
@ToString
public final class SQLServerDropIndexStatement extends DropIndexStatement
implements SQLServerStatement {
private SimpleTableSegment table;
+ private boolean containsExistClause;
+
/**
* Get simple table segment.
*
diff --git
a/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/dialect/statement/sqlserver/ddl/SQLServerDropTableStatement.java
b/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/dialect/statement/sqlserver/ddl/SQLServerDropTableStatement.java
index fae2031..b2e5528 100644
---
a/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/dialect/statement/sqlserver/ddl/SQLServerDropTableStatement.java
+++
b/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/dialect/statement/sqlserver/ddl/SQLServerDropTableStatement.java
@@ -31,5 +31,5 @@ import
org.apache.shardingsphere.sql.parser.sql.dialect.statement.sqlserver.SQLS
@ToString
public final class SQLServerDropTableStatement extends DropTableStatement
implements SQLServerStatement {
- private boolean containsIfExistClause;
+ private boolean containsExistClause;
}
diff --git
a/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/test/java/org/apache/shardingsphere/sql/parser/sql/dialect/handler/ddl/CreateTableStatementHandlerTest.java
b/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/test/java/org/apache/shardingsphere/sql/parser/sql/dialect/handler/ddl/CreateTableStatementHandlerTest.java
index 1b14bc8..46948a1 100644
---
a/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/test/java/org/apache/shardingsphere/sql/parser/sql/dialect/handler/ddl/CreateTableStatementHandlerTest.java
+++
b/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/test/java/org/apache/shardingsphere/sql/parser/sql/dialect/handler/ddl/CreateTableStatementHandlerTest.java
@@ -32,53 +32,53 @@ public final class CreateTableStatementHandlerTest {
@Test
public void assertContainsIfNotExistClauseForMySQL() {
MySQLCreateTableStatement createTableStatement = new
MySQLCreateTableStatement();
- createTableStatement.setNotExisted(true);
- boolean containsNotExistClause =
CreateTableStatementHandler.containsIfNotExistClause(createTableStatement);
+ createTableStatement.setContainsNotExistClause(true);
+ boolean containsNotExistClause =
CreateTableStatementHandler.containsNotExistClause(createTableStatement);
assertTrue(containsNotExistClause);
}
@Test
public void assertContainsIfNotExistClauseForPostgreSQL() {
PostgreSQLCreateTableStatement createTableStatement = new
PostgreSQLCreateTableStatement();
- createTableStatement.setNotExisted(true);
- boolean containsNotExistClause =
CreateTableStatementHandler.containsIfNotExistClause(createTableStatement);
+ createTableStatement.setContainsNotExistClause(true);
+ boolean containsNotExistClause =
CreateTableStatementHandler.containsNotExistClause(createTableStatement);
assertTrue(containsNotExistClause);
}
@Test
public void assertNotContainsIfNotExistClauseForMySQL() {
MySQLCreateTableStatement createTableStatement = new
MySQLCreateTableStatement();
- createTableStatement.setNotExisted(false);
- boolean containsNotExistClause =
CreateTableStatementHandler.containsIfNotExistClause(createTableStatement);
+ createTableStatement.setContainsNotExistClause(false);
+ boolean containsNotExistClause =
CreateTableStatementHandler.containsNotExistClause(createTableStatement);
assertFalse(containsNotExistClause);
}
@Test
public void assertNotContainsIfNotExistClauseForOracle() {
OracleCreateTableStatement createTableStatement = new
OracleCreateTableStatement();
- boolean containsNotExistClause =
CreateTableStatementHandler.containsIfNotExistClause(createTableStatement);
+ boolean containsNotExistClause =
CreateTableStatementHandler.containsNotExistClause(createTableStatement);
assertFalse(containsNotExistClause);
}
@Test
public void assertNotContainsIfNotExistClauseForPostgreSQL() {
PostgreSQLCreateTableStatement createTableStatement = new
PostgreSQLCreateTableStatement();
- createTableStatement.setNotExisted(false);
- boolean containsNotExistClause =
CreateTableStatementHandler.containsIfNotExistClause(createTableStatement);
+ createTableStatement.setContainsNotExistClause(false);
+ boolean containsNotExistClause =
CreateTableStatementHandler.containsNotExistClause(createTableStatement);
assertFalse(containsNotExistClause);
}
@Test
public void assertNotContainsNotExistClauseForSQL92() {
SQL92CreateTableStatement createTableStatement = new
SQL92CreateTableStatement();
- boolean containsNotExistClause =
CreateTableStatementHandler.containsIfNotExistClause(createTableStatement);
+ boolean containsNotExistClause =
CreateTableStatementHandler.containsNotExistClause(createTableStatement);
assertFalse(containsNotExistClause);
}
@Test
public void assertNotContainsIfNotExistClauseForSQLServer() {
SQLServerCreateTableStatement createTableStatement = new
SQLServerCreateTableStatement();
- boolean containsNotExistClause =
CreateTableStatementHandler.containsIfNotExistClause(createTableStatement);
+ boolean containsNotExistClause =
CreateTableStatementHandler.containsNotExistClause(createTableStatement);
assertFalse(containsNotExistClause);
}
}
diff --git
a/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/test/java/org/apache/shardingsphere/sql/parser/sql/dialect/handler/ddl/DropTableStatementHandlerTest.java
b/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/test/java/org/apache/shardingsphere/sql/parser/sql/dialect/handler/ddl/DropTableStatementHandlerTest.java
index 3442df8..e83da52 100644
---
a/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/test/java/org/apache/shardingsphere/sql/parser/sql/dialect/handler/ddl/DropTableStatementHandlerTest.java
+++
b/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/test/java/org/apache/shardingsphere/sql/parser/sql/dialect/handler/ddl/DropTableStatementHandlerTest.java
@@ -32,62 +32,62 @@ public final class DropTableStatementHandlerTest {
@Test
public void assertContainsIfExistClauseForMySQL() {
MySQLDropTableStatement dropTableStatement = new
MySQLDropTableStatement();
- dropTableStatement.setContainsIfExistClause(true);
- boolean containsIfExistClause =
DropTableStatementHandler.containsIfExistClause(dropTableStatement);
+ dropTableStatement.setContainsExistClause(true);
+ boolean containsIfExistClause =
DropTableStatementHandler.containsExistClause(dropTableStatement);
assertTrue(containsIfExistClause);
}
@Test
public void assertContainsIfExistClauseForPostgreSQL() {
PostgreSQLDropTableStatement dropTableStatement = new
PostgreSQLDropTableStatement();
- dropTableStatement.setContainsIfExistClause(true);
- boolean containsIfExistClause =
DropTableStatementHandler.containsIfExistClause(dropTableStatement);
+ dropTableStatement.setContainsExistClause(true);
+ boolean containsIfExistClause =
DropTableStatementHandler.containsExistClause(dropTableStatement);
assertTrue(containsIfExistClause);
}
@Test
public void assertContainsIfExistClauseForSQLServer() {
SQLServerDropTableStatement dropTableStatement = new
SQLServerDropTableStatement();
- dropTableStatement.setContainsIfExistClause(true);
- boolean containsIfExistClause =
DropTableStatementHandler.containsIfExistClause(dropTableStatement);
+ dropTableStatement.setContainsExistClause(true);
+ boolean containsIfExistClause =
DropTableStatementHandler.containsExistClause(dropTableStatement);
assertTrue(containsIfExistClause);
}
@Test
public void assertNotContainsIfExistClauseForMySQL() {
MySQLDropTableStatement dropTableStatement = new
MySQLDropTableStatement();
- dropTableStatement.setContainsIfExistClause(false);
- boolean containsIfExistClause =
DropTableStatementHandler.containsIfExistClause(dropTableStatement);
+ dropTableStatement.setContainsExistClause(false);
+ boolean containsIfExistClause =
DropTableStatementHandler.containsExistClause(dropTableStatement);
assertFalse(containsIfExistClause);
}
@Test
public void assertNotContainsIfExistClauseForOracle() {
OracleDropTableStatement dropTableStatement = new
OracleDropTableStatement();
- boolean containsIfExistClause =
DropTableStatementHandler.containsIfExistClause(dropTableStatement);
+ boolean containsIfExistClause =
DropTableStatementHandler.containsExistClause(dropTableStatement);
assertFalse(containsIfExistClause);
}
@Test
public void assertNotContainsIfExistClauseForPostgreSQL() {
PostgreSQLDropTableStatement dropTableStatement = new
PostgreSQLDropTableStatement();
- dropTableStatement.setContainsIfExistClause(false);
- boolean containsIfExistClause =
DropTableStatementHandler.containsIfExistClause(dropTableStatement);
+ dropTableStatement.setContainsExistClause(false);
+ boolean containsIfExistClause =
DropTableStatementHandler.containsExistClause(dropTableStatement);
assertFalse(containsIfExistClause);
}
@Test
public void assertNotContainsIfExistClauseForSQL92() {
SQL92DropTableStatement dropTableStatement = new
SQL92DropTableStatement();
- boolean containsIfExistClause =
DropTableStatementHandler.containsIfExistClause(dropTableStatement);
+ boolean containsIfExistClause =
DropTableStatementHandler.containsExistClause(dropTableStatement);
assertFalse(containsIfExistClause);
}
@Test
public void assertNotContainsIfExistClauseForSQLServer() {
SQLServerDropTableStatement dropTableStatement = new
SQLServerDropTableStatement();
- dropTableStatement.setContainsIfExistClause(false);
- boolean containsIfExistClause =
DropTableStatementHandler.containsIfExistClause(dropTableStatement);
+ dropTableStatement.setContainsExistClause(false);
+ boolean containsIfExistClause =
DropTableStatementHandler.containsExistClause(dropTableStatement);
assertFalse(containsIfExistClause);
}
}