You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by pa...@apache.org on 2022/06/05 11:36:40 UTC
[shardingsphere] branch master updated: Optimize fetch, move cursor statements parse logic (#18183)
This is an automated email from the ASF dual-hosted git repository.
panjuan 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 fc1da2c90d0 Optimize fetch, move cursor statements parse logic (#18183)
fc1da2c90d0 is described below
commit fc1da2c90d0ec509148f039ae939a6c12b77fe94
Author: Zhengqiang Duan <du...@apache.org>
AuthorDate: Sun Jun 5 19:36:34 2022 +0800
Optimize fetch, move cursor statements parse logic (#18183)
* Optimize fetch, move cursor statements parse logic
* optimize java doc
---
.../main/antlr4/imports/opengauss/DDLStatement.g4 | 28 ++---
.../impl/OpenGaussDDLStatementSQLVisitor.java | 139 ++++++++++++++++++---
.../impl/OpenGaussStatementSQLVisitor.java | 6 +
.../sql/common/constant/AggregationType.java | 1 +
.../{AggregationType.java => DirectionType.java} | 17 +--
.../segment/ddl/cursor/DirectionSegment.java} | 33 +++--
.../opengauss/ddl/OpenGaussFetchStatement.java | 14 +++
.../opengauss/ddl/OpenGaussMoveStatement.java | 14 +++
.../segment/cursor/DirectionSegmentAssert.java | 70 +++++++++++
.../statement/ddl/impl/FetchStatementAssert.java | 14 +++
.../statement/ddl/impl/MoveStatementAssert.java | 14 +++
.../impl/cursor/ExpectedDirectionSegment.java} | 18 +--
.../statement/ddl/FetchStatementTestCase.java | 4 +
.../statement/ddl/MoveStatementTestCase.java | 4 +
.../src/main/resources/case/ddl/fetch.xml | 68 +++++++++-
.../src/main/resources/case/ddl/move.xml | 70 ++++++++++-
.../src/main/resources/sql/supported/ddl/fetch.xml | 15 ++-
.../src/main/resources/sql/supported/ddl/move.xml | 15 ++-
18 files changed, 483 insertions(+), 61 deletions(-)
diff --git a/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-opengauss/src/main/antlr4/imports/opengauss/DDLStatement.g4 b/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-opengauss/src/main/antlr4/imports/opengauss/DDLStatement.g4
index b8ae1647714..45507743f83 100644
--- a/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-opengauss/src/main/antlr4/imports/opengauss/DDLStatement.g4
+++ b/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-opengauss/src/main/antlr4/imports/opengauss/DDLStatement.g4
@@ -1976,18 +1976,18 @@ fetch
;
direction
- : NEXT
- | PRIOR
- | FIRST
- | LAST
- | ABSOLUTE signedIconst
- | RELATIVE signedIconst
- | signedIconst
- | ALL
- | FORWARD
- | FORWARD signedIconst
- | FORWARD ALL
- | BACKWARD
- | BACKWARD signedIconst
- | BACKWARD ALL
+ : NEXT #next
+ | PRIOR #prior
+ | FIRST #first
+ | LAST #last
+ | ABSOLUTE signedIconst #absoluteCount
+ | RELATIVE signedIconst #relativeCount
+ | signedIconst #count
+ | ALL #all
+ | FORWARD #forward
+ | FORWARD signedIconst #forwardCount
+ | FORWARD ALL #forwardAll
+ | BACKWARD #backward
+ | BACKWARD signedIconst #backwardCount
+ | BACKWARD ALL #backwardAll
;
diff --git a/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-opengauss/src/main/java/org/apache/shardingsphere/sql/parser/opengauss/visitor/statement/impl/OpenGaussDDLStatementSQLVisitor.java b/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-opengauss/src/main/java/org/apache/shardingsphere/sql/parser/opengauss/visitor/statement/impl/OpenGaussDDLStatementSQLVisitor.java
index 9efe2b72a6d..d7afab91536 100644
--- a/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-opengauss/src/main/java/org/apache/shardingsphere/sql/parser/opengauss/visitor/statement/impl/OpenGaussDDLStatementSQLVisitor.java
+++ b/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-opengauss/src/main/java/org/apache/shardingsphere/sql/parser/opengauss/visitor/statement/impl/OpenGaussDDLStatementSQLVisitor.java
@@ -21,12 +21,15 @@ import lombok.NoArgsConstructor;
import org.apache.shardingsphere.sql.parser.api.visitor.ASTNode;
import org.apache.shardingsphere.sql.parser.api.visitor.operation.SQLStatementVisitor;
import org.apache.shardingsphere.sql.parser.api.visitor.type.DDLSQLVisitor;
+import org.apache.shardingsphere.sql.parser.autogen.OpenGaussStatementParser.AbsoluteCountContext;
import org.apache.shardingsphere.sql.parser.autogen.OpenGaussStatementParser.AddColumnSpecificationContext;
import org.apache.shardingsphere.sql.parser.autogen.OpenGaussStatementParser.AddConstraintSpecificationContext;
+import org.apache.shardingsphere.sql.parser.autogen.OpenGaussStatementParser.AllContext;
import org.apache.shardingsphere.sql.parser.autogen.OpenGaussStatementParser.AlterAggregateContext;
import org.apache.shardingsphere.sql.parser.autogen.OpenGaussStatementParser.AlterConversionContext;
import org.apache.shardingsphere.sql.parser.autogen.OpenGaussStatementParser.AlterDefaultPrivilegesContext;
import org.apache.shardingsphere.sql.parser.autogen.OpenGaussStatementParser.AlterDefinitionClauseContext;
+import org.apache.shardingsphere.sql.parser.autogen.OpenGaussStatementParser.AlterDirectoryContext;
import org.apache.shardingsphere.sql.parser.autogen.OpenGaussStatementParser.AlterDomainContext;
import org.apache.shardingsphere.sql.parser.autogen.OpenGaussStatementParser.AlterExtensionContext;
import org.apache.shardingsphere.sql.parser.autogen.OpenGaussStatementParser.AlterForeignTableContext;
@@ -37,40 +40,43 @@ import org.apache.shardingsphere.sql.parser.autogen.OpenGaussStatementParser.Alt
import org.apache.shardingsphere.sql.parser.autogen.OpenGaussStatementParser.AlterMaterializedViewContext;
import org.apache.shardingsphere.sql.parser.autogen.OpenGaussStatementParser.AlterProcedureContext;
import org.apache.shardingsphere.sql.parser.autogen.OpenGaussStatementParser.AlterRenameViewContext;
+import org.apache.shardingsphere.sql.parser.autogen.OpenGaussStatementParser.AlterRuleContext;
import org.apache.shardingsphere.sql.parser.autogen.OpenGaussStatementParser.AlterSchemaContext;
import org.apache.shardingsphere.sql.parser.autogen.OpenGaussStatementParser.AlterSequenceContext;
import org.apache.shardingsphere.sql.parser.autogen.OpenGaussStatementParser.AlterSynonymContext;
-import org.apache.shardingsphere.sql.parser.autogen.OpenGaussStatementParser.AlterDirectoryContext;
-import org.apache.shardingsphere.sql.parser.autogen.OpenGaussStatementParser.AlterRuleContext;
-import org.apache.shardingsphere.sql.parser.autogen.OpenGaussStatementParser.AlterTypeContext;
import org.apache.shardingsphere.sql.parser.autogen.OpenGaussStatementParser.AlterTableActionContext;
import org.apache.shardingsphere.sql.parser.autogen.OpenGaussStatementParser.AlterTableContext;
import org.apache.shardingsphere.sql.parser.autogen.OpenGaussStatementParser.AlterTablespaceContext;
import org.apache.shardingsphere.sql.parser.autogen.OpenGaussStatementParser.AlterTextSearchDictionaryContext;
import org.apache.shardingsphere.sql.parser.autogen.OpenGaussStatementParser.AlterTextSearchParserContext;
import org.apache.shardingsphere.sql.parser.autogen.OpenGaussStatementParser.AlterTextSearchTemplateContext;
+import org.apache.shardingsphere.sql.parser.autogen.OpenGaussStatementParser.AlterTypeContext;
import org.apache.shardingsphere.sql.parser.autogen.OpenGaussStatementParser.AlterViewContext;
+import org.apache.shardingsphere.sql.parser.autogen.OpenGaussStatementParser.BackwardAllContext;
+import org.apache.shardingsphere.sql.parser.autogen.OpenGaussStatementParser.BackwardContext;
+import org.apache.shardingsphere.sql.parser.autogen.OpenGaussStatementParser.BackwardCountContext;
import org.apache.shardingsphere.sql.parser.autogen.OpenGaussStatementParser.CloseContext;
import org.apache.shardingsphere.sql.parser.autogen.OpenGaussStatementParser.ColumnConstraintContext;
import org.apache.shardingsphere.sql.parser.autogen.OpenGaussStatementParser.ColumnDefinitionContext;
import org.apache.shardingsphere.sql.parser.autogen.OpenGaussStatementParser.CommentContext;
+import org.apache.shardingsphere.sql.parser.autogen.OpenGaussStatementParser.CountContext;
import org.apache.shardingsphere.sql.parser.autogen.OpenGaussStatementParser.CreateCastContext;
import org.apache.shardingsphere.sql.parser.autogen.OpenGaussStatementParser.CreateConversionContext;
import org.apache.shardingsphere.sql.parser.autogen.OpenGaussStatementParser.CreateDatabaseContext;
import org.apache.shardingsphere.sql.parser.autogen.OpenGaussStatementParser.CreateDefinitionClauseContext;
import org.apache.shardingsphere.sql.parser.autogen.OpenGaussStatementParser.CreateDefinitionContext;
+import org.apache.shardingsphere.sql.parser.autogen.OpenGaussStatementParser.CreateDirectoryContext;
import org.apache.shardingsphere.sql.parser.autogen.OpenGaussStatementParser.CreateDomainContext;
import org.apache.shardingsphere.sql.parser.autogen.OpenGaussStatementParser.CreateExtensionContext;
import org.apache.shardingsphere.sql.parser.autogen.OpenGaussStatementParser.CreateFunctionContext;
import org.apache.shardingsphere.sql.parser.autogen.OpenGaussStatementParser.CreateIndexContext;
import org.apache.shardingsphere.sql.parser.autogen.OpenGaussStatementParser.CreateLanguageContext;
import org.apache.shardingsphere.sql.parser.autogen.OpenGaussStatementParser.CreateProcedureContext;
+import org.apache.shardingsphere.sql.parser.autogen.OpenGaussStatementParser.CreatePublicationContext;
import org.apache.shardingsphere.sql.parser.autogen.OpenGaussStatementParser.CreateRuleContext;
import org.apache.shardingsphere.sql.parser.autogen.OpenGaussStatementParser.CreateSchemaContext;
import org.apache.shardingsphere.sql.parser.autogen.OpenGaussStatementParser.CreateSequenceContext;
import org.apache.shardingsphere.sql.parser.autogen.OpenGaussStatementParser.CreateSynonymContext;
-import org.apache.shardingsphere.sql.parser.autogen.OpenGaussStatementParser.CreatePublicationContext;
-import org.apache.shardingsphere.sql.parser.autogen.OpenGaussStatementParser.CreateDirectoryContext;
import org.apache.shardingsphere.sql.parser.autogen.OpenGaussStatementParser.CreateTableContext;
import org.apache.shardingsphere.sql.parser.autogen.OpenGaussStatementParser.CreateTablespaceContext;
import org.apache.shardingsphere.sql.parser.autogen.OpenGaussStatementParser.CreateTextSearchContext;
@@ -80,12 +86,12 @@ import org.apache.shardingsphere.sql.parser.autogen.OpenGaussStatementParser.Cur
import org.apache.shardingsphere.sql.parser.autogen.OpenGaussStatementParser.CursorNameContext;
import org.apache.shardingsphere.sql.parser.autogen.OpenGaussStatementParser.DeallocateContext;
import org.apache.shardingsphere.sql.parser.autogen.OpenGaussStatementParser.DeclareContext;
+import org.apache.shardingsphere.sql.parser.autogen.OpenGaussStatementParser.DropCastContext;
import org.apache.shardingsphere.sql.parser.autogen.OpenGaussStatementParser.DropColumnSpecificationContext;
import org.apache.shardingsphere.sql.parser.autogen.OpenGaussStatementParser.DropConstraintSpecificationContext;
-import org.apache.shardingsphere.sql.parser.autogen.OpenGaussStatementParser.DropCastContext;
-import org.apache.shardingsphere.sql.parser.autogen.OpenGaussStatementParser.DropRuleContext;
import org.apache.shardingsphere.sql.parser.autogen.OpenGaussStatementParser.DropConversionContext;
import org.apache.shardingsphere.sql.parser.autogen.OpenGaussStatementParser.DropDatabaseContext;
+import org.apache.shardingsphere.sql.parser.autogen.OpenGaussStatementParser.DropDirectoryContext;
import org.apache.shardingsphere.sql.parser.autogen.OpenGaussStatementParser.DropDomainContext;
import org.apache.shardingsphere.sql.parser.autogen.OpenGaussStatementParser.DropExtensionContext;
import org.apache.shardingsphere.sql.parser.autogen.OpenGaussStatementParser.DropFunctionContext;
@@ -93,25 +99,33 @@ import org.apache.shardingsphere.sql.parser.autogen.OpenGaussStatementParser.Dro
import org.apache.shardingsphere.sql.parser.autogen.OpenGaussStatementParser.DropLanguageContext;
import org.apache.shardingsphere.sql.parser.autogen.OpenGaussStatementParser.DropProcedureContext;
import org.apache.shardingsphere.sql.parser.autogen.OpenGaussStatementParser.DropPublicationContext;
+import org.apache.shardingsphere.sql.parser.autogen.OpenGaussStatementParser.DropRuleContext;
import org.apache.shardingsphere.sql.parser.autogen.OpenGaussStatementParser.DropSchemaContext;
import org.apache.shardingsphere.sql.parser.autogen.OpenGaussStatementParser.DropSequenceContext;
import org.apache.shardingsphere.sql.parser.autogen.OpenGaussStatementParser.DropSynonymContext;
-import org.apache.shardingsphere.sql.parser.autogen.OpenGaussStatementParser.DropTypeContext;
-import org.apache.shardingsphere.sql.parser.autogen.OpenGaussStatementParser.DropDirectoryContext;
import org.apache.shardingsphere.sql.parser.autogen.OpenGaussStatementParser.DropTableContext;
import org.apache.shardingsphere.sql.parser.autogen.OpenGaussStatementParser.DropTablespaceContext;
+import org.apache.shardingsphere.sql.parser.autogen.OpenGaussStatementParser.DropTypeContext;
import org.apache.shardingsphere.sql.parser.autogen.OpenGaussStatementParser.DropViewContext;
import org.apache.shardingsphere.sql.parser.autogen.OpenGaussStatementParser.FetchContext;
+import org.apache.shardingsphere.sql.parser.autogen.OpenGaussStatementParser.FirstContext;
+import org.apache.shardingsphere.sql.parser.autogen.OpenGaussStatementParser.ForwardAllContext;
+import org.apache.shardingsphere.sql.parser.autogen.OpenGaussStatementParser.ForwardContext;
+import org.apache.shardingsphere.sql.parser.autogen.OpenGaussStatementParser.ForwardCountContext;
import org.apache.shardingsphere.sql.parser.autogen.OpenGaussStatementParser.IndexElemContext;
import org.apache.shardingsphere.sql.parser.autogen.OpenGaussStatementParser.IndexNameContext;
import org.apache.shardingsphere.sql.parser.autogen.OpenGaussStatementParser.IndexNamesContext;
import org.apache.shardingsphere.sql.parser.autogen.OpenGaussStatementParser.IndexParamsContext;
+import org.apache.shardingsphere.sql.parser.autogen.OpenGaussStatementParser.LastContext;
import org.apache.shardingsphere.sql.parser.autogen.OpenGaussStatementParser.ModifyColumnSpecificationContext;
import org.apache.shardingsphere.sql.parser.autogen.OpenGaussStatementParser.ModifyConstraintSpecificationContext;
import org.apache.shardingsphere.sql.parser.autogen.OpenGaussStatementParser.MoveContext;
import org.apache.shardingsphere.sql.parser.autogen.OpenGaussStatementParser.NameContext;
import org.apache.shardingsphere.sql.parser.autogen.OpenGaussStatementParser.NameListContext;
+import org.apache.shardingsphere.sql.parser.autogen.OpenGaussStatementParser.NextContext;
import org.apache.shardingsphere.sql.parser.autogen.OpenGaussStatementParser.PrepareContext;
+import org.apache.shardingsphere.sql.parser.autogen.OpenGaussStatementParser.PriorContext;
+import org.apache.shardingsphere.sql.parser.autogen.OpenGaussStatementParser.RelativeCountContext;
import org.apache.shardingsphere.sql.parser.autogen.OpenGaussStatementParser.RenameColumnSpecificationContext;
import org.apache.shardingsphere.sql.parser.autogen.OpenGaussStatementParser.RenameTableSpecificationContext;
import org.apache.shardingsphere.sql.parser.autogen.OpenGaussStatementParser.TableConstraintContext;
@@ -120,6 +134,7 @@ import org.apache.shardingsphere.sql.parser.autogen.OpenGaussStatementParser.Tab
import org.apache.shardingsphere.sql.parser.autogen.OpenGaussStatementParser.TableNamesClauseContext;
import org.apache.shardingsphere.sql.parser.autogen.OpenGaussStatementParser.TruncateTableContext;
import org.apache.shardingsphere.sql.parser.autogen.OpenGaussStatementParser.ValidateConstraintSpecificationContext;
+import org.apache.shardingsphere.sql.parser.sql.common.constant.DirectionType;
import org.apache.shardingsphere.sql.parser.sql.common.segment.ddl.AlterDefinitionSegment;
import org.apache.shardingsphere.sql.parser.sql.common.segment.ddl.CreateDefinitionSegment;
import org.apache.shardingsphere.sql.parser.sql.common.segment.ddl.column.ColumnDefinitionSegment;
@@ -134,6 +149,7 @@ import org.apache.shardingsphere.sql.parser.sql.common.segment.ddl.constraint.al
import org.apache.shardingsphere.sql.parser.sql.common.segment.ddl.constraint.alter.ModifyConstraintDefinitionSegment;
import org.apache.shardingsphere.sql.parser.sql.common.segment.ddl.constraint.alter.ValidateConstraintDefinitionSegment;
import org.apache.shardingsphere.sql.parser.sql.common.segment.ddl.cursor.CursorNameSegment;
+import org.apache.shardingsphere.sql.parser.sql.common.segment.ddl.cursor.DirectionSegment;
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.table.RenameTableDefinitionSegment;
@@ -149,9 +165,11 @@ import org.apache.shardingsphere.sql.parser.sql.common.statement.dml.SelectState
import org.apache.shardingsphere.sql.parser.sql.common.statement.dml.UpdateStatement;
import org.apache.shardingsphere.sql.parser.sql.common.value.collection.CollectionValue;
import org.apache.shardingsphere.sql.parser.sql.common.value.identifier.IdentifierValue;
+import org.apache.shardingsphere.sql.parser.sql.common.value.literal.impl.NumberLiteralValue;
import org.apache.shardingsphere.sql.parser.sql.dialect.statement.opengauss.ddl.OpenGaussAlterAggregateStatement;
import org.apache.shardingsphere.sql.parser.sql.dialect.statement.opengauss.ddl.OpenGaussAlterConversionStatement;
import org.apache.shardingsphere.sql.parser.sql.dialect.statement.opengauss.ddl.OpenGaussAlterDefaultPrivilegesStatement;
+import org.apache.shardingsphere.sql.parser.sql.dialect.statement.opengauss.ddl.OpenGaussAlterDirectoryStatement;
import org.apache.shardingsphere.sql.parser.sql.dialect.statement.opengauss.ddl.OpenGaussAlterDomainStatement;
import org.apache.shardingsphere.sql.parser.sql.dialect.statement.opengauss.ddl.OpenGaussAlterExtensionStatement;
import org.apache.shardingsphere.sql.parser.sql.dialect.statement.opengauss.ddl.OpenGaussAlterForeignTableStatement;
@@ -161,33 +179,32 @@ import org.apache.shardingsphere.sql.parser.sql.dialect.statement.opengauss.ddl.
import org.apache.shardingsphere.sql.parser.sql.dialect.statement.opengauss.ddl.OpenGaussAlterLanguageStatement;
import org.apache.shardingsphere.sql.parser.sql.dialect.statement.opengauss.ddl.OpenGaussAlterMaterializedViewStatement;
import org.apache.shardingsphere.sql.parser.sql.dialect.statement.opengauss.ddl.OpenGaussAlterProcedureStatement;
+import org.apache.shardingsphere.sql.parser.sql.dialect.statement.opengauss.ddl.OpenGaussAlterRuleStatement;
import org.apache.shardingsphere.sql.parser.sql.dialect.statement.opengauss.ddl.OpenGaussAlterSchemaStatement;
import org.apache.shardingsphere.sql.parser.sql.dialect.statement.opengauss.ddl.OpenGaussAlterSequenceStatement;
import org.apache.shardingsphere.sql.parser.sql.dialect.statement.opengauss.ddl.OpenGaussAlterSynonymStatement;
-import org.apache.shardingsphere.sql.parser.sql.dialect.statement.opengauss.ddl.OpenGaussAlterDirectoryStatement;
-import org.apache.shardingsphere.sql.parser.sql.dialect.statement.opengauss.ddl.OpenGaussAlterRuleStatement;
-import org.apache.shardingsphere.sql.parser.sql.dialect.statement.opengauss.ddl.OpenGaussAlterTypeStatement;
import org.apache.shardingsphere.sql.parser.sql.dialect.statement.opengauss.ddl.OpenGaussAlterTableStatement;
import org.apache.shardingsphere.sql.parser.sql.dialect.statement.opengauss.ddl.OpenGaussAlterTablespaceStatement;
import org.apache.shardingsphere.sql.parser.sql.dialect.statement.opengauss.ddl.OpenGaussAlterTextSearchStatement;
+import org.apache.shardingsphere.sql.parser.sql.dialect.statement.opengauss.ddl.OpenGaussAlterTypeStatement;
import org.apache.shardingsphere.sql.parser.sql.dialect.statement.opengauss.ddl.OpenGaussAlterViewStatement;
import org.apache.shardingsphere.sql.parser.sql.dialect.statement.opengauss.ddl.OpenGaussCloseStatement;
import org.apache.shardingsphere.sql.parser.sql.dialect.statement.opengauss.ddl.OpenGaussCommentStatement;
-import org.apache.shardingsphere.sql.parser.sql.dialect.statement.opengauss.ddl.OpenGaussCreateConversionStatement;
import org.apache.shardingsphere.sql.parser.sql.dialect.statement.opengauss.ddl.OpenGaussCreateCastStatement;
+import org.apache.shardingsphere.sql.parser.sql.dialect.statement.opengauss.ddl.OpenGaussCreateConversionStatement;
import org.apache.shardingsphere.sql.parser.sql.dialect.statement.opengauss.ddl.OpenGaussCreateDatabaseStatement;
+import org.apache.shardingsphere.sql.parser.sql.dialect.statement.opengauss.ddl.OpenGaussCreateDirectoryStatement;
import org.apache.shardingsphere.sql.parser.sql.dialect.statement.opengauss.ddl.OpenGaussCreateDomainStatement;
import org.apache.shardingsphere.sql.parser.sql.dialect.statement.opengauss.ddl.OpenGaussCreateExtensionStatement;
import org.apache.shardingsphere.sql.parser.sql.dialect.statement.opengauss.ddl.OpenGaussCreateFunctionStatement;
import org.apache.shardingsphere.sql.parser.sql.dialect.statement.opengauss.ddl.OpenGaussCreateIndexStatement;
import org.apache.shardingsphere.sql.parser.sql.dialect.statement.opengauss.ddl.OpenGaussCreateLanguageStatement;
import org.apache.shardingsphere.sql.parser.sql.dialect.statement.opengauss.ddl.OpenGaussCreateProcedureStatement;
+import org.apache.shardingsphere.sql.parser.sql.dialect.statement.opengauss.ddl.OpenGaussCreatePublicationStatement;
import org.apache.shardingsphere.sql.parser.sql.dialect.statement.opengauss.ddl.OpenGaussCreateRuleStatement;
import org.apache.shardingsphere.sql.parser.sql.dialect.statement.opengauss.ddl.OpenGaussCreateSchemaStatement;
import org.apache.shardingsphere.sql.parser.sql.dialect.statement.opengauss.ddl.OpenGaussCreateSequenceStatement;
import org.apache.shardingsphere.sql.parser.sql.dialect.statement.opengauss.ddl.OpenGaussCreateSynonymStatement;
-import org.apache.shardingsphere.sql.parser.sql.dialect.statement.opengauss.ddl.OpenGaussCreatePublicationStatement;
-import org.apache.shardingsphere.sql.parser.sql.dialect.statement.opengauss.ddl.OpenGaussCreateDirectoryStatement;
import org.apache.shardingsphere.sql.parser.sql.dialect.statement.opengauss.ddl.OpenGaussCreateTableStatement;
import org.apache.shardingsphere.sql.parser.sql.dialect.statement.opengauss.ddl.OpenGaussCreateTablespaceStatement;
import org.apache.shardingsphere.sql.parser.sql.dialect.statement.opengauss.ddl.OpenGaussCreateTextSearchStatement;
@@ -197,9 +214,9 @@ import org.apache.shardingsphere.sql.parser.sql.dialect.statement.opengauss.ddl.
import org.apache.shardingsphere.sql.parser.sql.dialect.statement.opengauss.ddl.OpenGaussDeallocateStatement;
import org.apache.shardingsphere.sql.parser.sql.dialect.statement.opengauss.ddl.OpenGaussDeclareStatement;
import org.apache.shardingsphere.sql.parser.sql.dialect.statement.opengauss.ddl.OpenGaussDropCastStatement;
-import org.apache.shardingsphere.sql.parser.sql.dialect.statement.opengauss.ddl.OpenGaussDropRuleStatement;
import org.apache.shardingsphere.sql.parser.sql.dialect.statement.opengauss.ddl.OpenGaussDropConversionStatement;
import org.apache.shardingsphere.sql.parser.sql.dialect.statement.opengauss.ddl.OpenGaussDropDatabaseStatement;
+import org.apache.shardingsphere.sql.parser.sql.dialect.statement.opengauss.ddl.OpenGaussDropDirectoryStatement;
import org.apache.shardingsphere.sql.parser.sql.dialect.statement.opengauss.ddl.OpenGaussDropDomainStatement;
import org.apache.shardingsphere.sql.parser.sql.dialect.statement.opengauss.ddl.OpenGaussDropExtensionStatement;
import org.apache.shardingsphere.sql.parser.sql.dialect.statement.opengauss.ddl.OpenGaussDropFunctionStatement;
@@ -207,13 +224,13 @@ import org.apache.shardingsphere.sql.parser.sql.dialect.statement.opengauss.ddl.
import org.apache.shardingsphere.sql.parser.sql.dialect.statement.opengauss.ddl.OpenGaussDropLanguageStatement;
import org.apache.shardingsphere.sql.parser.sql.dialect.statement.opengauss.ddl.OpenGaussDropProcedureStatement;
import org.apache.shardingsphere.sql.parser.sql.dialect.statement.opengauss.ddl.OpenGaussDropPublicationStatement;
+import org.apache.shardingsphere.sql.parser.sql.dialect.statement.opengauss.ddl.OpenGaussDropRuleStatement;
import org.apache.shardingsphere.sql.parser.sql.dialect.statement.opengauss.ddl.OpenGaussDropSchemaStatement;
import org.apache.shardingsphere.sql.parser.sql.dialect.statement.opengauss.ddl.OpenGaussDropSequenceStatement;
import org.apache.shardingsphere.sql.parser.sql.dialect.statement.opengauss.ddl.OpenGaussDropSynonymStatement;
-import org.apache.shardingsphere.sql.parser.sql.dialect.statement.opengauss.ddl.OpenGaussDropTypeStatement;
-import org.apache.shardingsphere.sql.parser.sql.dialect.statement.opengauss.ddl.OpenGaussDropDirectoryStatement;
import org.apache.shardingsphere.sql.parser.sql.dialect.statement.opengauss.ddl.OpenGaussDropTableStatement;
import org.apache.shardingsphere.sql.parser.sql.dialect.statement.opengauss.ddl.OpenGaussDropTablespaceStatement;
+import org.apache.shardingsphere.sql.parser.sql.dialect.statement.opengauss.ddl.OpenGaussDropTypeStatement;
import org.apache.shardingsphere.sql.parser.sql.dialect.statement.opengauss.ddl.OpenGaussDropViewStatement;
import org.apache.shardingsphere.sql.parser.sql.dialect.statement.opengauss.ddl.OpenGaussFetchStatement;
import org.apache.shardingsphere.sql.parser.sql.dialect.statement.opengauss.ddl.OpenGaussMoveStatement;
@@ -977,6 +994,9 @@ public final class OpenGaussDDLStatementSQLVisitor extends OpenGaussStatementSQL
public ASTNode visitMove(final MoveContext ctx) {
OpenGaussMoveStatement result = new OpenGaussMoveStatement();
result.setCursorName((CursorNameSegment) visit(ctx.cursorName()));
+ if (null != ctx.direction()) {
+ result.setDirection((DirectionSegment) visit(ctx.direction()));
+ }
return result;
}
@@ -984,6 +1004,89 @@ public final class OpenGaussDDLStatementSQLVisitor extends OpenGaussStatementSQL
public ASTNode visitFetch(final FetchContext ctx) {
OpenGaussFetchStatement result = new OpenGaussFetchStatement();
result.setCursorName((CursorNameSegment) visit(ctx.cursorName()));
+ if (null != ctx.direction()) {
+ result.setDirection((DirectionSegment) visit(ctx.direction()));
+ }
return result;
}
+
+ @Override
+ public ASTNode visitNext(final NextContext ctx) {
+ return new DirectionSegment(ctx.start.getStartIndex(), ctx.stop.getStopIndex(), DirectionType.NEXT);
+ }
+
+ @Override
+ public ASTNode visitPrior(final PriorContext ctx) {
+ return new DirectionSegment(ctx.start.getStartIndex(), ctx.stop.getStopIndex(), DirectionType.PRIOR);
+ }
+
+ @Override
+ public ASTNode visitFirst(final FirstContext ctx) {
+ return new DirectionSegment(ctx.start.getStartIndex(), ctx.stop.getStopIndex(), DirectionType.FIRST);
+ }
+
+ @Override
+ public ASTNode visitLast(final LastContext ctx) {
+ return new DirectionSegment(ctx.start.getStartIndex(), ctx.stop.getStopIndex(), DirectionType.LAST);
+ }
+
+ @Override
+ public ASTNode visitAbsoluteCount(final AbsoluteCountContext ctx) {
+ DirectionSegment result = new DirectionSegment(ctx.start.getStartIndex(), ctx.stop.getStopIndex(), DirectionType.ABSOLUTE_COUNT);
+ result.setCount(((NumberLiteralValue) visit(ctx.signedIconst())).getValue().longValue());
+ return result;
+ }
+
+ @Override
+ public ASTNode visitRelativeCount(final RelativeCountContext ctx) {
+ DirectionSegment result = new DirectionSegment(ctx.start.getStartIndex(), ctx.stop.getStopIndex(), DirectionType.RELATIVE_COUNT);
+ result.setCount(((NumberLiteralValue) visit(ctx.signedIconst())).getValue().longValue());
+ return result;
+ }
+
+ @Override
+ public ASTNode visitCount(final CountContext ctx) {
+ DirectionSegment result = new DirectionSegment(ctx.start.getStartIndex(), ctx.stop.getStopIndex(), DirectionType.COUNT);
+ result.setCount(((NumberLiteralValue) visit(ctx.signedIconst())).getValue().longValue());
+ return result;
+ }
+
+ @Override
+ public ASTNode visitAll(final AllContext ctx) {
+ return new DirectionSegment(ctx.start.getStartIndex(), ctx.stop.getStopIndex(), DirectionType.ALL);
+ }
+
+ @Override
+ public ASTNode visitForward(final ForwardContext ctx) {
+ return new DirectionSegment(ctx.start.getStartIndex(), ctx.stop.getStopIndex(), DirectionType.FORWARD);
+ }
+
+ @Override
+ public ASTNode visitForwardCount(final ForwardCountContext ctx) {
+ DirectionSegment result = new DirectionSegment(ctx.start.getStartIndex(), ctx.stop.getStopIndex(), DirectionType.FORWARD_COUNT);
+ result.setCount(((NumberLiteralValue) visit(ctx.signedIconst())).getValue().longValue());
+ return result;
+ }
+
+ @Override
+ public ASTNode visitForwardAll(final ForwardAllContext ctx) {
+ return new DirectionSegment(ctx.start.getStartIndex(), ctx.stop.getStopIndex(), DirectionType.FORWARD_ALL);
+ }
+
+ @Override
+ public ASTNode visitBackward(final BackwardContext ctx) {
+ return new DirectionSegment(ctx.start.getStartIndex(), ctx.stop.getStopIndex(), DirectionType.BACKWARD);
+ }
+
+ @Override
+ public ASTNode visitBackwardCount(final BackwardCountContext ctx) {
+ DirectionSegment result = new DirectionSegment(ctx.start.getStartIndex(), ctx.stop.getStopIndex(), DirectionType.BACKWARD_COUNT);
+ result.setCount(((NumberLiteralValue) visit(ctx.signedIconst())).getValue().longValue());
+ return result;
+ }
+
+ @Override
+ public ASTNode visitBackwardAll(final BackwardAllContext ctx) {
+ return new DirectionSegment(ctx.start.getStartIndex(), ctx.stop.getStopIndex(), DirectionType.BACKWARD_ALL);
+ }
}
diff --git a/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-opengauss/src/main/java/org/apache/shardingsphere/sql/parser/opengauss/visitor/statement/impl/OpenGaussStatementSQLVisitor.java b/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-opengauss/src/main/java/org/apache/shardingsphere/sql/parser/opengauss/visitor/statement/impl/OpenGaussStatementSQLVisitor.java
index ab6f90bc8ba..bb74402f98f 100644
--- a/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-opengauss/src/main/java/org/apache/shardingsphere/sql/parser/opengauss/visitor/statement/impl/OpenGaussStatementSQLVisitor.java
+++ b/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-opengauss/src/main/java/org/apache/shardingsphere/sql/parser/opengauss/visitor/statement/impl/OpenGaussStatementSQLVisitor.java
@@ -87,6 +87,7 @@ import org.apache.shardingsphere.sql.parser.autogen.OpenGaussStatementParser.Sel
import org.apache.shardingsphere.sql.parser.autogen.OpenGaussStatementParser.SetClauseContext;
import org.apache.shardingsphere.sql.parser.autogen.OpenGaussStatementParser.SetClauseListContext;
import org.apache.shardingsphere.sql.parser.autogen.OpenGaussStatementParser.SetTargetContext;
+import org.apache.shardingsphere.sql.parser.autogen.OpenGaussStatementParser.SignedIconstContext;
import org.apache.shardingsphere.sql.parser.autogen.OpenGaussStatementParser.SimpleSelectContext;
import org.apache.shardingsphere.sql.parser.autogen.OpenGaussStatementParser.SortClauseContext;
import org.apache.shardingsphere.sql.parser.autogen.OpenGaussStatementParser.SortbyContext;
@@ -1213,4 +1214,9 @@ public abstract class OpenGaussStatementSQLVisitor extends OpenGaussStatementBas
}
return result;
}
+
+ @Override
+ public ASTNode visitSignedIconst(final SignedIconstContext ctx) {
+ return new NumberLiteralValue(ctx.getText());
+ }
}
diff --git a/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/common/constant/AggregationType.java b/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/common/constant/AggregationType.java
index 8f080a6136e..7a06e3c2a04 100644
--- a/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/common/constant/AggregationType.java
+++ b/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/common/constant/AggregationType.java
@@ -28,6 +28,7 @@ public enum AggregationType {
/**
* Is aggregation type.
+ *
* @param aggregationType aggregation type
* @return is aggregation type or not
*/
diff --git a/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/common/constant/AggregationType.java b/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/common/constant/DirectionType.java
similarity index 65%
copy from shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/common/constant/AggregationType.java
copy to shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/common/constant/DirectionType.java
index 8f080a6136e..20b1374b5ff 100644
--- a/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/common/constant/AggregationType.java
+++ b/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/common/constant/DirectionType.java
@@ -20,18 +20,19 @@ package org.apache.shardingsphere.sql.parser.sql.common.constant;
import java.util.Arrays;
/**
- * Aggregation function enum.
+ * Direction type enum.
*/
-public enum AggregationType {
+public enum DirectionType {
- MAX, MIN, SUM, COUNT, AVG, BIT_XOR;
+ NEXT, PRIOR, FIRST, LAST, ABSOLUTE_COUNT, RELATIVE_COUNT, COUNT, ALL, FORWARD, FORWARD_COUNT, FORWARD_ALL, BACKWARD, BACKWARD_COUNT, BACKWARD_ALL;
/**
- * Is aggregation type.
- * @param aggregationType aggregation type
- * @return is aggregation type or not
+ * Is direction type.
+ *
+ * @param directionType direction type
+ * @return is direction type or not
*/
- public static boolean isAggregationType(final String aggregationType) {
- return Arrays.stream(values()).anyMatch(each -> aggregationType.equalsIgnoreCase(each.name()));
+ public static boolean isAggregationType(final String directionType) {
+ return Arrays.stream(values()).anyMatch(each -> directionType.equalsIgnoreCase(each.name()));
}
}
diff --git a/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/dialect/statement/opengauss/ddl/OpenGaussFetchStatement.java b/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/common/segment/ddl/cursor/DirectionSegment.java
similarity index 56%
copy from shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/dialect/statement/opengauss/ddl/OpenGaussFetchStatement.java
copy to shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/common/segment/ddl/cursor/DirectionSegment.java
index da09c674f45..e24ecd6f8c7 100644
--- a/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/dialect/statement/opengauss/ddl/OpenGaussFetchStatement.java
+++ b/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/common/segment/ddl/cursor/DirectionSegment.java
@@ -15,23 +15,40 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.sql.parser.sql.dialect.statement.opengauss.ddl;
+package org.apache.shardingsphere.sql.parser.sql.common.segment.ddl.cursor;
import lombok.Getter;
+import lombok.RequiredArgsConstructor;
import lombok.Setter;
import lombok.ToString;
-import org.apache.shardingsphere.sql.parser.sql.common.segment.ddl.cursor.CursorNameSegment;
-import org.apache.shardingsphere.sql.parser.sql.common.statement.AbstractSQLStatement;
-import org.apache.shardingsphere.sql.parser.sql.common.statement.ddl.DDLStatement;
-import org.apache.shardingsphere.sql.parser.sql.dialect.statement.opengauss.OpenGaussStatement;
+import org.apache.shardingsphere.sql.parser.sql.common.constant.DirectionType;
+import org.apache.shardingsphere.sql.parser.sql.common.segment.SQLSegment;
+
+import java.util.Optional;
/**
- * OpenGauss fetch statement.
+ * Direction segment.
*/
+@RequiredArgsConstructor
@Getter
@Setter
@ToString
-public final class OpenGaussFetchStatement extends AbstractSQLStatement implements DDLStatement, OpenGaussStatement {
+public final class DirectionSegment implements SQLSegment {
+
+ private final int startIndex;
+
+ private final int stopIndex;
+
+ private final DirectionType directionType;
+
+ private Long count;
- private CursorNameSegment cursorName;
+ /**
+ * Get count.
+ *
+ * @return count
+ */
+ public Optional<Long> getCount() {
+ return Optional.ofNullable(count);
+ }
}
diff --git a/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/dialect/statement/opengauss/ddl/OpenGaussFetchStatement.java b/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/dialect/statement/opengauss/ddl/OpenGaussFetchStatement.java
index da09c674f45..3482f7e2500 100644
--- a/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/dialect/statement/opengauss/ddl/OpenGaussFetchStatement.java
+++ b/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/dialect/statement/opengauss/ddl/OpenGaussFetchStatement.java
@@ -21,10 +21,13 @@ import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import org.apache.shardingsphere.sql.parser.sql.common.segment.ddl.cursor.CursorNameSegment;
+import org.apache.shardingsphere.sql.parser.sql.common.segment.ddl.cursor.DirectionSegment;
import org.apache.shardingsphere.sql.parser.sql.common.statement.AbstractSQLStatement;
import org.apache.shardingsphere.sql.parser.sql.common.statement.ddl.DDLStatement;
import org.apache.shardingsphere.sql.parser.sql.dialect.statement.opengauss.OpenGaussStatement;
+import java.util.Optional;
+
/**
* OpenGauss fetch statement.
*/
@@ -34,4 +37,15 @@ import org.apache.shardingsphere.sql.parser.sql.dialect.statement.opengauss.Open
public final class OpenGaussFetchStatement extends AbstractSQLStatement implements DDLStatement, OpenGaussStatement {
private CursorNameSegment cursorName;
+
+ private DirectionSegment direction;
+
+ /**
+ * Get direction.
+ *
+ * @return direction
+ */
+ public Optional<DirectionSegment> getDirection() {
+ return Optional.ofNullable(direction);
+ }
}
diff --git a/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/dialect/statement/opengauss/ddl/OpenGaussMoveStatement.java b/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/dialect/statement/opengauss/ddl/OpenGaussMoveStatement.java
index 1029017c483..3e4c6be401b 100644
--- a/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/dialect/statement/opengauss/ddl/OpenGaussMoveStatement.java
+++ b/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/dialect/statement/opengauss/ddl/OpenGaussMoveStatement.java
@@ -21,10 +21,13 @@ import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import org.apache.shardingsphere.sql.parser.sql.common.segment.ddl.cursor.CursorNameSegment;
+import org.apache.shardingsphere.sql.parser.sql.common.segment.ddl.cursor.DirectionSegment;
import org.apache.shardingsphere.sql.parser.sql.common.statement.AbstractSQLStatement;
import org.apache.shardingsphere.sql.parser.sql.common.statement.ddl.DDLStatement;
import org.apache.shardingsphere.sql.parser.sql.dialect.statement.opengauss.OpenGaussStatement;
+import java.util.Optional;
+
/**
* OpenGauss move statement.
*/
@@ -34,4 +37,15 @@ import org.apache.shardingsphere.sql.parser.sql.dialect.statement.opengauss.Open
public final class OpenGaussMoveStatement extends AbstractSQLStatement implements DDLStatement, OpenGaussStatement {
private CursorNameSegment cursorName;
+
+ private DirectionSegment direction;
+
+ /**
+ * Get direction.
+ *
+ * @return direction
+ */
+ public Optional<DirectionSegment> getDirection() {
+ return Optional.ofNullable(direction);
+ }
}
diff --git a/shardingsphere-test/shardingsphere-parser-test/src/main/java/org/apache/shardingsphere/test/sql/parser/parameterized/asserts/segment/cursor/DirectionSegmentAssert.java b/shardingsphere-test/shardingsphere-parser-test/src/main/java/org/apache/shardingsphere/test/sql/parser/parameterized/asserts/segment/cursor/DirectionSegmentAssert.java
new file mode 100644
index 00000000000..2f3140c5aed
--- /dev/null
+++ b/shardingsphere-test/shardingsphere-parser-test/src/main/java/org/apache/shardingsphere/test/sql/parser/parameterized/asserts/segment/cursor/DirectionSegmentAssert.java
@@ -0,0 +1,70 @@
+/*
+ * 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.test.sql.parser.parameterized.asserts.segment.cursor;
+
+import lombok.AccessLevel;
+import lombok.NoArgsConstructor;
+import org.apache.shardingsphere.sql.parser.sql.common.segment.ddl.cursor.DirectionSegment;
+import org.apache.shardingsphere.test.sql.parser.parameterized.asserts.SQLCaseAssertContext;
+import org.apache.shardingsphere.test.sql.parser.parameterized.asserts.segment.SQLSegmentAssert;
+import org.apache.shardingsphere.test.sql.parser.parameterized.jaxb.cases.domain.segment.impl.cursor.ExpectedDirectionSegment;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertTrue;
+
+/**
+ * Direction segment assert.
+ */
+@NoArgsConstructor(access = AccessLevel.PRIVATE)
+public final class DirectionSegmentAssert {
+
+ /**
+ * Assert actual direction segment is correct with expected direction segment.
+ *
+ * @param assertContext assert context
+ * @param actual actual direction segment
+ * @param expected expected direction segment
+ */
+ public static void assertIs(final SQLCaseAssertContext assertContext, final DirectionSegment actual, final ExpectedDirectionSegment expected) {
+ assertDirectionType(assertContext, actual, expected);
+ assertCount(assertContext, actual, expected);
+ SQLSegmentAssert.assertIs(assertContext, actual, expected);
+ }
+
+ private static void assertDirectionType(final SQLCaseAssertContext assertContext, final DirectionSegment actual, final ExpectedDirectionSegment expected) {
+ if (null != expected.getDirectionType()) {
+ assertNotNull(assertContext.getText("Actual direction type should exist."), actual.getDirectionType());
+ assertThat(assertContext.getText("Direction type assertion error: "), actual.getDirectionType().name(), is(expected.getDirectionType()));
+ } else {
+ assertNull(assertContext.getText("Actual direction type should not exist."), actual.getDirectionType());
+ }
+ }
+
+ private static void assertCount(final SQLCaseAssertContext assertContext, final DirectionSegment actual, final ExpectedDirectionSegment expected) {
+ if (null != expected.getCount()) {
+ assertTrue(assertContext.getText("Actual count should exist."), actual.getCount().isPresent());
+ assertThat(assertContext.getText("Count assertion error: "), actual.getCount().get(), is(expected.getCount()));
+ } else {
+ assertFalse(assertContext.getText("Actual count should not exist."), actual.getCount().isPresent());
+ }
+ }
+}
diff --git a/shardingsphere-test/shardingsphere-parser-test/src/main/java/org/apache/shardingsphere/test/sql/parser/parameterized/asserts/statement/ddl/impl/FetchStatementAssert.java b/shardingsphere-test/shardingsphere-parser-test/src/main/java/org/apache/shardingsphere/test/sql/parser/parameterized/asserts/statement/ddl/impl/FetchStatementAssert.java
index 412ffce6e9c..d8748ba17fe 100644
--- a/shardingsphere-test/shardingsphere-parser-test/src/main/java/org/apache/shardingsphere/test/sql/parser/parameterized/asserts/statement/ddl/impl/FetchStatementAssert.java
+++ b/shardingsphere-test/shardingsphere-parser-test/src/main/java/org/apache/shardingsphere/test/sql/parser/parameterized/asserts/statement/ddl/impl/FetchStatementAssert.java
@@ -22,9 +22,13 @@ import lombok.NoArgsConstructor;
import org.apache.shardingsphere.sql.parser.sql.dialect.statement.opengauss.ddl.OpenGaussFetchStatement;
import org.apache.shardingsphere.test.sql.parser.parameterized.asserts.SQLCaseAssertContext;
import org.apache.shardingsphere.test.sql.parser.parameterized.asserts.segment.SQLSegmentAssert;
+import org.apache.shardingsphere.test.sql.parser.parameterized.asserts.segment.cursor.DirectionSegmentAssert;
import org.apache.shardingsphere.test.sql.parser.parameterized.asserts.value.IdentifierValueAssert;
import org.apache.shardingsphere.test.sql.parser.parameterized.jaxb.cases.domain.statement.ddl.FetchStatementTestCase;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
/**
* Fetch statement assert.
*/
@@ -40,10 +44,20 @@ public final class FetchStatementAssert {
*/
public static void assertIs(final SQLCaseAssertContext assertContext, final OpenGaussFetchStatement actual, final FetchStatementTestCase expected) {
assertCursorName(assertContext, actual, expected);
+ assertDirection(assertContext, actual, expected);
}
private static void assertCursorName(final SQLCaseAssertContext assertContext, final OpenGaussFetchStatement actual, final FetchStatementTestCase expected) {
IdentifierValueAssert.assertIs(assertContext, actual.getCursorName().getIdentifier(), expected.getCursorName(), "Fetch");
SQLSegmentAssert.assertIs(assertContext, actual.getCursorName(), expected.getCursorName());
}
+
+ private static void assertDirection(final SQLCaseAssertContext assertContext, final OpenGaussFetchStatement actual, final FetchStatementTestCase expected) {
+ if (null != expected.getDirection()) {
+ assertTrue(assertContext.getText("Actual direction segment should exist."), actual.getDirection().isPresent());
+ DirectionSegmentAssert.assertIs(assertContext, actual.getDirection().get(), expected.getDirection());
+ } else {
+ assertFalse(assertContext.getText("Actual direction segment should not exist."), actual.getDirection().isPresent());
+ }
+ }
}
diff --git a/shardingsphere-test/shardingsphere-parser-test/src/main/java/org/apache/shardingsphere/test/sql/parser/parameterized/asserts/statement/ddl/impl/MoveStatementAssert.java b/shardingsphere-test/shardingsphere-parser-test/src/main/java/org/apache/shardingsphere/test/sql/parser/parameterized/asserts/statement/ddl/impl/MoveStatementAssert.java
index 40dc216d7f6..ae4cedb606d 100644
--- a/shardingsphere-test/shardingsphere-parser-test/src/main/java/org/apache/shardingsphere/test/sql/parser/parameterized/asserts/statement/ddl/impl/MoveStatementAssert.java
+++ b/shardingsphere-test/shardingsphere-parser-test/src/main/java/org/apache/shardingsphere/test/sql/parser/parameterized/asserts/statement/ddl/impl/MoveStatementAssert.java
@@ -22,9 +22,13 @@ import lombok.NoArgsConstructor;
import org.apache.shardingsphere.sql.parser.sql.dialect.statement.opengauss.ddl.OpenGaussMoveStatement;
import org.apache.shardingsphere.test.sql.parser.parameterized.asserts.SQLCaseAssertContext;
import org.apache.shardingsphere.test.sql.parser.parameterized.asserts.segment.SQLSegmentAssert;
+import org.apache.shardingsphere.test.sql.parser.parameterized.asserts.segment.cursor.DirectionSegmentAssert;
import org.apache.shardingsphere.test.sql.parser.parameterized.asserts.value.IdentifierValueAssert;
import org.apache.shardingsphere.test.sql.parser.parameterized.jaxb.cases.domain.statement.ddl.MoveStatementTestCase;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
/**
* Move statement assert.
*/
@@ -40,10 +44,20 @@ public final class MoveStatementAssert {
*/
public static void assertIs(final SQLCaseAssertContext assertContext, final OpenGaussMoveStatement actual, final MoveStatementTestCase expected) {
assertCursorName(assertContext, actual, expected);
+ assertDirection(assertContext, actual, expected);
}
private static void assertCursorName(final SQLCaseAssertContext assertContext, final OpenGaussMoveStatement actual, final MoveStatementTestCase expected) {
IdentifierValueAssert.assertIs(assertContext, actual.getCursorName().getIdentifier(), expected.getCursorName(), "Move");
SQLSegmentAssert.assertIs(assertContext, actual.getCursorName(), expected.getCursorName());
}
+
+ private static void assertDirection(final SQLCaseAssertContext assertContext, final OpenGaussMoveStatement actual, final MoveStatementTestCase expected) {
+ if (null != expected.getDirection()) {
+ assertTrue(assertContext.getText("Actual direction segment should exist."), actual.getDirection().isPresent());
+ DirectionSegmentAssert.assertIs(assertContext, actual.getDirection().get(), expected.getDirection());
+ } else {
+ assertFalse(assertContext.getText("Actual direction segment should not exist."), actual.getDirection().isPresent());
+ }
+ }
}
diff --git a/shardingsphere-test/shardingsphere-parser-test/src/main/java/org/apache/shardingsphere/test/sql/parser/parameterized/jaxb/cases/domain/statement/ddl/MoveStatementTestCase.java b/shardingsphere-test/shardingsphere-parser-test/src/main/java/org/apache/shardingsphere/test/sql/parser/parameterized/jaxb/cases/domain/segment/impl/cursor/ExpectedDirectionSegment.java
similarity index 70%
copy from shardingsphere-test/shardingsphere-parser-test/src/main/java/org/apache/shardingsphere/test/sql/parser/parameterized/jaxb/cases/domain/statement/ddl/MoveStatementTestCase.java
copy to shardingsphere-test/shardingsphere-parser-test/src/main/java/org/apache/shardingsphere/test/sql/parser/parameterized/jaxb/cases/domain/segment/impl/cursor/ExpectedDirectionSegment.java
index 2ae5560b7eb..162edeafb8a 100644
--- a/shardingsphere-test/shardingsphere-parser-test/src/main/java/org/apache/shardingsphere/test/sql/parser/parameterized/jaxb/cases/domain/statement/ddl/MoveStatementTestCase.java
+++ b/shardingsphere-test/shardingsphere-parser-test/src/main/java/org/apache/shardingsphere/test/sql/parser/parameterized/jaxb/cases/domain/segment/impl/cursor/ExpectedDirectionSegment.java
@@ -15,22 +15,24 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.test.sql.parser.parameterized.jaxb.cases.domain.statement.ddl;
+package org.apache.shardingsphere.test.sql.parser.parameterized.jaxb.cases.domain.segment.impl.cursor;
import lombok.Getter;
import lombok.Setter;
-import org.apache.shardingsphere.test.sql.parser.parameterized.jaxb.cases.domain.segment.impl.cursor.ExpectedCursorName;
-import org.apache.shardingsphere.test.sql.parser.parameterized.jaxb.cases.domain.statement.SQLParserTestCase;
+import org.apache.shardingsphere.test.sql.parser.parameterized.jaxb.cases.domain.segment.AbstractExpectedSQLSegment;
-import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlAttribute;
/**
- * Move statement test case.
+ * Expected direction segment.
*/
@Getter
@Setter
-public final class MoveStatementTestCase extends SQLParserTestCase {
+public final class ExpectedDirectionSegment extends AbstractExpectedSQLSegment {
- @XmlElement(name = "cursor-name")
- private ExpectedCursorName cursorName;
+ @XmlAttribute(name = "direction-type")
+ private String directionType;
+
+ @XmlAttribute(name = "count")
+ private Long count;
}
diff --git a/shardingsphere-test/shardingsphere-parser-test/src/main/java/org/apache/shardingsphere/test/sql/parser/parameterized/jaxb/cases/domain/statement/ddl/FetchStatementTestCase.java b/shardingsphere-test/shardingsphere-parser-test/src/main/java/org/apache/shardingsphere/test/sql/parser/parameterized/jaxb/cases/domain/statement/ddl/FetchStatementTestCase.java
index ebbc29aa603..bbcb56bf45a 100644
--- a/shardingsphere-test/shardingsphere-parser-test/src/main/java/org/apache/shardingsphere/test/sql/parser/parameterized/jaxb/cases/domain/statement/ddl/FetchStatementTestCase.java
+++ b/shardingsphere-test/shardingsphere-parser-test/src/main/java/org/apache/shardingsphere/test/sql/parser/parameterized/jaxb/cases/domain/statement/ddl/FetchStatementTestCase.java
@@ -20,6 +20,7 @@ package org.apache.shardingsphere.test.sql.parser.parameterized.jaxb.cases.domai
import lombok.Getter;
import lombok.Setter;
import org.apache.shardingsphere.test.sql.parser.parameterized.jaxb.cases.domain.segment.impl.cursor.ExpectedCursorName;
+import org.apache.shardingsphere.test.sql.parser.parameterized.jaxb.cases.domain.segment.impl.cursor.ExpectedDirectionSegment;
import org.apache.shardingsphere.test.sql.parser.parameterized.jaxb.cases.domain.statement.SQLParserTestCase;
import javax.xml.bind.annotation.XmlElement;
@@ -33,4 +34,7 @@ public final class FetchStatementTestCase extends SQLParserTestCase {
@XmlElement(name = "cursor-name")
private ExpectedCursorName cursorName;
+
+ @XmlElement(name = "direction")
+ private ExpectedDirectionSegment direction;
}
diff --git a/shardingsphere-test/shardingsphere-parser-test/src/main/java/org/apache/shardingsphere/test/sql/parser/parameterized/jaxb/cases/domain/statement/ddl/MoveStatementTestCase.java b/shardingsphere-test/shardingsphere-parser-test/src/main/java/org/apache/shardingsphere/test/sql/parser/parameterized/jaxb/cases/domain/statement/ddl/MoveStatementTestCase.java
index 2ae5560b7eb..9053b1b0612 100644
--- a/shardingsphere-test/shardingsphere-parser-test/src/main/java/org/apache/shardingsphere/test/sql/parser/parameterized/jaxb/cases/domain/statement/ddl/MoveStatementTestCase.java
+++ b/shardingsphere-test/shardingsphere-parser-test/src/main/java/org/apache/shardingsphere/test/sql/parser/parameterized/jaxb/cases/domain/statement/ddl/MoveStatementTestCase.java
@@ -20,6 +20,7 @@ package org.apache.shardingsphere.test.sql.parser.parameterized.jaxb.cases.domai
import lombok.Getter;
import lombok.Setter;
import org.apache.shardingsphere.test.sql.parser.parameterized.jaxb.cases.domain.segment.impl.cursor.ExpectedCursorName;
+import org.apache.shardingsphere.test.sql.parser.parameterized.jaxb.cases.domain.segment.impl.cursor.ExpectedDirectionSegment;
import org.apache.shardingsphere.test.sql.parser.parameterized.jaxb.cases.domain.statement.SQLParserTestCase;
import javax.xml.bind.annotation.XmlElement;
@@ -33,4 +34,7 @@ public final class MoveStatementTestCase extends SQLParserTestCase {
@XmlElement(name = "cursor-name")
private ExpectedCursorName cursorName;
+
+ @XmlElement(name = "direction")
+ private ExpectedDirectionSegment direction;
}
diff --git a/shardingsphere-test/shardingsphere-parser-test/src/main/resources/case/ddl/fetch.xml b/shardingsphere-test/shardingsphere-parser-test/src/main/resources/case/ddl/fetch.xml
index 0f1a2623b18..6f61f143496 100644
--- a/shardingsphere-test/shardingsphere-parser-test/src/main/resources/case/ddl/fetch.xml
+++ b/shardingsphere-test/shardingsphere-parser-test/src/main/resources/case/ddl/fetch.xml
@@ -17,7 +17,73 @@
-->
<sql-parser-test-cases>
- <fetch sql-case-id="fetch_cursor">
+ <fetch sql-case-id="fetch_next">
+ <cursor-name name="t_order_cursor" start-index="16" stop-index="29" />
+ <direction direction-type="NEXT" start-index="6" stop-index="9" />
+ </fetch>
+
+ <fetch sql-case-id="fetch_prior">
+ <cursor-name name="t_order_cursor" start-index="17" stop-index="30" />
+ <direction direction-type="PRIOR" start-index="6" stop-index="10" />
+ </fetch>
+
+ <fetch sql-case-id="fetch_first">
+ <cursor-name name="t_order_cursor" start-index="17" stop-index="30" />
+ <direction direction-type="FIRST" start-index="6" stop-index="10" />
+ </fetch>
+
+ <fetch sql-case-id="fetch_last">
+ <cursor-name name="t_order_cursor" start-index="16" stop-index="29" />
+ <direction direction-type="LAST" start-index="6" stop-index="9" />
+ </fetch>
+
+ <fetch sql-case-id="fetch_absolute_count">
+ <cursor-name name="t_order_cursor" start-index="23" stop-index="36" />
+ <direction direction-type="ABSOLUTE_COUNT" count="10" start-index="6" stop-index="16" />
+ </fetch>
+
+ <fetch sql-case-id="fetch_relative_count">
+ <cursor-name name="t_order_cursor" start-index="23" stop-index="36" />
+ <direction direction-type="RELATIVE_COUNT" count="10" start-index="6" stop-index="16" />
+ </fetch>
+
+ <fetch sql-case-id="fetch_count">
+ <cursor-name name="t_order_cursor" start-index="14" stop-index="27" />
+ <direction direction-type="COUNT" count="10" start-index="6" stop-index="7" />
+ </fetch>
+
+ <fetch sql-case-id="fetch_all">
<cursor-name name="t_order_cursor" start-index="15" stop-index="28" />
+ <direction direction-type="ALL" start-index="6" stop-index="8" />
+ </fetch>
+
+ <fetch sql-case-id="fetch_forward">
+ <cursor-name name="t_order_cursor" start-index="19" stop-index="32" />
+ <direction direction-type="FORWARD" start-index="6" stop-index="12" />
+ </fetch>
+
+ <fetch sql-case-id="fetch_forward_count">
+ <cursor-name name="t_order_cursor" start-index="22" stop-index="35" />
+ <direction direction-type="FORWARD_COUNT" count="10" start-index="6" stop-index="15" />
+ </fetch>
+
+ <fetch sql-case-id="fetch_forward_all">
+ <cursor-name name="t_order_cursor" start-index="23" stop-index="36" />
+ <direction direction-type="FORWARD_ALL" start-index="6" stop-index="16" />
+ </fetch>
+
+ <fetch sql-case-id="fetch_backward">
+ <cursor-name name="t_order_cursor" start-index="20" stop-index="33" />
+ <direction direction-type="BACKWARD" start-index="6" stop-index="13" />
+ </fetch>
+
+ <fetch sql-case-id="fetch_backward_count">
+ <cursor-name name="t_order_cursor" start-index="23" stop-index="36" />
+ <direction direction-type="BACKWARD_COUNT" count="10" start-index="6" stop-index="16" />
+ </fetch>
+
+ <fetch sql-case-id="fetch_backward_all">
+ <cursor-name name="t_order_cursor" start-index="24" stop-index="37" />
+ <direction direction-type="BACKWARD_ALL" start-index="6" stop-index="17" />
</fetch>
</sql-parser-test-cases>
diff --git a/shardingsphere-test/shardingsphere-parser-test/src/main/resources/case/ddl/move.xml b/shardingsphere-test/shardingsphere-parser-test/src/main/resources/case/ddl/move.xml
index 132e3ef135f..5f705abbcd2 100644
--- a/shardingsphere-test/shardingsphere-parser-test/src/main/resources/case/ddl/move.xml
+++ b/shardingsphere-test/shardingsphere-parser-test/src/main/resources/case/ddl/move.xml
@@ -17,7 +17,73 @@
-->
<sql-parser-test-cases>
- <move sql-case-id="move_cursor">
- <cursor-name name="t_order_cursor" start-index="9" stop-index="22" />
+ <move sql-case-id="move_next">
+ <cursor-name name="t_order_cursor" start-index="15" stop-index="28" />
+ <direction direction-type="NEXT" start-index="5" stop-index="8" />
+ </move>
+
+ <move sql-case-id="move_prior">
+ <cursor-name name="t_order_cursor" start-index="16" stop-index="29" />
+ <direction direction-type="PRIOR" start-index="5" stop-index="9" />
+ </move>
+
+ <move sql-case-id="move_first">
+ <cursor-name name="t_order_cursor" start-index="16" stop-index="29" />
+ <direction direction-type="FIRST" start-index="5" stop-index="9" />
+ </move>
+
+ <move sql-case-id="move_last">
+ <cursor-name name="t_order_cursor" start-index="15" stop-index="28" />
+ <direction direction-type="LAST" start-index="5" stop-index="8" />
+ </move>
+
+ <move sql-case-id="move_absolute_count">
+ <cursor-name name="t_order_cursor" start-index="22" stop-index="35" />
+ <direction direction-type="ABSOLUTE_COUNT" count="10" start-index="5" stop-index="15" />
+ </move>
+
+ <move sql-case-id="move_relative_count">
+ <cursor-name name="t_order_cursor" start-index="22" stop-index="35" />
+ <direction direction-type="RELATIVE_COUNT" count="10" start-index="5" stop-index="15" />
+ </move>
+
+ <move sql-case-id="move_count">
+ <cursor-name name="t_order_cursor" start-index="13" stop-index="26" />
+ <direction direction-type="COUNT" count="10" start-index="5" stop-index="6" />
+ </move>
+
+ <move sql-case-id="move_all">
+ <cursor-name name="t_order_cursor" start-index="14" stop-index="27" />
+ <direction direction-type="ALL" start-index="5" stop-index="7" />
+ </move>
+
+ <move sql-case-id="move_forward">
+ <cursor-name name="t_order_cursor" start-index="18" stop-index="31" />
+ <direction direction-type="FORWARD" start-index="5" stop-index="11" />
+ </move>
+
+ <move sql-case-id="move_forward_count">
+ <cursor-name name="t_order_cursor" start-index="21" stop-index="34" />
+ <direction direction-type="FORWARD_COUNT" count="10" start-index="5" stop-index="14" />
+ </move>
+
+ <move sql-case-id="move_forward_all">
+ <cursor-name name="t_order_cursor" start-index="22" stop-index="35" />
+ <direction direction-type="FORWARD_ALL" start-index="5" stop-index="15" />
+ </move>
+
+ <move sql-case-id="move_backward">
+ <cursor-name name="t_order_cursor" start-index="19" stop-index="32" />
+ <direction direction-type="BACKWARD" start-index="5" stop-index="12" />
+ </move>
+
+ <move sql-case-id="move_backward_count">
+ <cursor-name name="t_order_cursor" start-index="22" stop-index="35" />
+ <direction direction-type="BACKWARD_COUNT" count="10" start-index="5" stop-index="15" />
+ </move>
+
+ <move sql-case-id="move_backward_all">
+ <cursor-name name="t_order_cursor" start-index="23" stop-index="36" />
+ <direction direction-type="BACKWARD_ALL" start-index="5" stop-index="16" />
</move>
</sql-parser-test-cases>
diff --git a/shardingsphere-test/shardingsphere-parser-test/src/main/resources/sql/supported/ddl/fetch.xml b/shardingsphere-test/shardingsphere-parser-test/src/main/resources/sql/supported/ddl/fetch.xml
index 013c0894103..f0dc70e5693 100644
--- a/shardingsphere-test/shardingsphere-parser-test/src/main/resources/sql/supported/ddl/fetch.xml
+++ b/shardingsphere-test/shardingsphere-parser-test/src/main/resources/sql/supported/ddl/fetch.xml
@@ -17,5 +17,18 @@
-->
<sql-cases>
- <sql-case id="fetch_cursor" value="FETCH ALL FROM t_order_cursor;" db-types="openGauss" />
+ <sql-case id="fetch_next" value="FETCH NEXT FROM t_order_cursor;" db-types="openGauss" />
+ <sql-case id="fetch_prior" value="FETCH PRIOR FROM t_order_cursor;" db-types="openGauss" />
+ <sql-case id="fetch_first" value="FETCH FIRST FROM t_order_cursor;" db-types="openGauss" />
+ <sql-case id="fetch_last" value="FETCH LAST FROM t_order_cursor;" db-types="openGauss" />
+ <sql-case id="fetch_absolute_count" value="FETCH ABSOLUTE 10 FROM t_order_cursor;" db-types="openGauss" />
+ <sql-case id="fetch_relative_count" value="FETCH RELATIVE 10 FROM t_order_cursor;" db-types="openGauss" />
+ <sql-case id="fetch_count" value="FETCH 10 FROM t_order_cursor;" db-types="openGauss" />
+ <sql-case id="fetch_all" value="FETCH ALL FROM t_order_cursor;" db-types="openGauss" />
+ <sql-case id="fetch_forward" value="FETCH FORWARD FROM t_order_cursor;" db-types="openGauss" />
+ <sql-case id="fetch_forward_count" value="FETCH FORWARD 10 FROM t_order_cursor;" db-types="openGauss" />
+ <sql-case id="fetch_forward_all" value="FETCH FORWARD ALL FROM t_order_cursor;" db-types="openGauss" />
+ <sql-case id="fetch_backward" value="FETCH BACKWARD FROM t_order_cursor;" db-types="openGauss" />
+ <sql-case id="fetch_backward_count" value="FETCH BACKWARD 10 FROM t_order_cursor;" db-types="openGauss" />
+ <sql-case id="fetch_backward_all" value="FETCH BACKWARD ALL FROM t_order_cursor;" db-types="openGauss" />
</sql-cases>
diff --git a/shardingsphere-test/shardingsphere-parser-test/src/main/resources/sql/supported/ddl/move.xml b/shardingsphere-test/shardingsphere-parser-test/src/main/resources/sql/supported/ddl/move.xml
index e6f143f1b69..a01e916d258 100644
--- a/shardingsphere-test/shardingsphere-parser-test/src/main/resources/sql/supported/ddl/move.xml
+++ b/shardingsphere-test/shardingsphere-parser-test/src/main/resources/sql/supported/ddl/move.xml
@@ -17,5 +17,18 @@
-->
<sql-cases>
- <sql-case id="move_cursor" value="MOVE ALL t_order_cursor;" db-types="openGauss" />
+ <sql-case id="move_next" value="MOVE NEXT FROM t_order_cursor;" db-types="openGauss" />
+ <sql-case id="move_prior" value="MOVE PRIOR FROM t_order_cursor;" db-types="openGauss" />
+ <sql-case id="move_first" value="MOVE FIRST FROM t_order_cursor;" db-types="openGauss" />
+ <sql-case id="move_last" value="MOVE LAST FROM t_order_cursor;" db-types="openGauss" />
+ <sql-case id="move_absolute_count" value="MOVE ABSOLUTE 10 FROM t_order_cursor;" db-types="openGauss" />
+ <sql-case id="move_relative_count" value="MOVE RELATIVE 10 FROM t_order_cursor;" db-types="openGauss" />
+ <sql-case id="move_count" value="MOVE 10 FROM t_order_cursor;" db-types="openGauss" />
+ <sql-case id="move_all" value="MOVE ALL FROM t_order_cursor;" db-types="openGauss" />
+ <sql-case id="move_forward" value="MOVE FORWARD FROM t_order_cursor;" db-types="openGauss" />
+ <sql-case id="move_forward_count" value="MOVE FORWARD 10 FROM t_order_cursor;" db-types="openGauss" />
+ <sql-case id="move_forward_all" value="MOVE FORWARD ALL FROM t_order_cursor;" db-types="openGauss" />
+ <sql-case id="move_backward" value="MOVE BACKWARD FROM t_order_cursor;" db-types="openGauss" />
+ <sql-case id="move_backward_count" value="MOVE BACKWARD 10 FROM t_order_cursor;" db-types="openGauss" />
+ <sql-case id="move_backward_all" value="MOVE BACKWARD ALL FROM t_order_cursor;" db-types="openGauss" />
</sql-cases>