This is an automated email from the ASF dual-hosted git repository.
zhangliang 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 f23f90d308f Remove useless CallStatementContext (#32111)
f23f90d308f is described below
commit f23f90d308f4a5ea380d41e9240220c9ee584ce9
Author: Liang Zhang <[email protected]>
AuthorDate: Mon Jul 15 14:57:47 2024 +0800
Remove useless CallStatementContext (#32111)
---
.../statement/SQLStatementContextFactory.java | 6 +--
.../statement/dml/CallStatementContext.java | 36 ----------------
.../statement/dml/CallStatementContextTest.java | 48 ----------------------
3 files changed, 1 insertion(+), 89 deletions(-)
diff --git
a/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/SQLStatementContextFactory.java
b/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/SQLStatementContextFactory.java
index 6c345fab1e4..cb610b86d6e 100644
---
a/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/SQLStatementContextFactory.java
+++
b/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/SQLStatementContextFactory.java
@@ -51,7 +51,6 @@ import
org.apache.shardingsphere.infra.binder.context.statement.ddl.MoveStatemen
import
org.apache.shardingsphere.infra.binder.context.statement.ddl.PrepareStatementContext;
import
org.apache.shardingsphere.infra.binder.context.statement.ddl.RenameTableStatementContext;
import
org.apache.shardingsphere.infra.binder.context.statement.ddl.TruncateStatementContext;
-import
org.apache.shardingsphere.infra.binder.context.statement.dml.CallStatementContext;
import
org.apache.shardingsphere.infra.binder.context.statement.dml.CopyStatementContext;
import
org.apache.shardingsphere.infra.binder.context.statement.dml.DeleteStatementContext;
import
org.apache.shardingsphere.infra.binder.context.statement.dml.DoStatementContext;
@@ -157,9 +156,6 @@ public final class SQLStatementContextFactory {
if (sqlStatement instanceof InsertStatement) {
return new InsertStatementContext(metaData, params,
(InsertStatement) sqlStatement, currentDatabaseName);
}
- if (sqlStatement instanceof CallStatement) {
- return new CallStatementContext((CallStatement) sqlStatement);
- }
if (sqlStatement instanceof CopyStatement) {
return new CopyStatementContext((CopyStatement) sqlStatement,
currentDatabaseName);
}
@@ -172,7 +168,7 @@ public final class SQLStatementContextFactory {
if (sqlStatement instanceof LoadXMLStatement) {
return new LoadXMLStatementContext((LoadXMLStatement)
sqlStatement, currentDatabaseName);
}
- if (sqlStatement instanceof MergeStatement) {
+ if (sqlStatement instanceof CallStatement || sqlStatement instanceof
MergeStatement) {
return new UnknownSQLStatementContext(sqlStatement);
}
throw new UnsupportedSQLOperationException(String.format("Unsupported
SQL statement `%s`", sqlStatement.getClass().getSimpleName()));
diff --git
a/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/dml/CallStatementContext.java
b/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/dml/CallStatementContext.java
deleted file mode 100644
index f01d4f1d04c..00000000000
---
a/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/dml/CallStatementContext.java
+++ /dev/null
@@ -1,36 +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.infra.binder.context.statement.dml;
-
-import
org.apache.shardingsphere.infra.binder.context.statement.CommonSQLStatementContext;
-import
org.apache.shardingsphere.sql.parser.statement.core.statement.dml.CallStatement;
-
-/**
- * Call statement context.
- */
-public final class CallStatementContext extends CommonSQLStatementContext {
-
- public CallStatementContext(final CallStatement sqlStatement) {
- super(sqlStatement);
- }
-
- @Override
- public CallStatement getSqlStatement() {
- return (CallStatement) super.getSqlStatement();
- }
-}
diff --git
a/infra/binder/src/test/java/org/apache/shardingsphere/infra/binder/context/statement/dml/CallStatementContextTest.java
b/infra/binder/src/test/java/org/apache/shardingsphere/infra/binder/context/statement/dml/CallStatementContextTest.java
deleted file mode 100644
index 0f46f16be31..00000000000
---
a/infra/binder/src/test/java/org/apache/shardingsphere/infra/binder/context/statement/dml/CallStatementContextTest.java
+++ /dev/null
@@ -1,48 +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.infra.binder.context.statement.dml;
-
-import
org.apache.shardingsphere.infra.binder.context.statement.CommonSQLStatementContext;
-import
org.apache.shardingsphere.sql.parser.statement.core.statement.dml.CallStatement;
-import
org.apache.shardingsphere.sql.parser.statement.mysql.dml.MySQLCallStatement;
-import
org.apache.shardingsphere.sql.parser.statement.postgresql.dml.PostgreSQLCallStatement;
-import org.junit.jupiter.api.Test;
-
-import static org.hamcrest.CoreMatchers.instanceOf;
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.mockito.Mockito.mock;
-
-class CallStatementContextTest {
-
- @Test
- void assertMySQLNewInstance() {
- assertNewInstance(mock(MySQLCallStatement.class));
- }
-
- @Test
- void assertPostgreSQLNewInstance() {
- assertNewInstance(mock(PostgreSQLCallStatement.class));
- }
-
- private void assertNewInstance(final CallStatement callStatement) {
- CallStatementContext actual = new CallStatementContext(callStatement);
- assertThat(actual, instanceOf(CommonSQLStatementContext.class));
- assertThat(actual.getSqlStatement(), is(callStatement));
- }
-}