You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by tu...@apache.org on 2022/04/27 09:04:27 UTC
[shardingsphere] branch master updated: Optimize create function and procedure validator logic (#17145)
This is an automated email from the ASF dual-hosted git repository.
tuichenchuxin 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 943d9ebd6fb Optimize create function and procedure validator logic (#17145)
943d9ebd6fb is described below
commit 943d9ebd6fb914179e5ba360e5b33ed4dfa41b52
Author: Zhengqiang Duan <du...@apache.org>
AuthorDate: Wed Apr 27 17:04:05 2022 +0800
Optimize create function and procedure validator logic (#17145)
---
.../ShardingCreateFunctionStatementValidator.java | 17 +++++---
.../ShardingCreateProcedureStatementValidator.java | 18 +++++---
...ardingCreateFunctionStatementValidatorTest.java | 7 ++-
...rdingCreateProcedureStatementValidatorTest.java | 9 ++--
.../impl/MySQLDDLStatementSQLVisitor.java | 14 ++++++
.../segment/ddl/routine/FunctionNameSegment.java | 50 ++++++++++++++++++++++
.../statement/ddl/CreateFunctionStatement.java | 18 ++++++++
.../statement/ddl/CreateProcedureStatement.java | 18 ++++++++
8 files changed, 134 insertions(+), 17 deletions(-)
diff --git a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/route/engine/validator/ddl/impl/ShardingCreateFunctionStatementValidator.java b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/route/engine/validator/ddl/impl/ShardingCreateFunctionStatementValidator.java
index 02e17b6ff0d..2fe2732f32d 100644
--- a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/route/engine/validator/ddl/impl/ShardingCreateFunctionStatementValidator.java
+++ b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/route/engine/validator/ddl/impl/ShardingCreateFunctionStatementValidator.java
@@ -20,6 +20,7 @@ package org.apache.shardingsphere.sharding.route.engine.validator.ddl.impl;
import org.apache.shardingsphere.infra.binder.statement.SQLStatementContext;
import org.apache.shardingsphere.infra.config.props.ConfigurationProperties;
import org.apache.shardingsphere.infra.metadata.ShardingSphereMetaData;
+import org.apache.shardingsphere.infra.metadata.schema.ShardingSphereSchema;
import org.apache.shardingsphere.infra.route.context.RouteContext;
import org.apache.shardingsphere.sharding.route.engine.validator.ddl.ShardingDDLStatementValidator;
import org.apache.shardingsphere.sharding.rule.ShardingRule;
@@ -42,13 +43,17 @@ public final class ShardingCreateFunctionStatementValidator extends ShardingDDLS
public void preValidate(final ShardingRule shardingRule, final SQLStatementContext<CreateFunctionStatement> sqlStatementContext,
final List<Object> parameters, final ShardingSphereMetaData metaData) {
Optional<RoutineBodySegment> routineBodySegment = CreateFunctionStatementHandler.getRoutineBodySegment(sqlStatementContext.getSqlStatement());
- if (routineBodySegment.isPresent()) {
- TableExtractor extractor = new TableExtractor();
- Collection<SimpleTableSegment> existTables = extractor.extractExistTableFromRoutineBody(routineBodySegment.get());
- validateShardingTable(shardingRule, existTables);
- validateTableExist(metaData.getDefaultSchema(), existTables);
- validateTableNotExist(metaData.getDefaultSchema(), extractor.extractNotExistTableFromRoutineBody(routineBodySegment.get()));
+ if (!routineBodySegment.isPresent()) {
+ return;
}
+ TableExtractor extractor = new TableExtractor();
+ Collection<SimpleTableSegment> existTables = extractor.extractExistTableFromRoutineBody(routineBodySegment.get());
+ validateShardingTable(shardingRule, existTables);
+ String defaultSchema = sqlStatementContext.getDatabaseType().getDefaultSchema(metaData.getDatabaseName());
+ ShardingSphereSchema schema = sqlStatementContext.getSqlStatement().getFunctionName().flatMap(optional -> optional.getOwner()
+ .map(owner -> metaData.getSchemaByName(owner.getIdentifier().getValue()))).orElseGet(() -> metaData.getSchemaByName(defaultSchema));
+ validateTableExist(schema, existTables);
+ validateTableNotExist(schema, extractor.extractNotExistTableFromRoutineBody(routineBodySegment.get()));
}
@Override
diff --git a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/route/engine/validator/ddl/impl/ShardingCreateProcedureStatementValidator.java b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/route/engine/validator/ddl/impl/ShardingCreateProcedureStatementValidator.java
index 46d52c2c3e9..3e430288791 100644
--- a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/route/engine/validator/ddl/impl/ShardingCreateProcedureStatementValidator.java
+++ b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/route/engine/validator/ddl/impl/ShardingCreateProcedureStatementValidator.java
@@ -20,6 +20,7 @@ package org.apache.shardingsphere.sharding.route.engine.validator.ddl.impl;
import org.apache.shardingsphere.infra.binder.statement.SQLStatementContext;
import org.apache.shardingsphere.infra.config.props.ConfigurationProperties;
import org.apache.shardingsphere.infra.metadata.ShardingSphereMetaData;
+import org.apache.shardingsphere.infra.metadata.schema.ShardingSphereSchema;
import org.apache.shardingsphere.infra.route.context.RouteContext;
import org.apache.shardingsphere.sharding.route.engine.validator.ddl.ShardingDDLStatementValidator;
import org.apache.shardingsphere.sharding.rule.ShardingRule;
@@ -42,13 +43,18 @@ public final class ShardingCreateProcedureStatementValidator extends ShardingDDL
public void preValidate(final ShardingRule shardingRule, final SQLStatementContext<CreateProcedureStatement> sqlStatementContext,
final List<Object> parameters, final ShardingSphereMetaData metaData) {
Optional<RoutineBodySegment> routineBodySegment = CreateProcedureStatementHandler.getRoutineBodySegment(sqlStatementContext.getSqlStatement());
- if (routineBodySegment.isPresent()) {
- TableExtractor extractor = new TableExtractor();
- validateTableNotExist(metaData.getDefaultSchema(), extractor.extractNotExistTableFromRoutineBody(routineBodySegment.get()));
- Collection<SimpleTableSegment> existTables = extractor.extractExistTableFromRoutineBody(routineBodySegment.get());
- validateShardingTable(shardingRule, existTables);
- validateTableExist(metaData.getDefaultSchema(), existTables);
+ if (!routineBodySegment.isPresent()) {
+ return;
}
+ TableExtractor extractor = new TableExtractor();
+ String defaultSchema = sqlStatementContext.getDatabaseType().getDefaultSchema(metaData.getDatabaseName());
+ ShardingSphereSchema schema = sqlStatementContext.getSqlStatement().getProcedureName().flatMap(optional -> optional.getOwner()
+ .map(owner -> metaData.getSchemaByName(owner.getIdentifier().getValue()))).orElseGet(() -> metaData.getSchemaByName(defaultSchema));
+ Collection<SimpleTableSegment> existTables = extractor.extractExistTableFromRoutineBody(routineBodySegment.get());
+ validateShardingTable(shardingRule, existTables);
+ validateTableExist(schema, existTables);
+ Collection<SimpleTableSegment> notExistTables = extractor.extractNotExistTableFromRoutineBody(routineBodySegment.get());
+ validateTableNotExist(schema, notExistTables);
}
@Override
diff --git a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/test/java/org/apache/shardingsphere/sharding/route/engine/validator/ddl/ShardingCreateFunctionStatementValidatorTest.java b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/test/java/org/apache/shardingsphere/sharding/route/engine/validator/ddl/ShardingCreateFunctionStatementValidatorTest.java
index b26e6bcce24..5aecaaf35af 100644
--- a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/test/java/org/apache/shardingsphere/sharding/route/engine/validator/ddl/ShardingCreateFunctionStatementValidatorTest.java
+++ b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/test/java/org/apache/shardingsphere/sharding/route/engine/validator/ddl/ShardingCreateFunctionStatementValidatorTest.java
@@ -19,6 +19,7 @@ package org.apache.shardingsphere.sharding.route.engine.validator.ddl;
import org.apache.shardingsphere.infra.binder.statement.CommonSQLStatementContext;
import org.apache.shardingsphere.infra.binder.statement.SQLStatementContext;
+import org.apache.shardingsphere.infra.database.DefaultSchema;
import org.apache.shardingsphere.infra.exception.ShardingSphereException;
import org.apache.shardingsphere.infra.metadata.ShardingSphereMetaData;
import org.apache.shardingsphere.sharding.route.engine.exception.NoSuchTableException;
@@ -68,7 +69,8 @@ public final class ShardingCreateFunctionStatementValidatorTest {
sqlStatement.setRoutineBody(routineBody);
SQLStatementContext<CreateFunctionStatement> sqlStatementContext = new CommonSQLStatementContext<>(sqlStatement);
ShardingSphereMetaData metaData = mock(ShardingSphereMetaData.class, RETURNS_DEEP_STUBS);
- when(metaData.getDefaultSchema().containsTable("t_order_item")).thenReturn(true);
+ when(metaData.getDatabaseName()).thenReturn(DefaultSchema.LOGIC_NAME);
+ when(metaData.getSchemaByName(DefaultSchema.LOGIC_NAME).containsTable("t_order_item")).thenReturn(true);
new ShardingCreateFunctionStatementValidator().preValidate(shardingRule, sqlStatementContext, Collections.emptyList(), metaData);
}
@@ -112,7 +114,8 @@ public final class ShardingCreateFunctionStatementValidatorTest {
sqlStatement.setRoutineBody(routineBody);
SQLStatementContext<CreateFunctionStatement> sqlStatementContext = new CommonSQLStatementContext<>(sqlStatement);
ShardingSphereMetaData metaData = mock(ShardingSphereMetaData.class, RETURNS_DEEP_STUBS);
- when(metaData.getDefaultSchema().containsTable("t_order")).thenReturn(true);
+ when(metaData.getDatabaseName()).thenReturn(DefaultSchema.LOGIC_NAME);
+ when(metaData.getSchemaByName(DefaultSchema.LOGIC_NAME).containsTable("t_order")).thenReturn(true);
new ShardingCreateFunctionStatementValidator().preValidate(shardingRule, sqlStatementContext, Collections.emptyList(), metaData);
}
}
diff --git a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/test/java/org/apache/shardingsphere/sharding/route/engine/validator/ddl/ShardingCreateProcedureStatementValidatorTest.java b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/test/java/org/apache/shardingsphere/sharding/route/engine/validator/ddl/ShardingCreateProcedureStatementValidatorTest.java
index a72796eb493..dc168a38144 100644
--- a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/test/java/org/apache/shardingsphere/sharding/route/engine/validator/ddl/ShardingCreateProcedureStatementValidatorTest.java
+++ b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/test/java/org/apache/shardingsphere/sharding/route/engine/validator/ddl/ShardingCreateProcedureStatementValidatorTest.java
@@ -19,6 +19,7 @@ package org.apache.shardingsphere.sharding.route.engine.validator.ddl;
import org.apache.shardingsphere.infra.binder.statement.CommonSQLStatementContext;
import org.apache.shardingsphere.infra.binder.statement.SQLStatementContext;
+import org.apache.shardingsphere.infra.database.DefaultSchema;
import org.apache.shardingsphere.infra.exception.ShardingSphereException;
import org.apache.shardingsphere.infra.metadata.ShardingSphereMetaData;
import org.apache.shardingsphere.sharding.route.engine.exception.NoSuchTableException;
@@ -66,10 +67,11 @@ public final class ShardingCreateProcedureStatementValidatorTest {
routineBody.getValidStatements().add(selectValidStatementSegment);
MySQLCreateProcedureStatement sqlStatement = new MySQLCreateProcedureStatement();
sqlStatement.setRoutineBody(routineBody);
- SQLStatementContext<CreateProcedureStatement> sqlStatementContext = new CommonSQLStatementContext<>(sqlStatement);
ShardingSphereMetaData metaData = mock(ShardingSphereMetaData.class, RETURNS_DEEP_STUBS);
- when(metaData.getDefaultSchema().containsTable("t_order_item")).thenReturn(true);
+ when(metaData.getDatabaseName()).thenReturn(DefaultSchema.LOGIC_NAME);
+ when(metaData.getSchemaByName(DefaultSchema.LOGIC_NAME).containsTable("t_order_item")).thenReturn(true);
when(shardingRule.isShardingTable("t_order_item")).thenReturn(false);
+ SQLStatementContext<CreateProcedureStatement> sqlStatementContext = new CommonSQLStatementContext<>(sqlStatement);
new ShardingCreateProcedureStatementValidator().preValidate(shardingRule, sqlStatementContext, Collections.emptyList(), metaData);
}
@@ -113,7 +115,8 @@ public final class ShardingCreateProcedureStatementValidatorTest {
sqlStatement.setRoutineBody(routineBody);
SQLStatementContext<CreateProcedureStatement> sqlStatementContext = new CommonSQLStatementContext<>(sqlStatement);
ShardingSphereMetaData metaData = mock(ShardingSphereMetaData.class, RETURNS_DEEP_STUBS);
- when(metaData.getDefaultSchema().containsTable("t_order")).thenReturn(true);
+ when(metaData.getDatabaseName()).thenReturn(DefaultSchema.LOGIC_NAME);
+ when(metaData.getSchemaByName(DefaultSchema.LOGIC_NAME).containsTable("t_order")).thenReturn(true);
new ShardingCreateProcedureStatementValidator().preValidate(shardingRule, sqlStatementContext, Collections.emptyList(), metaData);
}
}
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 b3900122a29..8b618b4a40d 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
@@ -76,6 +76,7 @@ import org.apache.shardingsphere.sql.parser.autogen.MySQLStatementParser.DropVie
import org.apache.shardingsphere.sql.parser.autogen.MySQLStatementParser.ExecuteStmtContext;
import org.apache.shardingsphere.sql.parser.autogen.MySQLStatementParser.FieldDefinitionContext;
import org.apache.shardingsphere.sql.parser.autogen.MySQLStatementParser.FlowControlStatementContext;
+import org.apache.shardingsphere.sql.parser.autogen.MySQLStatementParser.FunctionNameContext;
import org.apache.shardingsphere.sql.parser.autogen.MySQLStatementParser.IfStatementContext;
import org.apache.shardingsphere.sql.parser.autogen.MySQLStatementParser.KeyListWithExpressionContext;
import org.apache.shardingsphere.sql.parser.autogen.MySQLStatementParser.KeyPartContext;
@@ -115,6 +116,7 @@ import org.apache.shardingsphere.sql.parser.sql.common.segment.ddl.constraint.al
import org.apache.shardingsphere.sql.parser.sql.common.segment.ddl.index.DropIndexDefinitionSegment;
import org.apache.shardingsphere.sql.parser.sql.common.segment.ddl.index.IndexNameSegment;
import org.apache.shardingsphere.sql.parser.sql.common.segment.ddl.index.IndexSegment;
+import org.apache.shardingsphere.sql.parser.sql.common.segment.ddl.routine.FunctionNameSegment;
import org.apache.shardingsphere.sql.parser.sql.common.segment.ddl.routine.RoutineBodySegment;
import org.apache.shardingsphere.sql.parser.sql.common.segment.ddl.routine.ValidStatementSegment;
import org.apache.shardingsphere.sql.parser.sql.common.segment.ddl.table.ConvertTableDefinitionSegment;
@@ -122,6 +124,7 @@ import org.apache.shardingsphere.sql.parser.sql.common.segment.ddl.table.RenameT
import org.apache.shardingsphere.sql.parser.sql.common.segment.dml.column.ColumnSegment;
import org.apache.shardingsphere.sql.parser.sql.common.segment.dml.expr.simple.SimpleExpressionSegment;
import org.apache.shardingsphere.sql.parser.sql.common.segment.generic.DataTypeSegment;
+import org.apache.shardingsphere.sql.parser.sql.common.segment.generic.OwnerSegment;
import org.apache.shardingsphere.sql.parser.sql.common.segment.generic.table.SimpleTableSegment;
import org.apache.shardingsphere.sql.parser.sql.common.statement.SQLStatement;
import org.apache.shardingsphere.sql.parser.sql.common.value.collection.CollectionValue;
@@ -583,10 +586,20 @@ public final class MySQLDDLStatementSQLVisitor extends MySQLStatementSQLVisitor
@Override
public ASTNode visitCreateProcedure(final CreateProcedureContext ctx) {
MySQLCreateProcedureStatement result = new MySQLCreateProcedureStatement();
+ result.setProcedureName((FunctionNameSegment) visit(ctx.functionName()));
result.setRoutineBody((RoutineBodySegment) visit(ctx.routineBody()));
return result;
}
+ @Override
+ public ASTNode visitFunctionName(final FunctionNameContext ctx) {
+ FunctionNameSegment result = new FunctionNameSegment(ctx.start.getStartIndex(), ctx.stop.getStopIndex(), (IdentifierValue) visit(ctx.identifier()));
+ if (null != ctx.owner()) {
+ result.setOwner((OwnerSegment) visit(ctx.owner()));
+ }
+ return result;
+ }
+
@Override
public ASTNode visitAlterProcedure(final AlterProcedureContext ctx) {
return new MySQLAlterProcedureStatement();
@@ -600,6 +613,7 @@ public final class MySQLDDLStatementSQLVisitor extends MySQLStatementSQLVisitor
@Override
public ASTNode visitCreateFunction(final CreateFunctionContext ctx) {
MySQLCreateFunctionStatement result = new MySQLCreateFunctionStatement();
+ result.setFunctionName((FunctionNameSegment) visit(ctx.functionName()));
result.setRoutineBody((RoutineBodySegment) visit(ctx.routineBody()));
return result;
}
diff --git a/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/common/segment/ddl/routine/FunctionNameSegment.java b/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/common/segment/ddl/routine/FunctionNameSegment.java
new file mode 100644
index 00000000000..4cba30dc6d2
--- /dev/null
+++ b/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/common/segment/ddl/routine/FunctionNameSegment.java
@@ -0,0 +1,50 @@
+/*
+ * 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.sql.parser.sql.common.segment.ddl.routine;
+
+import lombok.Getter;
+import lombok.RequiredArgsConstructor;
+import lombok.Setter;
+import org.apache.shardingsphere.sql.parser.sql.common.segment.SQLSegment;
+import org.apache.shardingsphere.sql.parser.sql.common.segment.generic.OwnerAvailable;
+import org.apache.shardingsphere.sql.parser.sql.common.segment.generic.OwnerSegment;
+import org.apache.shardingsphere.sql.parser.sql.common.value.identifier.IdentifierValue;
+
+import java.util.Optional;
+
+/**
+ * Function name segment.
+ */
+@RequiredArgsConstructor
+@Getter
+@Setter
+public final class FunctionNameSegment implements SQLSegment, OwnerAvailable {
+
+ private final int startIndex;
+
+ private final int stopIndex;
+
+ private final IdentifierValue identifier;
+
+ private OwnerSegment owner;
+
+ @Override
+ public Optional<OwnerSegment> getOwner() {
+ return Optional.ofNullable(owner);
+ }
+}
diff --git a/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/common/statement/ddl/CreateFunctionStatement.java b/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/common/statement/ddl/CreateFunctionStatement.java
index 5f5a8ce02c5..aa69ee5192b 100644
--- a/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/common/statement/ddl/CreateFunctionStatement.java
+++ b/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/common/statement/ddl/CreateFunctionStatement.java
@@ -17,10 +17,28 @@
package org.apache.shardingsphere.sql.parser.sql.common.statement.ddl;
+import lombok.Getter;
+import lombok.Setter;
+import org.apache.shardingsphere.sql.parser.sql.common.segment.ddl.routine.FunctionNameSegment;
import org.apache.shardingsphere.sql.parser.sql.common.statement.AbstractSQLStatement;
+import java.util.Optional;
+
/**
* Create function statement.
*/
+@Getter
+@Setter
public abstract class CreateFunctionStatement extends AbstractSQLStatement implements DDLStatement {
+
+ private FunctionNameSegment functionName;
+
+ /**
+ * Get function name segment.
+ *
+ * @return function name segment
+ */
+ public Optional<FunctionNameSegment> getFunctionName() {
+ return Optional.ofNullable(functionName);
+ }
}
diff --git a/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/common/statement/ddl/CreateProcedureStatement.java b/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/common/statement/ddl/CreateProcedureStatement.java
index 58129628f5d..ccee547a181 100644
--- a/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/common/statement/ddl/CreateProcedureStatement.java
+++ b/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/common/statement/ddl/CreateProcedureStatement.java
@@ -17,10 +17,28 @@
package org.apache.shardingsphere.sql.parser.sql.common.statement.ddl;
+import lombok.Getter;
+import lombok.Setter;
+import org.apache.shardingsphere.sql.parser.sql.common.segment.ddl.routine.FunctionNameSegment;
import org.apache.shardingsphere.sql.parser.sql.common.statement.AbstractSQLStatement;
+import java.util.Optional;
+
/**
* Create procedure statement.
*/
+@Getter
+@Setter
public abstract class CreateProcedureStatement extends AbstractSQLStatement implements DDLStatement {
+
+ private FunctionNameSegment procedureName;
+
+ /**
+ * Get procedure name segment.
+ *
+ * @return procedure name segment
+ */
+ public Optional<FunctionNameSegment> getProcedureName() {
+ return Optional.ofNullable(procedureName);
+ }
}