This is an automated email from the ASF dual-hosted git repository.
wuweijie 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 219fe26 Remove CREATE SHARDING RULE (#10125)
219fe26 is described below
commit 219fe262a71b1c932b9a539fbaae87634cc887d9
Author: Haoran Meng <[email protected]>
AuthorDate: Mon Apr 19 12:50:33 2021 +0800
Remove CREATE SHARDING RULE (#10125)
---
.../src/main/antlr4/imports/RDLStatement.g4 | 4 --
.../distsql/parser/core/DistSQLVisitor.java | 29 ---------
.../create/impl/CreateShardingRuleStatement.java | 45 -------------
.../converter/ShardingRuleStatementConverter.java | 15 -----
.../ShardingRuleStatementConverterTest.java | 6 +-
.../text/distsql/rdl/RDLBackendHandlerFactory.java | 6 +-
.../rdl/impl/CreateShardingRuleBackendHandler.java | 76 ----------------------
.../text/distsql/RDLBackendHandlerFactoryTest.java | 10 +--
.../command/query/PostgreSQLCommand.java | 4 +-
.../command/query/PostgreSQLCommandTest.java | 6 +-
10 files changed, 15 insertions(+), 186 deletions(-)
diff --git
a/shardingsphere-distsql-parser/shardingsphere-distsql-parser-engine/src/main/antlr4/imports/RDLStatement.g4
b/shardingsphere-distsql-parser/shardingsphere-distsql-parser-engine/src/main/antlr4/imports/RDLStatement.g4
index 16843c6..52a0bd8 100644
---
a/shardingsphere-distsql-parser/shardingsphere-distsql-parser-engine/src/main/antlr4/imports/RDLStatement.g4
+++
b/shardingsphere-distsql-parser/shardingsphere-distsql-parser-engine/src/main/antlr4/imports/RDLStatement.g4
@@ -63,10 +63,6 @@ createShardingTableRule
: CREATE SHARDING TABLE RULE shardingTableRuleDefinition (COMMA
shardingTableRuleDefinition)*
;
-createShardingRule
- : CREATE SHARDING RULE LP shardingTableRuleDefinition (COMMA
shardingTableRuleDefinition)* bindingTables? defaultTableStrategy?
broadcastTables? RP
- ;
-
alterShardingRule
: ALTER SHARDING RULE LP alterShardingTableRuleDefinition (COMMA
alterShardingTableRuleDefinition)* alterBindingTables? defaultTableStrategy?
broadcastTables? RP
;
diff --git
a/shardingsphere-distsql-parser/shardingsphere-distsql-parser-engine/src/main/java/org/apache/shardingsphere/distsql/parser/core/DistSQLVisitor.java
b/shardingsphere-distsql-parser/shardingsphere-distsql-parser-engine/src/main/java/org/apache/shardingsphere/distsql/parser/core/DistSQLVisitor.java
index 6adb042..eae1de6 100644
---
a/shardingsphere-distsql-parser/shardingsphere-distsql-parser-engine/src/main/java/org/apache/shardingsphere/distsql/parser/core/DistSQLVisitor.java
+++
b/shardingsphere-distsql-parser/shardingsphere-distsql-parser-engine/src/main/java/org/apache/shardingsphere/distsql/parser/core/DistSQLVisitor.java
@@ -26,10 +26,8 @@ import
org.apache.shardingsphere.distsql.parser.autogen.DistSQLStatementParser.A
import
org.apache.shardingsphere.distsql.parser.autogen.DistSQLStatementParser.AlterReplicaQueryRuleDefinitionContext;
import
org.apache.shardingsphere.distsql.parser.autogen.DistSQLStatementParser.AlterShardingRuleContext;
import
org.apache.shardingsphere.distsql.parser.autogen.DistSQLStatementParser.AlterShardingTableRuleDefinitionContext;
-import
org.apache.shardingsphere.distsql.parser.autogen.DistSQLStatementParser.BindingTableContext;
import
org.apache.shardingsphere.distsql.parser.autogen.DistSQLStatementParser.CheckScalingJobContext;
import
org.apache.shardingsphere.distsql.parser.autogen.DistSQLStatementParser.CreateReplicaQueryRuleContext;
-import
org.apache.shardingsphere.distsql.parser.autogen.DistSQLStatementParser.CreateShardingRuleContext;
import
org.apache.shardingsphere.distsql.parser.autogen.DistSQLStatementParser.CreateShardingTableRuleContext;
import
org.apache.shardingsphere.distsql.parser.autogen.DistSQLStatementParser.DataSourceContext;
import
org.apache.shardingsphere.distsql.parser.autogen.DistSQLStatementParser.DropReplicaQueryRuleContext;
@@ -64,7 +62,6 @@ import
org.apache.shardingsphere.distsql.parser.statement.rdl.AlterReadWriteSpli
import
org.apache.shardingsphere.distsql.parser.statement.rdl.AlterShardingRuleStatement;
import
org.apache.shardingsphere.distsql.parser.statement.rdl.create.impl.AddResourceStatement;
import
org.apache.shardingsphere.distsql.parser.statement.rdl.create.impl.CreateReadWriteSplittingRuleStatement;
-import
org.apache.shardingsphere.distsql.parser.statement.rdl.create.impl.CreateShardingRuleStatement;
import
org.apache.shardingsphere.distsql.parser.statement.rdl.create.impl.CreateShardingTableRuleStatement;
import
org.apache.shardingsphere.distsql.parser.statement.rdl.drop.impl.DropReplicaQueryRuleStatement;
import
org.apache.shardingsphere.distsql.parser.statement.rdl.drop.impl.DropResourceStatement;
@@ -126,32 +123,6 @@ public final class DistSQLVisitor extends
DistSQLStatementBaseVisitor<ASTNode> {
}
@Override
- public ASTNode visitCreateShardingRule(final CreateShardingRuleContext
ctx) {
- CreateShardingRuleStatement result;
- if (null != ctx.defaultTableStrategy()) {
- String defaultTableStrategyColumn = null !=
ctx.defaultTableStrategy().columnName() ?
ctx.defaultTableStrategy().columnName().getText() : null;
- result = new
CreateShardingRuleStatement(defaultTableStrategyColumn, (FunctionSegment)
visit(ctx.defaultTableStrategy()));
- } else {
- result = new CreateShardingRuleStatement(null, null);
- }
- for (ShardingTableRuleDefinitionContext each :
ctx.shardingTableRuleDefinition()) {
- result.getTables().add((TableRuleSegment) visit(each));
- }
- if (null != ctx.bindingTables()) {
- for (BindingTableContext each :
ctx.bindingTables().bindingTable()) {
- Collection<String> tables =
each.tableNames().IDENTIFIER().stream().map(t -> new
IdentifierValue(t.getText()).getValue()).collect(Collectors.toList());
- result.getBindingTables().add(tables);
- }
- }
- if (null != ctx.broadcastTables()) {
- for (TerminalNode each : ctx.broadcastTables().IDENTIFIER()) {
- result.getBroadcastTables().add(new
IdentifierValue(each.getText()).getValue());
- }
- }
- return result;
- }
-
- @Override
public ASTNode visitAlterShardingRule(final AlterShardingRuleContext ctx) {
AlterShardingRuleStatement result;
if (null != ctx.defaultTableStrategy()) {
diff --git
a/shardingsphere-distsql-parser/shardingsphere-distsql-parser-statement/src/main/java/org/apache/shardingsphere/distsql/parser/statement/rdl/create/impl/CreateShardingRuleStatement.java
b/shardingsphere-distsql-parser/shardingsphere-distsql-parser-statement/src/main/java/org/apache/shardingsphere/distsql/parser/statement/rdl/create/impl/CreateShardingRuleStatement.java
deleted file mode 100644
index 6740a42..0000000
---
a/shardingsphere-distsql-parser/shardingsphere-distsql-parser-statement/src/main/java/org/apache/shardingsphere/distsql/parser/statement/rdl/create/impl/CreateShardingRuleStatement.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.shardingsphere.distsql.parser.statement.rdl.create.impl;
-
-import lombok.Getter;
-import lombok.RequiredArgsConstructor;
-import org.apache.shardingsphere.distsql.parser.segment.FunctionSegment;
-import org.apache.shardingsphere.distsql.parser.segment.TableRuleSegment;
-import
org.apache.shardingsphere.distsql.parser.statement.rdl.create.CreateRDLStatement;
-
-import java.util.Collection;
-import java.util.LinkedList;
-
-/**
- * Create sharding rule statement.
- */
-@RequiredArgsConstructor
-@Getter
-public final class CreateShardingRuleStatement extends CreateRDLStatement {
-
- private final Collection<TableRuleSegment> tables = new LinkedList<>();
-
- private final Collection<Collection<String>> bindingTables = new
LinkedList<>();
-
- private final Collection<String> broadcastTables = new LinkedList<>();
-
- private final String defaultTableStrategyColumn;
-
- private final FunctionSegment defaultTableStrategy;
-}
diff --git
a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-common/src/main/java/org/apache/shardingsphere/sharding/converter/ShardingRuleStatementConverter.java
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-common/src/main/java/org/apache/shardingsphere/sharding/converter/ShardingRuleStatementConverter.java
index f09f27a..57a8635 100644
---
a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-common/src/main/java/org/apache/shardingsphere/sharding/converter/ShardingRuleStatementConverter.java
+++
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-common/src/main/java/org/apache/shardingsphere/sharding/converter/ShardingRuleStatementConverter.java
@@ -22,7 +22,6 @@ import lombok.AccessLevel;
import lombok.NoArgsConstructor;
import org.apache.shardingsphere.distsql.parser.segment.FunctionSegment;
import org.apache.shardingsphere.distsql.parser.segment.TableRuleSegment;
-import
org.apache.shardingsphere.distsql.parser.statement.rdl.create.impl.CreateShardingRuleStatement;
import
org.apache.shardingsphere.distsql.parser.statement.rdl.create.impl.CreateShardingTableRuleStatement;
import
org.apache.shardingsphere.infra.yaml.config.algorithm.YamlShardingSphereAlgorithmConfiguration;
import
org.apache.shardingsphere.sharding.yaml.config.YamlShardingRuleConfiguration;
@@ -41,20 +40,6 @@ import java.util.Collection;
public final class ShardingRuleStatementConverter {
/**
- * Convert create sharding rule statement context to YAML sharding rule
configuration.
- *
- * @param sqlStatement create sharding rule statement
- * @return YAML sharding rule configuration
- */
- public static YamlShardingRuleConfiguration convert(final
CreateShardingRuleStatement sqlStatement) {
- YamlShardingRuleConfiguration result =
convertTableRuleSegments(sqlStatement.getTables());
- for (Collection<String> each : sqlStatement.getBindingTables()) {
- result.getBindingTables().add(Joiner.on(",").join(each));
- }
- return result;
- }
-
- /**
* Convert create sharding table rule statement context to YAML sharding
rule configuration.
*
* @param sqlStatement create sharding table rule statement
diff --git
a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-common/src/test/java/org/apache/shardingsphere/sharding/converter/ShardingRuleStatementConverterTest.java
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-common/src/test/java/org/apache/shardingsphere/sharding/converter/ShardingRuleStatementConverterTest.java
index 2211c40..ed6a477 100644
---
a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-common/src/test/java/org/apache/shardingsphere/sharding/converter/ShardingRuleStatementConverterTest.java
+++
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-common/src/test/java/org/apache/shardingsphere/sharding/converter/ShardingRuleStatementConverterTest.java
@@ -19,7 +19,7 @@ package org.apache.shardingsphere.sharding.converter;
import org.apache.shardingsphere.distsql.parser.segment.FunctionSegment;
import org.apache.shardingsphere.distsql.parser.segment.TableRuleSegment;
-import
org.apache.shardingsphere.distsql.parser.statement.rdl.create.impl.CreateShardingRuleStatement;
+import
org.apache.shardingsphere.distsql.parser.statement.rdl.create.impl.CreateShardingTableRuleStatement;
import org.apache.shardingsphere.infra.spi.ShardingSphereServiceLoader;
import org.apache.shardingsphere.sharding.spi.ShardingAlgorithm;
import
org.apache.shardingsphere.sharding.yaml.config.YamlShardingRuleConfiguration;
@@ -37,7 +37,7 @@ public final class ShardingRuleStatementConverterTest {
private TableRuleSegment segment;
- private CreateShardingRuleStatement sqlStatement;
+ private CreateShardingTableRuleStatement sqlStatement;
@Before
public void setUp() {
@@ -52,7 +52,7 @@ public final class ShardingRuleStatementConverterTest {
props.setProperty("sharding_count", "2");
functionSegment.setAlgorithmProps(props);
segment.setTableStrategy(functionSegment);
- sqlStatement = new CreateShardingRuleStatement(null, functionSegment);
+ sqlStatement = new CreateShardingTableRuleStatement();
sqlStatement.getTables().add(segment);
}
diff --git
a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/rdl/RDLBackendHandlerFactory.java
b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/rdl/RDLBackendHandlerFactory.java
index a3bc841..195ff7b 100644
---
a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/rdl/RDLBackendHandlerFactory.java
+++
b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/rdl/RDLBackendHandlerFactory.java
@@ -23,7 +23,6 @@ import
org.apache.shardingsphere.distsql.parser.statement.rdl.AlterReadWriteSpli
import
org.apache.shardingsphere.distsql.parser.statement.rdl.AlterShardingRuleStatement;
import
org.apache.shardingsphere.distsql.parser.statement.rdl.create.impl.AddResourceStatement;
import
org.apache.shardingsphere.distsql.parser.statement.rdl.create.impl.CreateReadWriteSplittingRuleStatement;
-import
org.apache.shardingsphere.distsql.parser.statement.rdl.create.impl.CreateShardingRuleStatement;
import
org.apache.shardingsphere.distsql.parser.statement.rdl.create.impl.CreateShardingTableRuleStatement;
import
org.apache.shardingsphere.distsql.parser.statement.rdl.drop.impl.DropReplicaQueryRuleStatement;
import
org.apache.shardingsphere.distsql.parser.statement.rdl.drop.impl.DropResourceStatement;
@@ -38,7 +37,6 @@ import
org.apache.shardingsphere.proxy.backend.text.distsql.rdl.impl.AlterReadWr
import
org.apache.shardingsphere.proxy.backend.text.distsql.rdl.impl.AlterShardingRuleBackendHandler;
import
org.apache.shardingsphere.proxy.backend.text.distsql.rdl.impl.CreateDatabaseBackendHandler;
import
org.apache.shardingsphere.proxy.backend.text.distsql.rdl.impl.CreateReadWriteSplittingRuleBackendHandler;
-import
org.apache.shardingsphere.proxy.backend.text.distsql.rdl.impl.CreateShardingRuleBackendHandler;
import
org.apache.shardingsphere.proxy.backend.text.distsql.rdl.impl.CreateShardingTableRuleBackendHandler;
import
org.apache.shardingsphere.proxy.backend.text.distsql.rdl.impl.DropDatabaseBackendHandler;
import
org.apache.shardingsphere.proxy.backend.text.distsql.rdl.impl.DropReadWriteSplittingRuleBackendHandler;
@@ -90,8 +88,8 @@ public final class RDLBackendHandlerFactory {
if (sqlStatement instanceof CreateDatabaseStatement) {
return Optional.of(new
CreateDatabaseBackendHandler((CreateDatabaseStatement) sqlStatement));
}
- if (sqlStatement instanceof CreateShardingRuleStatement) {
- return Optional.of(new
CreateShardingRuleBackendHandler((CreateShardingRuleStatement) sqlStatement,
backendConnection));
+ if (sqlStatement instanceof CreateShardingTableRuleStatement) {
+ return Optional.of(new
CreateShardingTableRuleBackendHandler((CreateShardingTableRuleStatement)
sqlStatement, backendConnection));
}
if (sqlStatement instanceof CreateShardingTableRuleStatement) {
return Optional.of(new
CreateShardingTableRuleBackendHandler((CreateShardingTableRuleStatement)
sqlStatement, backendConnection));
diff --git
a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/rdl/impl/CreateShardingRuleBackendHandler.java
b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/rdl/impl/CreateShardingRuleBackendHandler.java
deleted file mode 100644
index bb161d1..0000000
---
a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/rdl/impl/CreateShardingRuleBackendHandler.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.shardingsphere.proxy.backend.text.distsql.rdl.impl;
-
-import org.apache.shardingsphere.distsql.parser.segment.TableRuleSegment;
-import
org.apache.shardingsphere.distsql.parser.statement.rdl.create.impl.CreateShardingRuleStatement;
-import
org.apache.shardingsphere.governance.core.event.model.rule.RuleConfigurationsAlteredEvent;
-import org.apache.shardingsphere.infra.config.RuleConfiguration;
-import org.apache.shardingsphere.infra.eventbus.ShardingSphereEventBus;
-import
org.apache.shardingsphere.infra.yaml.swapper.YamlRuleConfigurationSwapperEngine;
-import
org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.BackendConnection;
-import
org.apache.shardingsphere.proxy.backend.exception.ShardingTableRuleNotExistedException;
-import org.apache.shardingsphere.proxy.backend.response.header.ResponseHeader;
-import
org.apache.shardingsphere.proxy.backend.response.header.update.UpdateResponseHeader;
-import
org.apache.shardingsphere.proxy.backend.text.SchemaRequiredBackendHandler;
-import
org.apache.shardingsphere.sharding.converter.ShardingRuleStatementConverter;
-import
org.apache.shardingsphere.sharding.yaml.config.YamlShardingRuleConfiguration;
-
-import java.util.Collection;
-import java.util.Collections;
-import java.util.LinkedList;
-import java.util.stream.Collectors;
-
-/**
- * Create sharding rule backend handler.
- */
-public final class CreateShardingRuleBackendHandler extends
SchemaRequiredBackendHandler<CreateShardingRuleStatement> {
-
- public CreateShardingRuleBackendHandler(final CreateShardingRuleStatement
sqlStatement, final BackendConnection backendConnection) {
- super(sqlStatement, backendConnection);
- }
-
- @Override
- public ResponseHeader execute(final String schemaName, final
CreateShardingRuleStatement sqlStatement) {
- check(sqlStatement);
- YamlShardingRuleConfiguration config =
ShardingRuleStatementConverter.convert(sqlStatement);
- Collection<RuleConfiguration> rules = new
YamlRuleConfigurationSwapperEngine().swapToRuleConfigurations(Collections.singleton(config));
- post(schemaName, rules);
- return new UpdateResponseHeader(sqlStatement);
- }
-
- private void check(final CreateShardingRuleStatement sqlStatement) {
- Collection<String> validTables =
sqlStatement.getTables().stream().map(TableRuleSegment::getLogicTable).collect(Collectors.toList());
- Collection<String> invalidTables = new LinkedList<>();
- for (Collection<String> each : sqlStatement.getBindingTables()) {
- for (String t : each) {
- if (!validTables.contains(t)) {
- invalidTables.add(t);
- }
- }
- }
- if (!invalidTables.isEmpty()) {
- throw new ShardingTableRuleNotExistedException(invalidTables);
- }
- }
-
- private void post(final String schemaName, final
Collection<RuleConfiguration> rules) {
- ShardingSphereEventBus.getInstance().post(new
RuleConfigurationsAlteredEvent(schemaName, rules));
- // TODO Need to get the executed feedback from registry center for
returning.
- }
-}
diff --git
a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/RDLBackendHandlerFactoryTest.java
b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/RDLBackendHandlerFactoryTest.java
index 6cfa9ff..31f9b0a 100644
---
a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/RDLBackendHandlerFactoryTest.java
+++
b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/RDLBackendHandlerFactoryTest.java
@@ -21,7 +21,7 @@ import lombok.SneakyThrows;
import
org.apache.shardingsphere.distsql.parser.statement.rdl.AlterReadWriteSplittingRuleStatement;
import
org.apache.shardingsphere.distsql.parser.statement.rdl.create.impl.AddResourceStatement;
import
org.apache.shardingsphere.distsql.parser.statement.rdl.create.impl.CreateReadWriteSplittingRuleStatement;
-import
org.apache.shardingsphere.distsql.parser.statement.rdl.create.impl.CreateShardingRuleStatement;
+import
org.apache.shardingsphere.distsql.parser.statement.rdl.create.impl.CreateShardingTableRuleStatement;
import
org.apache.shardingsphere.distsql.parser.statement.rdl.drop.impl.DropReplicaQueryRuleStatement;
import
org.apache.shardingsphere.distsql.parser.statement.rdl.drop.impl.DropResourceStatement;
import
org.apache.shardingsphere.distsql.parser.statement.rql.show.ShowResourcesStatement;
@@ -181,16 +181,16 @@ public final class RDLBackendHandlerFactoryTest {
}
@Test
- public void assertExecuteShardingRuleContext() throws SQLException {
+ public void assertExecuteShardingTableRuleContext() throws SQLException {
BackendConnection connection = mock(BackendConnection.class);
when(connection.getSchemaName()).thenReturn("schema");
try {
- RDLBackendHandlerFactory.newInstance(new MySQLDatabaseType(),
mock(CreateShardingRuleStatement.class), connection);
+ RDLBackendHandlerFactory.newInstance(new MySQLDatabaseType(),
mock(CreateShardingTableRuleStatement.class), connection);
} catch (final SQLException ex) {
- assertThat(ex.getMessage(), is("No Registry center to execute
`CreateShardingRuleStatement` SQL"));
+ assertThat(ex.getMessage(), is("No Registry center to execute
`CreateShardingTableRuleStatement` SQL"));
}
setGovernanceMetaDataContexts(true);
- Optional<TextProtocolBackendHandler> rdlBackendHandler =
RDLBackendHandlerFactory.newInstance(new MySQLDatabaseType(),
mock(CreateShardingRuleStatement.class), connection);
+ Optional<TextProtocolBackendHandler> rdlBackendHandler =
RDLBackendHandlerFactory.newInstance(new MySQLDatabaseType(),
mock(CreateShardingTableRuleStatement.class), connection);
assertTrue(rdlBackendHandler.isPresent());
ResponseHeader response = rdlBackendHandler.get().execute();
assertThat(response, instanceOf(UpdateResponseHeader.class));
diff --git
a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/PostgreSQLCommand.java
b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/PostgreSQLCommand.java
index 13e58f6..6940da6 100644
---
a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/PostgreSQLCommand.java
+++
b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/PostgreSQLCommand.java
@@ -19,7 +19,7 @@ package
org.apache.shardingsphere.proxy.frontend.postgresql.command.query;
import lombok.RequiredArgsConstructor;
import
org.apache.shardingsphere.distsql.parser.statement.rdl.create.impl.AddResourceStatement;
-import
org.apache.shardingsphere.distsql.parser.statement.rdl.create.impl.CreateShardingRuleStatement;
+import
org.apache.shardingsphere.distsql.parser.statement.rdl.create.impl.CreateShardingTableRuleStatement;
import org.apache.shardingsphere.sql.parser.sql.common.statement.SQLStatement;
import
org.apache.shardingsphere.sql.parser.sql.common.statement.ddl.CreateDatabaseStatement;
import
org.apache.shardingsphere.sql.parser.sql.common.statement.ddl.DropDatabaseStatement;
@@ -50,7 +50,7 @@ public final class PostgreSQLCommand {
if (sqlStatement instanceof UpdateStatement) {
return "UPDATE";
}
- if (sqlStatement instanceof CreateDatabaseStatement || sqlStatement
instanceof AddResourceStatement || sqlStatement instanceof
CreateShardingRuleStatement) {
+ if (sqlStatement instanceof CreateDatabaseStatement || sqlStatement
instanceof AddResourceStatement || sqlStatement instanceof
CreateShardingTableRuleStatement) {
return "CREATE";
}
if (sqlStatement instanceof DropDatabaseStatement) {
diff --git
a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/PostgreSQLCommandTest.java
b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/PostgreSQLCommandTest.java
index 01fbd78..65b996e 100644
---
a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/PostgreSQLCommandTest.java
+++
b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/PostgreSQLCommandTest.java
@@ -18,7 +18,7 @@
package org.apache.shardingsphere.proxy.frontend.postgresql.command.query;
import
org.apache.shardingsphere.distsql.parser.statement.rdl.create.impl.AddResourceStatement;
-import
org.apache.shardingsphere.distsql.parser.statement.rdl.create.impl.CreateShardingRuleStatement;
+import
org.apache.shardingsphere.distsql.parser.statement.rdl.create.impl.CreateShardingTableRuleStatement;
import org.apache.shardingsphere.sql.parser.sql.common.statement.SQLStatement;
import
org.apache.shardingsphere.sql.parser.sql.common.statement.ddl.CreateDatabaseStatement;
import
org.apache.shardingsphere.sql.parser.sql.common.statement.ddl.DropDatabaseStatement;
@@ -69,7 +69,7 @@ public final class PostgreSQLCommandTest {
}
@Test
- public void
assertPostgreSQLCommandWhenSQLStatementInstanceOfCreateShardingRuleStatement() {
- assertThat(new
PostgreSQLCommand(mock(CreateShardingRuleStatement.class)).getSQLCommand(),
is("CREATE"));
+ public void
assertPostgreSQLCommandWhenSQLStatementInstanceOfCreateShardingTableRuleStatement()
{
+ assertThat(new
PostgreSQLCommand(mock(CreateShardingTableRuleStatement.class)).getSQLCommand(),
is("CREATE"));
}
}