You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by ch...@apache.org on 2026/08/10 05:40:20 UTC
(shardingsphere) branch master updated: Minor refactor for CreateDatabaseObjectStatementContext (#39391)
This is an automated email from the ASF dual-hosted git repository.
FlyingZC 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 adb3c6fdcbb Minor refactor for CreateDatabaseObjectStatementContext (#39391)
adb3c6fdcbb is described below
commit adb3c6fdcbbd28ef8d1eda778b40e8432cddceb2
Author: Zhengqiang Duan <du...@apache.org>
AuthorDate: Mon Aug 10 13:40:13 2026 +0800
Minor refactor for CreateDatabaseObjectStatementContext (#39391)
* Minor refactor for CreateDatabaseObjectStatementContext
* Fix passthrough e2e case
---
.../ShardingCreateProcedureSupportedChecker.java | 11 +--
...hardingCreateProcedureSupportedCheckerTest.java | 17 ++--
.../binder/context/SQLStatementContextFactory.java | 4 +-
.../ddl/CreateDatabaseObjectStatementContext.java | 93 ++++++++++++++++++++++
.../type/ddl/CreateProcedureStatementContext.java | 48 -----------
.../CreateDatabaseObjectStatementContextTest.java | 82 +++++++++++++++++++
.../ddl/CreateProcedureStatementContextTest.java | 35 --------
.../select_aliased_system_variables_with_scope.xml | 2 +-
.../cases/dal/dataset/select_system_variables.xml | 2 +-
9 files changed, 195 insertions(+), 99 deletions(-)
diff --git a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/checker/sql/ddl/ShardingCreateProcedureSupportedChecker.java b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/checker/sql/ddl/ShardingCreateProcedureSupportedChecker.java
index cf439b651be..39b8b5456c5 100644
--- a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/checker/sql/ddl/ShardingCreateProcedureSupportedChecker.java
+++ b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/checker/sql/ddl/ShardingCreateProcedureSupportedChecker.java
@@ -18,7 +18,7 @@
package org.apache.shardingsphere.sharding.checker.sql.ddl;
import org.apache.shardingsphere.infra.binder.context.statement.SQLStatementContext;
-import org.apache.shardingsphere.infra.binder.context.statement.type.ddl.CreateProcedureStatementContext;
+import org.apache.shardingsphere.infra.binder.context.statement.type.ddl.CreateDatabaseObjectStatementContext;
import org.apache.shardingsphere.infra.checker.SupportedSQLChecker;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
import org.apache.shardingsphere.infra.metadata.database.schema.model.ShardingSphereSchema;
@@ -35,16 +35,17 @@ import java.util.Optional;
/**
* Create procedure supported checker for sharding.
*/
-public final class ShardingCreateProcedureSupportedChecker implements SupportedSQLChecker<CreateProcedureStatementContext, ShardingRule> {
+public final class ShardingCreateProcedureSupportedChecker implements SupportedSQLChecker<CreateDatabaseObjectStatementContext, ShardingRule> {
@Override
public boolean isCheck(final SQLStatementContext sqlStatementContext) {
- return sqlStatementContext instanceof CreateProcedureStatementContext;
+ return sqlStatementContext instanceof CreateDatabaseObjectStatementContext && sqlStatementContext.getSqlStatement() instanceof CreateProcedureStatement;
}
@Override
- public void check(final ShardingRule rule, final ShardingSphereDatabase database, final ShardingSphereSchema currentSchema, final CreateProcedureStatementContext sqlStatementContext) {
- CreateProcedureStatement createProcedureStatement = sqlStatementContext.getSqlStatement();
+ public void check(final ShardingRule rule, final ShardingSphereDatabase database, final ShardingSphereSchema currentSchema,
+ final CreateDatabaseObjectStatementContext sqlStatementContext) {
+ CreateProcedureStatement createProcedureStatement = (CreateProcedureStatement) sqlStatementContext.getSqlStatement();
Optional<RoutineBodySegment> routineBodySegment = createProcedureStatement.getRoutineBody();
if (!routineBodySegment.isPresent()) {
return;
diff --git a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/checker/sql/ddl/ShardingCreateProcedureSupportedCheckerTest.java b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/checker/sql/ddl/ShardingCreateProcedureSupportedCheckerTest.java
index 469b66792b3..90415c9f59b 100644
--- a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/checker/sql/ddl/ShardingCreateProcedureSupportedCheckerTest.java
+++ b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/checker/sql/ddl/ShardingCreateProcedureSupportedCheckerTest.java
@@ -20,7 +20,8 @@ package org.apache.shardingsphere.sharding.checker.sql.ddl;
import org.apache.shardingsphere.database.connector.core.type.DatabaseType;
import org.apache.shardingsphere.database.exception.core.exception.syntax.table.NoSuchTableException;
import org.apache.shardingsphere.database.exception.core.exception.syntax.table.TableExistsException;
-import org.apache.shardingsphere.infra.binder.context.statement.type.ddl.CreateProcedureStatementContext;
+import org.apache.shardingsphere.infra.binder.context.statement.type.ddl.CreateDatabaseObjectStatementContext;
+import org.apache.shardingsphere.infra.metadata.ShardingSphereMetaData;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
import org.apache.shardingsphere.infra.metadata.database.schema.model.ShardingSphereSchema;
import org.apache.shardingsphere.infra.spi.type.typed.TypedSPILoader;
@@ -76,7 +77,7 @@ class ShardingCreateProcedureSupportedCheckerTest {
when(schema.containsTable(new IdentifierValue("bar_tbl"))).thenReturn(true);
when(schema.containsTable(new IdentifierValue("foo_tbl"))).thenReturn(false);
when(rule.isShardingTable("bar_tbl")).thenReturn(false);
- CreateProcedureStatementContext sqlStatementContext = new CreateProcedureStatementContext(sqlStatement);
+ CreateDatabaseObjectStatementContext sqlStatementContext = new CreateDatabaseObjectStatementContext(sqlStatement, "foo_db", mock(ShardingSphereMetaData.class));
ShardingSphereDatabase database = mock(ShardingSphereDatabase.class, RETURNS_DEEP_STUBS);
assertDoesNotThrow(() -> new ShardingCreateProcedureSupportedChecker().check(rule, database, schema, sqlStatementContext));
}
@@ -93,10 +94,11 @@ class ShardingCreateProcedureSupportedCheckerTest {
routineBody.getValidStatements().add(validStatementSegment);
CreateProcedureStatement sqlStatement = new CreateProcedureStatement(databaseType);
sqlStatement.setRoutineBody(routineBody);
- CreateProcedureStatementContext sqlStatementContext = new CreateProcedureStatementContext(sqlStatement);
+ CreateDatabaseObjectStatementContext sqlStatementContext = new CreateDatabaseObjectStatementContext(sqlStatement, "foo_db", mock(ShardingSphereMetaData.class));
ShardingSphereDatabase database = mock(ShardingSphereDatabase.class, RETURNS_DEEP_STUBS);
when(rule.isShardingTable("foo_tbl")).thenReturn(true);
- assertThrows(UnsupportedShardingOperationException.class, () -> new ShardingCreateProcedureSupportedChecker().check(rule, database, mock(), sqlStatementContext));
+ assertThrows(UnsupportedShardingOperationException.class,
+ () -> new ShardingCreateProcedureSupportedChecker().check(rule, database, mock(), sqlStatementContext));
}
@Test
@@ -111,9 +113,10 @@ class ShardingCreateProcedureSupportedCheckerTest {
routineBody.getValidStatements().add(validStatementSegment);
CreateProcedureStatement sqlStatement = mock(CreateProcedureStatement.class);
when(sqlStatement.getRoutineBody()).thenReturn(Optional.of(routineBody));
- CreateProcedureStatementContext sqlStatementContext = new CreateProcedureStatementContext(sqlStatement);
+ CreateDatabaseObjectStatementContext sqlStatementContext = new CreateDatabaseObjectStatementContext(sqlStatement, "foo_db", mock(ShardingSphereMetaData.class));
ShardingSphereDatabase database = mock(ShardingSphereDatabase.class, RETURNS_DEEP_STUBS);
- assertThrows(NoSuchTableException.class, () -> new ShardingCreateProcedureSupportedChecker().check(rule, database, mock(), sqlStatementContext));
+ assertThrows(NoSuchTableException.class,
+ () -> new ShardingCreateProcedureSupportedChecker().check(rule, database, mock(), sqlStatementContext));
}
@Test
@@ -128,7 +131,7 @@ class ShardingCreateProcedureSupportedCheckerTest {
routineBody.getValidStatements().add(validStatementSegment);
CreateProcedureStatement sqlStatement = mock(CreateProcedureStatement.class);
when(sqlStatement.getRoutineBody()).thenReturn(Optional.of(routineBody));
- CreateProcedureStatementContext sqlStatementContext = new CreateProcedureStatementContext(sqlStatement);
+ CreateDatabaseObjectStatementContext sqlStatementContext = new CreateDatabaseObjectStatementContext(sqlStatement, "foo_db", mock(ShardingSphereMetaData.class));
ShardingSphereDatabase database = mock(ShardingSphereDatabase.class, RETURNS_DEEP_STUBS);
ShardingSphereSchema schema = mock(ShardingSphereSchema.class);
when(schema.containsTable(new IdentifierValue("foo_tbl"))).thenReturn(true);
diff --git a/infra/binder/core/src/main/java/org/apache/shardingsphere/infra/binder/context/SQLStatementContextFactory.java b/infra/binder/core/src/main/java/org/apache/shardingsphere/infra/binder/context/SQLStatementContextFactory.java
index 2f8dec5658e..253fc470c9f 100644
--- a/infra/binder/core/src/main/java/org/apache/shardingsphere/infra/binder/context/SQLStatementContextFactory.java
+++ b/infra/binder/core/src/main/java/org/apache/shardingsphere/infra/binder/context/SQLStatementContextFactory.java
@@ -24,7 +24,7 @@ import org.apache.shardingsphere.infra.binder.context.statement.SQLStatementCont
import org.apache.shardingsphere.infra.binder.context.statement.type.CommonSQLStatementContext;
import org.apache.shardingsphere.infra.binder.context.statement.type.dal.ExplainStatementContext;
import org.apache.shardingsphere.infra.binder.context.statement.type.ddl.AlterViewStatementContext;
-import org.apache.shardingsphere.infra.binder.context.statement.type.ddl.CreateProcedureStatementContext;
+import org.apache.shardingsphere.infra.binder.context.statement.type.ddl.CreateDatabaseObjectStatementContext;
import org.apache.shardingsphere.infra.binder.context.statement.type.ddl.CreateViewStatementContext;
import org.apache.shardingsphere.infra.binder.context.statement.type.ddl.CursorHeldSQLStatementContext;
import org.apache.shardingsphere.infra.binder.context.statement.type.ddl.CursorStatementContext;
@@ -105,7 +105,7 @@ public final class SQLStatementContextFactory {
private static SQLStatementContext getDDLStatementContext(final ShardingSphereMetaData metaData, final DDLStatement sqlStatement, final String currentDatabaseName) {
if (sqlStatement instanceof CreateProcedureStatement) {
- return new CreateProcedureStatementContext((CreateProcedureStatement) sqlStatement);
+ return new CreateDatabaseObjectStatementContext((CreateProcedureStatement) sqlStatement, currentDatabaseName, metaData);
}
if (sqlStatement instanceof CreateViewStatement) {
return new CreateViewStatementContext(metaData, (CreateViewStatement) sqlStatement, currentDatabaseName);
diff --git a/infra/binder/core/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/type/ddl/CreateDatabaseObjectStatementContext.java b/infra/binder/core/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/type/ddl/CreateDatabaseObjectStatementContext.java
new file mode 100644
index 00000000000..a4f7cb9a6bb
--- /dev/null
+++ b/infra/binder/core/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/type/ddl/CreateDatabaseObjectStatementContext.java
@@ -0,0 +1,93 @@
+/*
+ * 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.type.ddl;
+
+import lombok.Getter;
+import org.apache.shardingsphere.infra.binder.context.SQLStatementContextFactory;
+import org.apache.shardingsphere.infra.binder.context.segment.table.TablesContext;
+import org.apache.shardingsphere.infra.binder.context.statement.SQLStatementContext;
+import org.apache.shardingsphere.infra.binder.engine.SQLBindEngine;
+import org.apache.shardingsphere.infra.hint.HintValueContext;
+import org.apache.shardingsphere.infra.metadata.ShardingSphereMetaData;
+import org.apache.shardingsphere.sql.parser.statement.core.extractor.TableExtractor;
+import org.apache.shardingsphere.sql.parser.statement.core.segment.ddl.routine.RoutineBodySegment;
+import org.apache.shardingsphere.sql.parser.statement.core.segment.generic.table.SimpleTableSegment;
+import org.apache.shardingsphere.sql.parser.statement.core.segment.procedure.SQLStatementSegment;
+import org.apache.shardingsphere.sql.parser.statement.core.statement.SQLStatement;
+import org.apache.shardingsphere.sql.parser.statement.core.statement.attribute.type.TableSQLStatementAttribute;
+import org.apache.shardingsphere.sql.parser.statement.core.statement.type.ddl.function.CreateFunctionStatement;
+import org.apache.shardingsphere.sql.parser.statement.core.statement.type.ddl.procedure.CreateProcedureStatement;
+import org.apache.shardingsphere.sql.parser.statement.core.statement.type.ddl.trigger.CreateTriggerStatement;
+
+import java.util.Collection;
+import java.util.Collections;
+import java.util.LinkedList;
+import java.util.Optional;
+
+/**
+ * Create database object statement context.
+ */
+@Getter
+public final class CreateDatabaseObjectStatementContext implements SQLStatementContext {
+
+ private final SQLStatement sqlStatement;
+
+ private final TablesContext tablesContext;
+
+ private final Collection<SQLStatementContext> sqlStatementContexts = new LinkedList<>();
+
+ public CreateDatabaseObjectStatementContext(final CreateFunctionStatement sqlStatement, final String currentDatabaseName, final ShardingSphereMetaData metaData) {
+ this(sqlStatement, sqlStatement.getSqlStatements(), currentDatabaseName, metaData);
+ }
+
+ public CreateDatabaseObjectStatementContext(final CreateTriggerStatement sqlStatement, final String currentDatabaseName, final ShardingSphereMetaData metaData) {
+ this(sqlStatement, sqlStatement.getSqlStatements(), currentDatabaseName, metaData);
+ }
+
+ public CreateDatabaseObjectStatementContext(final CreateProcedureStatement sqlStatement, final String currentDatabaseName, final ShardingSphereMetaData metaData) {
+ this(sqlStatement, sqlStatement.getSqlStatements(), currentDatabaseName, metaData);
+ }
+
+ private CreateDatabaseObjectStatementContext(final SQLStatement sqlStatement, final Collection<SQLStatementSegment> internalSqlStatements,
+ final String currentDatabaseName, final ShardingSphereMetaData metaData) {
+ this.sqlStatement = sqlStatement;
+ Collection<SimpleTableSegment> tables = new LinkedList<>(extractTables(sqlStatement));
+ SQLBindEngine sqlBindEngine = new SQLBindEngine(metaData, currentDatabaseName, new HintValueContext());
+ for (SQLStatementSegment each : internalSqlStatements) {
+ SQLStatementContext sqlStatementContext = createInternalSQLStatementContext(sqlBindEngine, sqlStatement, each, currentDatabaseName, metaData);
+ sqlStatementContexts.add(sqlStatementContext);
+ tables.addAll(sqlStatementContext.getTablesContext().getSimpleTables());
+ }
+ tablesContext = new TablesContext(tables);
+ }
+
+ private SQLStatementContext createInternalSQLStatementContext(final SQLBindEngine sqlBindEngine, final SQLStatement sqlStatement, final SQLStatementSegment segment,
+ final String currentDatabaseName, final ShardingSphereMetaData metaData) {
+ return sqlStatement instanceof CreateProcedureStatement
+ ? SQLStatementContextFactory.newInstance(metaData, segment.getSqlStatement(), currentDatabaseName)
+ : sqlBindEngine.bind(segment.getSqlStatement());
+ }
+
+ private Collection<SimpleTableSegment> extractTables(final SQLStatement sqlStatement) {
+ if (sqlStatement instanceof CreateProcedureStatement) {
+ Optional<RoutineBodySegment> routineBody = ((CreateProcedureStatement) sqlStatement).getRoutineBody();
+ return routineBody.map(optional -> new TableExtractor().extractExistTableFromRoutineBody(optional)).orElseGet(Collections::emptyList);
+ }
+ return sqlStatement.getAttributes().findAttribute(TableSQLStatementAttribute.class).map(TableSQLStatementAttribute::getTables).orElseGet(Collections::emptyList);
+ }
+}
diff --git a/infra/binder/core/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/type/ddl/CreateProcedureStatementContext.java b/infra/binder/core/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/type/ddl/CreateProcedureStatementContext.java
deleted file mode 100644
index b3ae6f7869a..00000000000
--- a/infra/binder/core/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/type/ddl/CreateProcedureStatementContext.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.type.ddl;
-
-import lombok.Getter;
-import org.apache.shardingsphere.infra.binder.context.segment.table.TablesContext;
-import org.apache.shardingsphere.infra.binder.context.statement.SQLStatementContext;
-import org.apache.shardingsphere.sql.parser.statement.core.extractor.TableExtractor;
-import org.apache.shardingsphere.sql.parser.statement.core.segment.ddl.routine.RoutineBodySegment;
-import org.apache.shardingsphere.sql.parser.statement.core.segment.generic.table.SimpleTableSegment;
-import org.apache.shardingsphere.sql.parser.statement.core.statement.type.ddl.procedure.CreateProcedureStatement;
-
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Optional;
-
-/**
- * Create procedure statement context.
- */
-@Getter
-public final class CreateProcedureStatementContext implements SQLStatementContext {
-
- private final CreateProcedureStatement sqlStatement;
-
- private final TablesContext tablesContext;
-
- public CreateProcedureStatementContext(final CreateProcedureStatement sqlStatement) {
- this.sqlStatement = sqlStatement;
- Optional<RoutineBodySegment> routineBodySegment = sqlStatement.getRoutineBody();
- Collection<SimpleTableSegment> tables = routineBodySegment.map(optional -> new TableExtractor().extractExistTableFromRoutineBody(optional)).orElseGet(Collections::emptyList);
- tablesContext = new TablesContext(tables);
- }
-}
diff --git a/infra/binder/core/src/test/java/org/apache/shardingsphere/infra/binder/context/statement/type/ddl/CreateDatabaseObjectStatementContextTest.java b/infra/binder/core/src/test/java/org/apache/shardingsphere/infra/binder/context/statement/type/ddl/CreateDatabaseObjectStatementContextTest.java
new file mode 100644
index 00000000000..21442077880
--- /dev/null
+++ b/infra/binder/core/src/test/java/org/apache/shardingsphere/infra/binder/context/statement/type/ddl/CreateDatabaseObjectStatementContextTest.java
@@ -0,0 +1,82 @@
+/*
+ * 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.type.ddl;
+
+import org.apache.shardingsphere.database.connector.core.type.DatabaseType;
+import org.apache.shardingsphere.infra.metadata.ShardingSphereMetaData;
+import org.apache.shardingsphere.infra.spi.type.typed.TypedSPILoader;
+import org.apache.shardingsphere.sql.parser.statement.core.segment.generic.table.SimpleTableSegment;
+import org.apache.shardingsphere.sql.parser.statement.core.segment.generic.table.TableNameSegment;
+import org.apache.shardingsphere.sql.parser.statement.core.segment.procedure.SQLStatementSegment;
+import org.apache.shardingsphere.sql.parser.statement.core.statement.SQLStatement;
+import org.apache.shardingsphere.sql.parser.statement.core.statement.attribute.SQLStatementAttributes;
+import org.apache.shardingsphere.sql.parser.statement.core.statement.attribute.type.TableSQLStatementAttribute;
+import org.apache.shardingsphere.sql.parser.statement.core.statement.type.ddl.procedure.CreateProcedureStatement;
+import org.apache.shardingsphere.sql.parser.statement.core.statement.type.ddl.trigger.CreateTriggerStatement;
+import org.apache.shardingsphere.sql.parser.statement.core.value.identifier.IdentifierValue;
+import org.junit.jupiter.api.Test;
+
+import java.util.Collections;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.is;
+import static org.mockito.Mockito.mock;
+
+class CreateDatabaseObjectStatementContextTest {
+
+ private final DatabaseType databaseType = TypedSPILoader.getService(DatabaseType.class, "FIXTURE");
+
+ @Test
+ void assertNewInstanceWithTriggerTable() {
+ CreateTriggerStatement statement = new CreateTriggerStatement(databaseType);
+ statement.setTable(new SimpleTableSegment(new TableNameSegment(28, 36, new IdentifierValue("t_account"))));
+ CreateDatabaseObjectStatementContext actual = new CreateDatabaseObjectStatementContext(statement, "foo_db", mock(ShardingSphereMetaData.class));
+ assertThat(actual.getSqlStatement(), is(statement));
+ assertThat(actual.getTablesContext().getSimpleTables().iterator().next().getTableName().getIdentifier().getValue(), is("t_account"));
+ }
+
+ @Test
+ void assertNewInstanceWithProcedure() {
+ CreateProcedureStatement sqlStatement = mock(CreateProcedureStatement.class);
+ CreateDatabaseObjectStatementContext actual = new CreateDatabaseObjectStatementContext(sqlStatement, "foo_db", mock(ShardingSphereMetaData.class));
+ assertThat(actual.getSqlStatement(), is(sqlStatement));
+ }
+
+ @Test
+ void assertNewInstanceWithProcedureInternalSQLTablesContext() {
+ CreateProcedureStatement sqlStatement = new CreateProcedureStatement(databaseType);
+ sqlStatement.getSqlStatements().add(new SQLStatementSegment(0, 0, new TableAwareSQLStatement("t_encrypt")));
+ CreateDatabaseObjectStatementContext actual = new CreateDatabaseObjectStatementContext(sqlStatement, "foo_db", mock(ShardingSphereMetaData.class));
+ assertThat(actual.getTablesContext().getTableNames(), is(Collections.singleton("t_encrypt")));
+ }
+
+ private static final class TableAwareSQLStatement extends SQLStatement {
+
+ private final SQLStatementAttributes attributes;
+
+ private TableAwareSQLStatement(final String tableName) {
+ super(TypedSPILoader.getService(DatabaseType.class, "FIXTURE"));
+ attributes = new SQLStatementAttributes(new TableSQLStatementAttribute(new SimpleTableSegment(new TableNameSegment(0, tableName.length(), new IdentifierValue(tableName)))));
+ }
+
+ @Override
+ public SQLStatementAttributes getAttributes() {
+ return attributes;
+ }
+ }
+}
diff --git a/infra/binder/core/src/test/java/org/apache/shardingsphere/infra/binder/context/statement/type/ddl/CreateProcedureStatementContextTest.java b/infra/binder/core/src/test/java/org/apache/shardingsphere/infra/binder/context/statement/type/ddl/CreateProcedureStatementContextTest.java
deleted file mode 100644
index 4826baf043e..00000000000
--- a/infra/binder/core/src/test/java/org/apache/shardingsphere/infra/binder/context/statement/type/ddl/CreateProcedureStatementContextTest.java
+++ /dev/null
@@ -1,35 +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.type.ddl;
-
-import org.apache.shardingsphere.sql.parser.statement.core.statement.type.ddl.procedure.CreateProcedureStatement;
-import org.junit.jupiter.api.Test;
-
-import static org.hamcrest.Matchers.is;
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.mockito.Mockito.mock;
-
-class CreateProcedureStatementContextTest {
-
- @Test
- void assertNewInstance() {
- CreateProcedureStatement sqlStatement = mock(CreateProcedureStatement.class);
- CreateProcedureStatementContext actual = new CreateProcedureStatementContext(sqlStatement);
- assertThat(actual.getSqlStatement(), is(sqlStatement));
- }
-}
diff --git a/test/e2e/sql/src/test/resources/cases/dal/dataset/select_aliased_system_variables_with_scope.xml b/test/e2e/sql/src/test/resources/cases/dal/dataset/select_aliased_system_variables_with_scope.xml
index 2d3df7306d1..f764b48c3cd 100644
--- a/test/e2e/sql/src/test/resources/cases/dal/dataset/select_aliased_system_variables_with_scope.xml
+++ b/test/e2e/sql/src/test/resources/cases/dal/dataset/select_aliased_system_variables_with_scope.xml
@@ -460,5 +460,5 @@
<column name="thread_concurrency" />
<column name="timed_mutexes" />
</metadata>
- <row values="0, , 33062, , , , , , , , , TLSv1.2,TLSv1.3, *,,, 1, 1, 1, 1, 1, 0, 0, , 0, *, 32768, 0, 0, 1, 2592000, 0, 0, 1, 0, 1, 0, 8192, 0, 32768, 0, 3, 25000, , 8388608, utf8mb4, utf8mb4, utf8mb4, binary, null, utf8mb4, utf8mb4, , 0, utf8mb4_unicode_ci, utf8mb4_unicode_ci, utf8mb4_unicode_ci, 10, 8912, 18446744073709551615, 0, 0, 1000, , , caching_sha2_password, utf8mb4_unicode_ci, 0, , 0, , 0, 100, 300, 1000, , 1, 4, 0, FALSE, 200, 0, 0, 1, , 0, 0, 1, + -><()~*:"&quo [...]
+ <row values="0, , 33062, , , , , , , , , TLSv1.2,TLSv1.3, *,,, 1, 1, 1, 1, 1, 0, 0, , 0, *, 32768, 0, 0, 1, 2592000, 0, 0, 1, 0, 1, 0, 8192, 0, 32768, 0, 3, 25000, , 8388608, utf8mb4, utf8mb4, utf8mb4, binary, NOT_VERIFY, utf8mb4, utf8mb4, , 0, NOT_VERIFY, NOT_VERIFY, NOT_VERIFY, 10, 8912, 18446744073709551615, 0, 0, 1000, , , caching_sha2_password, NOT_VERIFY, 0, , 0, , 0, 100, 300, 1000, , 1, 4, 0, FALSE, 200, 0, 0, 1, , 0, 0, 1, + -><()~*:""&|, 84, 4, 20, , 0, [...]
</dataset>
diff --git a/test/e2e/sql/src/test/resources/cases/dal/dataset/select_system_variables.xml b/test/e2e/sql/src/test/resources/cases/dal/dataset/select_system_variables.xml
index 0fc80c46a2c..07dbb447cc5 100644
--- a/test/e2e/sql/src/test/resources/cases/dal/dataset/select_system_variables.xml
+++ b/test/e2e/sql/src/test/resources/cases/dal/dataset/select_system_variables.xml
@@ -460,5 +460,5 @@
<column name="@@thread_concurrency" />
<column name="@@timed_mutexes" />
</metadata>
- <row values="0, , 33062, , , , , , , , , TLSv1.2,TLSv1.3, *,,, 1, 1, 1, 1, 1, 0, 0, , 0, *, 32768, 0, 0, 1, 2592000, 0, 0, 1, 0, 1, 0, 8192, 0, 32768, 0, 3, 25000, , 8388608, utf8mb4, utf8mb4, utf8mb4, binary, null, utf8mb4, utf8mb4, , 0, utf8mb4_unicode_ci, utf8mb4_unicode_ci, utf8mb4_unicode_ci, 10, 8912, 18446744073709551615, 0, 0, 1000, , , caching_sha2_password, utf8mb4_unicode_ci, 0, , 0, , 0, 100, 300, 1000, , 1, 4, 0, FALSE, 200, 0, 0, 1, , 0, 0, 1, + -><()~*:"&quo [...]
+ <row values="0, , 33062, , , , , , , , , TLSv1.2,TLSv1.3, *,,, 1, 1, 1, 1, 1, 0, 0, , 0, *, 32768, 0, 0, 1, 2592000, 0, 0, 1, 0, 1, 0, 8192, 0, 32768, 0, 3, 25000, , 8388608, utf8mb4, utf8mb4, utf8mb4, binary, NOT_VERIFY, utf8mb4, utf8mb4, , 0, NOT_VERIFY, NOT_VERIFY, NOT_VERIFY, 10, 8912, 18446744073709551615, 0, 0, 1000, , , caching_sha2_password, NOT_VERIFY, 0, , 0, , 0, 100, 300, 1000, , 1, 4, 0, FALSE, 200, 0, 0, 1, , 0, 0, 1, + -><()~*:""&|, 84, 4, 20, , 0, [...]
</dataset>