This is an automated email from the ASF dual-hosted git repository.
sunnianjun 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 9b19d14ce05 Remove ConnectionSessionAwareRULExecutor (#29875)
9b19d14ce05 is described below
commit 9b19d14ce0530c131be2dbf376b317fb9efe6541
Author: Liang Zhang <[email protected]>
AuthorDate: Sat Jan 27 20:10:35 2024 +0800
Remove ConnectionSessionAwareRULExecutor (#29875)
---
.../DistSQLExecutorConnectionContextAware.java | 51 ++++++++++++++++++++++
.../DistSQLExecutorDatabaseProtocolTypeAware.java | 18 +++-----
.../handler/distsql/rul/RULBackendHandler.java | 17 ++++++--
.../distsql/rul/type/FormatSQLExecutor.java | 10 ++---
.../distsql/rul/type/ParseDistSQLExecutor.java | 11 ++---
.../handler/distsql/rul/type/PreviewExecutor.java | 51 ++++++++++++----------
6 files changed, 111 insertions(+), 47 deletions(-)
diff --git
a/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/aware/DistSQLExecutorConnectionContextAware.java
b/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/aware/DistSQLExecutorConnectionContextAware.java
new file mode 100644
index 00000000000..d50f5c4624d
--- /dev/null
+++
b/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/aware/DistSQLExecutorConnectionContextAware.java
@@ -0,0 +1,51 @@
+/*
+ * 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.handler.aware;
+
+import
org.apache.shardingsphere.infra.executor.sql.prepare.driver.DatabaseConnectionManager;
+import
org.apache.shardingsphere.infra.executor.sql.prepare.driver.ExecutorStatementManager;
+import org.apache.shardingsphere.infra.session.connection.ConnectionContext;
+
+/**
+ * DistSQL executor connection context aware.
+ */
+public interface DistSQLExecutorConnectionContextAware {
+
+ /**
+ * Set connection context.
+ *
+ * @param connectionContext connection context
+ */
+ void setConnectionContext(ConnectionContext connectionContext);
+
+ /**
+ * Set database connection manager.
+ *
+ * @param databaseConnectionManager database connection manager
+ */
+ @SuppressWarnings("rawtypes")
+ void setDatabaseConnectionManager(DatabaseConnectionManager
databaseConnectionManager);
+
+ /**
+ * Set executor statement manager.
+ *
+ * @param executorStatementManager executor statement manager
+ */
+ @SuppressWarnings("rawtypes")
+ void setStatementManager(ExecutorStatementManager
executorStatementManager);
+}
diff --git
a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rul/aware/ConnectionSessionAwareRULExecutor.java
b/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/aware/DistSQLExecutorDatabaseProtocolTypeAware.java
similarity index 57%
rename from
proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rul/aware/ConnectionSessionAwareRULExecutor.java
rename to
infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/aware/DistSQLExecutorDatabaseProtocolTypeAware.java
index 904c4eda685..61dcf2f2a3c 100644
---
a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rul/aware/ConnectionSessionAwareRULExecutor.java
+++
b/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/aware/DistSQLExecutorDatabaseProtocolTypeAware.java
@@ -15,23 +15,19 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.proxy.backend.handler.distsql.rul.aware;
+package org.apache.shardingsphere.distsql.handler.aware;
-import org.apache.shardingsphere.distsql.handler.type.rul.RULExecutor;
-import org.apache.shardingsphere.distsql.statement.rul.RULStatement;
-import org.apache.shardingsphere.proxy.backend.session.ConnectionSession;
+import org.apache.shardingsphere.infra.database.core.type.DatabaseType;
/**
- * Connection session aware RUL executor.
- *
- * @param <T> type of RUL statement
+ * DistSQL executor database protocol type Aware.
*/
-public interface ConnectionSessionAwareRULExecutor<T extends RULStatement>
extends RULExecutor<T> {
+public interface DistSQLExecutorDatabaseProtocolTypeAware {
/**
- * Set connection session.
+ * Set database protocol type.
*
- * @param connectionSession connection session
+ * @param protocolType database protocol type
*/
- void setConnectionSession(ConnectionSession connectionSession);
+ void setDatabaseProtocolType(DatabaseType protocolType);
}
diff --git
a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rul/RULBackendHandler.java
b/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rul/RULBackendHandler.java
index 7a3dcc5d455..d7ad04282e3 100644
---
a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rul/RULBackendHandler.java
+++
b/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rul/RULBackendHandler.java
@@ -18,14 +18,17 @@
package org.apache.shardingsphere.proxy.backend.handler.distsql.rul;
import lombok.RequiredArgsConstructor;
+import
org.apache.shardingsphere.distsql.handler.aware.DistSQLExecutorConnectionContextAware;
+import
org.apache.shardingsphere.distsql.handler.aware.DistSQLExecutorDatabaseAware;
+import
org.apache.shardingsphere.distsql.handler.aware.DistSQLExecutorDatabaseProtocolTypeAware;
import org.apache.shardingsphere.distsql.handler.type.rul.RULExecutor;
+import org.apache.shardingsphere.distsql.handler.util.DatabaseNameUtils;
import org.apache.shardingsphere.distsql.statement.rul.RULStatement;
import org.apache.shardingsphere.infra.merge.result.MergedResult;
import
org.apache.shardingsphere.infra.merge.result.impl.local.LocalDataMergedResult;
import org.apache.shardingsphere.infra.spi.type.typed.TypedSPILoader;
import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
import
org.apache.shardingsphere.proxy.backend.handler.distsql.DistSQLBackendHandler;
-import
org.apache.shardingsphere.proxy.backend.handler.distsql.rul.aware.ConnectionSessionAwareRULExecutor;
import org.apache.shardingsphere.proxy.backend.response.data.QueryResponseCell;
import org.apache.shardingsphere.proxy.backend.response.data.QueryResponseRow;
import org.apache.shardingsphere.proxy.backend.response.header.ResponseHeader;
@@ -67,8 +70,16 @@ public final class RULBackendHandler implements
DistSQLBackendHandler {
}
private MergedResult createMergedResult(final RULExecutor<RULStatement>
executor) throws SQLException {
- if (executor instanceof ConnectionSessionAwareRULExecutor) {
- ((ConnectionSessionAwareRULExecutor<RULStatement>)
executor).setConnectionSession(connectionSession);
+ if (executor instanceof DistSQLExecutorDatabaseAware) {
+ ((DistSQLExecutorDatabaseAware)
executor).setDatabase(ProxyContext.getInstance().getDatabase(DatabaseNameUtils.getDatabaseName(sqlStatement,
connectionSession.getDatabaseName())));
+ }
+ if (executor instanceof DistSQLExecutorDatabaseProtocolTypeAware) {
+ ((DistSQLExecutorDatabaseProtocolTypeAware)
executor).setDatabaseProtocolType(connectionSession.getProtocolType());
+ }
+ if (executor instanceof DistSQLExecutorConnectionContextAware) {
+ ((DistSQLExecutorConnectionContextAware)
executor).setConnectionContext(connectionSession.getConnectionContext());
+ ((DistSQLExecutorConnectionContextAware)
executor).setDatabaseConnectionManager(connectionSession.getDatabaseConnectionManager());
+ ((DistSQLExecutorConnectionContextAware)
executor).setStatementManager(connectionSession.getStatementManager());
}
return new LocalDataMergedResult(executor.getRows(sqlStatement,
ProxyContext.getInstance().getContextManager()));
}
diff --git
a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rul/type/FormatSQLExecutor.java
b/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rul/type/FormatSQLExecutor.java
index 54db26fcd3f..2822df53190 100644
---
a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rul/type/FormatSQLExecutor.java
+++
b/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rul/type/FormatSQLExecutor.java
@@ -18,12 +18,12 @@
package org.apache.shardingsphere.proxy.backend.handler.distsql.rul.type;
import lombok.Setter;
+import
org.apache.shardingsphere.distsql.handler.aware.DistSQLExecutorDatabaseProtocolTypeAware;
+import org.apache.shardingsphere.distsql.handler.type.rul.RULExecutor;
import org.apache.shardingsphere.distsql.statement.rul.sql.FormatStatement;
import org.apache.shardingsphere.infra.database.core.type.DatabaseType;
import
org.apache.shardingsphere.infra.merge.result.impl.local.LocalDataQueryResultRow;
import org.apache.shardingsphere.mode.manager.ContextManager;
-import
org.apache.shardingsphere.proxy.backend.handler.distsql.rul.aware.ConnectionSessionAwareRULExecutor;
-import org.apache.shardingsphere.proxy.backend.session.ConnectionSession;
import org.apache.shardingsphere.sql.parser.api.CacheOption;
import org.apache.shardingsphere.sql.parser.api.SQLFormatEngine;
@@ -35,9 +35,9 @@ import java.util.Properties;
* Format SQL executor.
*/
@Setter
-public final class FormatSQLExecutor implements
ConnectionSessionAwareRULExecutor<FormatStatement> {
+public final class FormatSQLExecutor implements RULExecutor<FormatStatement>,
DistSQLExecutorDatabaseProtocolTypeAware {
- private ConnectionSession connectionSession;
+ private DatabaseType databaseProtocolType;
@Override
public Collection<String> getColumnNames() {
@@ -46,7 +46,7 @@ public final class FormatSQLExecutor implements
ConnectionSessionAwareRULExecuto
@Override
public Collection<LocalDataQueryResultRow> getRows(final FormatStatement
sqlStatement, final ContextManager contextManager) {
- return Collections.singleton(new
LocalDataQueryResultRow(formatSQL(sqlStatement.getSql(),
connectionSession.getProtocolType())));
+ return Collections.singleton(new
LocalDataQueryResultRow(formatSQL(sqlStatement.getSql(),
databaseProtocolType)));
}
private Object formatSQL(final String sql, final DatabaseType
databaseType) {
diff --git
a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rul/type/ParseDistSQLExecutor.java
b/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rul/type/ParseDistSQLExecutor.java
index 47c523791e4..9daa213ae8c 100644
---
a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rul/type/ParseDistSQLExecutor.java
+++
b/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rul/type/ParseDistSQLExecutor.java
@@ -18,14 +18,15 @@
package org.apache.shardingsphere.proxy.backend.handler.distsql.rul.type;
import lombok.Setter;
+import
org.apache.shardingsphere.distsql.handler.aware.DistSQLExecutorDatabaseProtocolTypeAware;
+import org.apache.shardingsphere.distsql.handler.type.rul.RULExecutor;
import org.apache.shardingsphere.distsql.statement.rul.sql.ParseStatement;
+import org.apache.shardingsphere.infra.database.core.type.DatabaseType;
import
org.apache.shardingsphere.infra.merge.result.impl.local.LocalDataQueryResultRow;
import org.apache.shardingsphere.infra.metadata.ShardingSphereMetaData;
import org.apache.shardingsphere.infra.util.json.JsonUtils;
import org.apache.shardingsphere.mode.manager.ContextManager;
import org.apache.shardingsphere.parser.rule.SQLParserRule;
-import
org.apache.shardingsphere.proxy.backend.handler.distsql.rul.aware.ConnectionSessionAwareRULExecutor;
-import org.apache.shardingsphere.proxy.backend.session.ConnectionSession;
import org.apache.shardingsphere.sql.parser.sql.common.statement.SQLStatement;
import java.util.Arrays;
@@ -36,9 +37,9 @@ import java.util.Collections;
* Parse DistSQL executor.
*/
@Setter
-public final class ParseDistSQLExecutor implements
ConnectionSessionAwareRULExecutor<ParseStatement> {
+public final class ParseDistSQLExecutor implements
RULExecutor<ParseStatement>, DistSQLExecutorDatabaseProtocolTypeAware {
- private ConnectionSession connectionSession;
+ private DatabaseType databaseProtocolType;
@Override
public Collection<String> getColumnNames() {
@@ -53,7 +54,7 @@ public final class ParseDistSQLExecutor implements
ConnectionSessionAwareRULExec
private SQLStatement parseSQL(final ShardingSphereMetaData metaData, final
ParseStatement sqlStatement) {
SQLParserRule sqlParserRule =
metaData.getGlobalRuleMetaData().getSingleRule(SQLParserRule.class);
- return
sqlParserRule.getSQLParserEngine(connectionSession.getProtocolType()).parse(sqlStatement.getSql(),
false);
+ return
sqlParserRule.getSQLParserEngine(databaseProtocolType).parse(sqlStatement.getSql(),
false);
}
@Override
diff --git
a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rul/type/PreviewExecutor.java
b/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rul/type/PreviewExecutor.java
index 4f06b08af55..f13faa28131 100644
---
a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rul/type/PreviewExecutor.java
+++
b/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rul/type/PreviewExecutor.java
@@ -19,7 +19,9 @@ package
org.apache.shardingsphere.proxy.backend.handler.distsql.rul.type;
import com.google.common.base.Preconditions;
import lombok.Setter;
-import org.apache.shardingsphere.distsql.handler.util.DatabaseNameUtils;
+import
org.apache.shardingsphere.distsql.handler.aware.DistSQLExecutorConnectionContextAware;
+import
org.apache.shardingsphere.distsql.handler.aware.DistSQLExecutorDatabaseAware;
+import org.apache.shardingsphere.distsql.handler.type.rul.RULExecutor;
import org.apache.shardingsphere.distsql.statement.rul.sql.PreviewStatement;
import
org.apache.shardingsphere.infra.binder.context.aware.CursorDefinitionAware;
import
org.apache.shardingsphere.infra.binder.context.statement.SQLStatementContext;
@@ -40,7 +42,9 @@ import
org.apache.shardingsphere.infra.executor.sql.execute.engine.driver.jdbc.J
import
org.apache.shardingsphere.infra.executor.sql.execute.engine.driver.jdbc.JDBCExecutorCallback;
import
org.apache.shardingsphere.infra.executor.sql.execute.result.ExecuteResult;
import
org.apache.shardingsphere.infra.executor.sql.execute.result.query.impl.driver.jdbc.type.stream.JDBCStreamQueryResult;
+import
org.apache.shardingsphere.infra.executor.sql.prepare.driver.DatabaseConnectionManager;
import
org.apache.shardingsphere.infra.executor.sql.prepare.driver.DriverExecutionPrepareEngine;
+import
org.apache.shardingsphere.infra.executor.sql.prepare.driver.ExecutorStatementManager;
import
org.apache.shardingsphere.infra.executor.sql.prepare.driver.jdbc.JDBCDriverType;
import
org.apache.shardingsphere.infra.executor.sql.prepare.driver.jdbc.StatementOption;
import org.apache.shardingsphere.infra.hint.HintValueContext;
@@ -48,16 +52,12 @@ import org.apache.shardingsphere.infra.hint.SQLHintUtils;
import
org.apache.shardingsphere.infra.merge.result.impl.local.LocalDataQueryResultRow;
import org.apache.shardingsphere.infra.metadata.ShardingSphereMetaData;
import
org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
-import
org.apache.shardingsphere.infra.metadata.database.resource.ResourceMetaData;
+import org.apache.shardingsphere.infra.session.connection.ConnectionContext;
import org.apache.shardingsphere.infra.session.query.QueryContext;
import org.apache.shardingsphere.mode.manager.ContextManager;
import org.apache.shardingsphere.parser.rule.SQLParserRule;
-import
org.apache.shardingsphere.proxy.backend.connector.jdbc.statement.JDBCBackendStatement;
import org.apache.shardingsphere.proxy.backend.context.BackendExecutorContext;
-import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
import
org.apache.shardingsphere.proxy.backend.exception.RuleNotExistedException;
-import
org.apache.shardingsphere.proxy.backend.handler.distsql.rul.aware.ConnectionSessionAwareRULExecutor;
-import org.apache.shardingsphere.proxy.backend.session.ConnectionSession;
import org.apache.shardingsphere.sql.parser.sql.common.statement.SQLStatement;
import
org.apache.shardingsphere.sql.parser.sql.dialect.statement.mysql.dml.MySQLInsertStatement;
import org.apache.shardingsphere.sqlfederation.engine.SQLFederationEngine;
@@ -76,9 +76,17 @@ import java.util.stream.Collectors;
* Preview executor.
*/
@Setter
-public final class PreviewExecutor implements
ConnectionSessionAwareRULExecutor<PreviewStatement> {
+public final class PreviewExecutor implements RULExecutor<PreviewStatement>,
DistSQLExecutorDatabaseAware, DistSQLExecutorConnectionContextAware {
- private ConnectionSession connectionSession;
+ private ShardingSphereDatabase database;
+
+ private ConnectionContext connectionContext;
+
+ @SuppressWarnings("rawtypes")
+ private DatabaseConnectionManager databaseConnectionManager;
+
+ @SuppressWarnings("rawtypes")
+ private ExecutorStatementManager statementManager;
@Override
public Collection<String> getColumnNames() {
@@ -88,7 +96,6 @@ public final class PreviewExecutor implements
ConnectionSessionAwareRULExecutor<
@Override
public Collection<LocalDataQueryResultRow> getRows(final PreviewStatement
sqlStatement, final ContextManager contextManager) throws SQLException {
ShardingSphereMetaData metaData =
contextManager.getMetaDataContexts().getMetaData();
- ShardingSphereDatabase database =
ProxyContext.getInstance().getDatabase(DatabaseNameUtils.getDatabaseName(sqlStatement,
connectionSession.getDatabaseName()));
String toBePreviewedSQL =
SQLHintUtils.removeHint(sqlStatement.getSql());
HintValueContext hintValueContext =
SQLHintUtils.extractHint(sqlStatement.getSql()).orElseGet(HintValueContext::new);
SQLStatement toBePreviewedStatement =
metaData.getGlobalRuleMetaData().getSingleRule(SQLParserRule.class).getSQLParserEngine(database.getProtocolType()).parse(toBePreviewedSQL,
false);
@@ -101,11 +108,11 @@ public final class PreviewExecutor implements
ConnectionSessionAwareRULExecutor<
String schemaName =
queryContext.getSqlStatementContext().getTablesContext().getSchemaName()
.orElseGet(() -> new
DatabaseTypeRegistry(database.getProtocolType()).getDefaultSchemaName(database.getName()));
SQLFederationEngine federationEngine = new
SQLFederationEngine(database.getName(), schemaName, metaData,
contextManager.getMetaDataContexts().getStatistics(),
- new
JDBCExecutor(BackendExecutorContext.getInstance().getExecutorEngine(),
connectionSession.getConnectionContext()));
+ new
JDBCExecutor(BackendExecutorContext.getInstance().getExecutorEngine(),
connectionContext));
Collection<ExecutionUnit> executionUnits =
federationEngine.decide(queryContext.getSqlStatementContext(),
queryContext.getParameters(), database, metaData.getGlobalRuleMetaData())
- ? getFederationExecutionUnits(queryContext, metaData,
database, federationEngine)
+ ? getFederationExecutionUnits(queryContext, metaData,
federationEngine)
: new KernelProcessor().generateExecutionContext(
- queryContext, database,
metaData.getGlobalRuleMetaData(), metaData.getProps(),
connectionSession.getConnectionContext()).getExecutionUnits();
+ queryContext, database,
metaData.getGlobalRuleMetaData(), metaData.getProps(),
connectionContext).getExecutionUnits();
return executionUnits.stream().map(each -> new
LocalDataQueryResultRow(each.getDataSourceName(),
each.getSqlUnit().getSql())).collect(Collectors.toList());
}
@@ -114,24 +121,23 @@ public final class PreviewExecutor implements
ConnectionSessionAwareRULExecutor<
return;
}
String cursorName = ((CursorAvailable)
toBePreviewedStatementContext).getCursorName().get().getIdentifier().getValue().toLowerCase();
- CursorStatementContext cursorStatementContext =
(CursorStatementContext)
connectionSession.getConnectionContext().getCursorContext().getCursorDefinitions().get(cursorName);
+ CursorStatementContext cursorStatementContext =
(CursorStatementContext)
connectionContext.getCursorContext().getCursorDefinitions().get(cursorName);
Preconditions.checkNotNull(cursorStatementContext, "Cursor %s does not
exist.", cursorName);
((CursorDefinitionAware)
toBePreviewedStatementContext).setUpCursorDefinition(cursorStatementContext);
}
- private Collection<ExecutionUnit> getFederationExecutionUnits(final
QueryContext queryContext, final ShardingSphereMetaData metaData,
- final
ShardingSphereDatabase database, final SQLFederationEngine federationEngine) {
+ private Collection<ExecutionUnit> getFederationExecutionUnits(final
QueryContext queryContext, final ShardingSphereMetaData metaData, final
SQLFederationEngine federationEngine) {
SQLStatement sqlStatement =
queryContext.getSqlStatementContext().getSqlStatement();
// TODO move dialect MySQLInsertStatement into database type module
@zhangliang
boolean isReturnGeneratedKeys = sqlStatement instanceof
MySQLInsertStatement;
- DriverExecutionPrepareEngine<JDBCExecutionUnit, Connection>
prepareEngine = createDriverExecutionPrepareEngine(isReturnGeneratedKeys,
metaData.getProps(), database);
+ DriverExecutionPrepareEngine<JDBCExecutionUnit, Connection>
prepareEngine = createDriverExecutionPrepareEngine(isReturnGeneratedKeys,
metaData.getProps());
SQLFederationExecutorContext context = new
SQLFederationExecutorContext(true, queryContext, metaData);
- federationEngine.executeQuery(prepareEngine,
createPreviewFederationCallback(database.getProtocolType(),
database.getResourceMetaData(), sqlStatement), context);
+ federationEngine.executeQuery(prepareEngine,
createPreviewFederationCallback(sqlStatement), context);
return context.getExecutionUnits();
}
- private JDBCExecutorCallback<ExecuteResult>
createPreviewFederationCallback(final DatabaseType protocolType, final
ResourceMetaData resourceMetaData, final SQLStatement sqlStatement) {
- return new JDBCExecutorCallback<ExecuteResult>(protocolType,
resourceMetaData, sqlStatement,
SQLExecutorExceptionHandler.isExceptionThrown()) {
+ private JDBCExecutorCallback<ExecuteResult>
createPreviewFederationCallback(final SQLStatement sqlStatement) {
+ return new
JDBCExecutorCallback<ExecuteResult>(database.getProtocolType(),
database.getResourceMetaData(), sqlStatement,
SQLExecutorExceptionHandler.isExceptionThrown()) {
@Override
protected ExecuteResult executeSQL(final String sql, final
Statement statement, final ConnectionMode connectionMode, final DatabaseType
storageType) throws SQLException {
@@ -145,11 +151,10 @@ public final class PreviewExecutor implements
ConnectionSessionAwareRULExecutor<
};
}
- private DriverExecutionPrepareEngine<JDBCExecutionUnit, Connection>
createDriverExecutionPrepareEngine(final boolean isReturnGeneratedKeys,
-
final ConfigurationProperties props, final
ShardingSphereDatabase database) {
+ @SuppressWarnings({"unchecked", "rawtypes"})
+ private DriverExecutionPrepareEngine<JDBCExecutionUnit, Connection>
createDriverExecutionPrepareEngine(final boolean isReturnGeneratedKeys, final
ConfigurationProperties props) {
int maxConnectionsSizePerQuery =
props.<Integer>getValue(ConfigurationPropertyKey.MAX_CONNECTIONS_SIZE_PER_QUERY);
- return new DriverExecutionPrepareEngine<>(JDBCDriverType.STATEMENT,
maxConnectionsSizePerQuery,
- connectionSession.getDatabaseConnectionManager(),
(JDBCBackendStatement) connectionSession.getStatementManager(),
+ return new DriverExecutionPrepareEngine<>(JDBCDriverType.STATEMENT,
maxConnectionsSizePerQuery, databaseConnectionManager, statementManager,
new StatementOption(isReturnGeneratedKeys),
database.getRuleMetaData().getRules(),
database.getResourceMetaData().getStorageUnits());
}