Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move CheckpointStatement to tcl package and visitor logic to tcl visitor, remove LockTableStatement #31758

Merged
merged 3 commits into from
Jun 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -435,25 +435,6 @@ dostmtOptItem
: STRING_ | LANGUAGE nonReservedWordOrSconst
;

lock
: LOCK TABLE? relationExprList (IN lockType MODE)? NOWAIT?
;

lockType
: ACCESS SHARE
| ROW SHARE
| ROW EXCLUSIVE
| SHARE UPDATE EXCLUSIVE
| SHARE
| SHARE ROW EXCLUSIVE
| EXCLUSIVE
| ACCESS EXCLUSIVE
;

checkpoint
: CHECKPOINT
;

copy
: COPY (BINARY)? qualifiedName (LP_ columnList RP_)? (FROM | TO) PROGRAM?
(STRING_ | STDIN | STDOUT) copyDelimiter? (WITH)? copyOptions whereClause?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,3 +84,21 @@ constraintsSetList
: ALL | qualifiedNameList
;

checkpoint
: CHECKPOINT
;

lock
: LOCK TABLE? relationExprList (IN lockType MODE)? NOWAIT?
;

lockType
: ACCESS SHARE
| ROW SHARE
| ROW EXCLUSIVE
| SHARE UPDATE EXCLUSIVE
| SHARE
| SHARE ROW EXCLUSIVE
| EXCLUSIVE
| ACCESS EXCLUSIVE
;
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import org.apache.shardingsphere.sql.parser.api.ASTNode;
import org.apache.shardingsphere.sql.parser.api.visitor.statement.type.DMLStatementVisitor;
import org.apache.shardingsphere.sql.parser.autogen.OpenGaussStatementParser.CallContext;
import org.apache.shardingsphere.sql.parser.autogen.OpenGaussStatementParser.CheckpointContext;
import org.apache.shardingsphere.sql.parser.autogen.OpenGaussStatementParser.CopyContext;
import org.apache.shardingsphere.sql.parser.autogen.OpenGaussStatementParser.DoStatementContext;
import org.apache.shardingsphere.sql.parser.autogen.OpenGaussStatementParser.ReturningClauseContext;
Expand All @@ -29,7 +28,6 @@
import org.apache.shardingsphere.sql.parser.sql.common.segment.dml.item.ProjectionsSegment;
import org.apache.shardingsphere.sql.parser.sql.common.segment.generic.table.SimpleTableSegment;
import org.apache.shardingsphere.sql.parser.sql.dialect.statement.opengauss.dml.OpenGaussCallStatement;
import org.apache.shardingsphere.sql.parser.sql.dialect.statement.opengauss.dml.OpenGaussCheckpointStatement;
import org.apache.shardingsphere.sql.parser.sql.dialect.statement.opengauss.dml.OpenGaussCopyStatement;
import org.apache.shardingsphere.sql.parser.sql.dialect.statement.opengauss.dml.OpenGaussDoStatement;

Expand Down Expand Up @@ -57,11 +55,6 @@ public ASTNode visitCopy(final CopyContext ctx) {
return result;
}

@Override
public ASTNode visitCheckpoint(final CheckpointContext ctx) {
return new OpenGaussCheckpointStatement();
}

@Override
public ASTNode visitReturningClause(final ReturningClauseContext ctx) {
return new ReturningSegment(ctx.start.getStartIndex(), ctx.stop.getStopIndex(), (ProjectionsSegment) visit(ctx.targetList()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import org.apache.shardingsphere.sql.parser.api.visitor.statement.type.TCLStatementVisitor;
import org.apache.shardingsphere.sql.parser.autogen.OpenGaussStatementParser.AbortContext;
import org.apache.shardingsphere.sql.parser.autogen.OpenGaussStatementParser.BeginTransactionContext;
import org.apache.shardingsphere.sql.parser.autogen.OpenGaussStatementParser.CheckpointContext;
import org.apache.shardingsphere.sql.parser.autogen.OpenGaussStatementParser.CommitContext;
import org.apache.shardingsphere.sql.parser.autogen.OpenGaussStatementParser.CommitPreparedContext;
import org.apache.shardingsphere.sql.parser.autogen.OpenGaussStatementParser.EndContext;
Expand All @@ -34,6 +35,7 @@
import org.apache.shardingsphere.sql.parser.autogen.OpenGaussStatementParser.StartTransactionContext;
import org.apache.shardingsphere.sql.parser.opengauss.visitor.statement.OpenGaussStatementVisitor;
import org.apache.shardingsphere.sql.parser.sql.dialect.statement.opengauss.tcl.OpenGaussBeginTransactionStatement;
import org.apache.shardingsphere.sql.parser.sql.dialect.statement.opengauss.tcl.OpenGaussCheckpointStatement;
import org.apache.shardingsphere.sql.parser.sql.dialect.statement.opengauss.tcl.OpenGaussCommitPreparedStatement;
import org.apache.shardingsphere.sql.parser.sql.dialect.statement.opengauss.tcl.OpenGaussCommitStatement;
import org.apache.shardingsphere.sql.parser.sql.dialect.statement.opengauss.tcl.OpenGaussReleaseSavepointStatement;
Expand Down Expand Up @@ -121,4 +123,9 @@ public ASTNode visitCommitPrepared(final CommitPreparedContext ctx) {
public ASTNode visitRollbackPrepared(final RollbackPreparedContext ctx) {
return new OpenGaussRollbackPreparedStatement();
}

@Override
public ASTNode visitCheckpoint(final CheckpointContext ctx) {
return new OpenGaussCheckpointStatement();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -882,7 +882,7 @@ rowPatternAggregateFunc
: (RUNNING | FINAL)? aggregationFunction
;

lockTable
lock
: LOCK TABLE (tableName | viewName) (partitionExtensionClause | AT_ dbLink)? (COMMA_ (tableName | viewName) (partitionExtensionClause | AT_ dbLink)? )* IN lockmodeClause MODE ( NOWAIT | WAIT INTEGER_)?
;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@ sqlStatementInPlsql
// TODO collection_method_call
| delete
| insert
| lockTable
| lock
| merge
| rollback
| savepoint
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ execute
| alterTable
| dropTable
| truncateTable
| lockTable
| lock
| createIndex
| dropIndex
| alterIndex
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@
import org.apache.shardingsphere.sql.parser.autogen.OracleStatementParser.DropColumnSpecificationContext;
import org.apache.shardingsphere.sql.parser.autogen.OracleStatementParser.DropConstraintClauseContext;
import org.apache.shardingsphere.sql.parser.autogen.OracleStatementParser.DropContextContext;
import org.apache.shardingsphere.sql.parser.autogen.OracleStatementParser.DropDatabaseContext;
import org.apache.shardingsphere.sql.parser.autogen.OracleStatementParser.DropDatabaseLinkContext;
import org.apache.shardingsphere.sql.parser.autogen.OracleStatementParser.DropDimensionContext;
import org.apache.shardingsphere.sql.parser.autogen.OracleStatementParser.DropDirectoryContext;
Expand Down Expand Up @@ -194,7 +195,6 @@
import org.apache.shardingsphere.sql.parser.autogen.OracleStatementParser.TypeNameContext;
import org.apache.shardingsphere.sql.parser.autogen.OracleStatementParser.VariableNameContext;
import org.apache.shardingsphere.sql.parser.autogen.OracleStatementParser.VarrayTypeSpecContext;
import org.apache.shardingsphere.sql.parser.autogen.OracleStatementParser.DropDatabaseContext;
import org.apache.shardingsphere.sql.parser.oracle.visitor.statement.OracleStatementVisitor;
import org.apache.shardingsphere.sql.parser.sql.common.segment.dal.VariableSegment;
import org.apache.shardingsphere.sql.parser.sql.common.segment.ddl.AlterDefinitionSegment;
Expand Down Expand Up @@ -308,6 +308,7 @@
import org.apache.shardingsphere.sql.parser.sql.dialect.statement.oracle.ddl.OracleDropClusterStatement;
import org.apache.shardingsphere.sql.parser.sql.dialect.statement.oracle.ddl.OracleDropContextStatement;
import org.apache.shardingsphere.sql.parser.sql.dialect.statement.oracle.ddl.OracleDropDatabaseLinkStatement;
import org.apache.shardingsphere.sql.parser.sql.dialect.statement.oracle.ddl.OracleDropDatabaseStatement;
import org.apache.shardingsphere.sql.parser.sql.dialect.statement.oracle.ddl.OracleDropDimensionStatement;
import org.apache.shardingsphere.sql.parser.sql.dialect.statement.oracle.ddl.OracleDropDirectoryStatement;
import org.apache.shardingsphere.sql.parser.sql.dialect.statement.oracle.ddl.OracleDropDiskgroupStatement;
Expand Down Expand Up @@ -347,7 +348,6 @@
import org.apache.shardingsphere.sql.parser.sql.dialect.statement.oracle.ddl.OracleSwitchStatement;
import org.apache.shardingsphere.sql.parser.sql.dialect.statement.oracle.ddl.OracleSystemActionStatement;
import org.apache.shardingsphere.sql.parser.sql.dialect.statement.oracle.ddl.OracleTruncateStatement;
import org.apache.shardingsphere.sql.parser.sql.dialect.statement.oracle.ddl.OracleDropDatabaseStatement;
import org.apache.shardingsphere.sql.parser.sql.dialect.statement.oracle.dml.OracleSelectStatement;
import org.apache.shardingsphere.sql.parser.sql.dialect.statement.oracle.plsql.CursorForLoopStatementSegment;
import org.apache.shardingsphere.sql.parser.sql.dialect.statement.oracle.plsql.ProcedureBodyEndNameSegment;
Expand Down Expand Up @@ -1547,10 +1547,10 @@ public ASTNode visitSqlStatementInPlsql(final SqlStatementInPlsqlContext ctx) {
getSqlStatementsInPlsql().add(new SQLStatementSegment(ctx.insert().start.getStartIndex(), ctx.insert().stop.getStopIndex(), result));
addToTempCursorForLoopStatements(result);
}
if (null != ctx.lockTable()) {
if (null != ctx.lock()) {
OracleStatementVisitor visitor = createOracleDMLStatementVisitor();
SQLStatement result = (SQLStatement) visitor.visitLockTable(ctx.lockTable());
getSqlStatementsInPlsql().add(new SQLStatementSegment(ctx.lockTable().start.getStartIndex(), ctx.lockTable().stop.getStopIndex(), result));
SQLStatement result = (SQLStatement) visitor.visitLock(ctx.lock());
getSqlStatementsInPlsql().add(new SQLStatementSegment(ctx.lock().start.getStartIndex(), ctx.lock().stop.getStopIndex(), result));
addToTempCursorForLoopStatements(result);
}
if (null != ctx.merge()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@
import org.apache.shardingsphere.sql.parser.autogen.OracleStatementParser.InsertValuesClauseContext;
import org.apache.shardingsphere.sql.parser.autogen.OracleStatementParser.IntoClauseContext;
import org.apache.shardingsphere.sql.parser.autogen.OracleStatementParser.JoinClauseContext;
import org.apache.shardingsphere.sql.parser.autogen.OracleStatementParser.LockTableContext;
import org.apache.shardingsphere.sql.parser.autogen.OracleStatementParser.MergeAssignmentContext;
import org.apache.shardingsphere.sql.parser.autogen.OracleStatementParser.MergeAssignmentValueContext;
import org.apache.shardingsphere.sql.parser.autogen.OracleStatementParser.MergeColumnValueContext;
Expand Down Expand Up @@ -185,7 +184,6 @@
import org.apache.shardingsphere.sql.parser.sql.dialect.segment.oracle.xml.XmlTableFunctionSegment;
import org.apache.shardingsphere.sql.parser.sql.dialect.statement.oracle.dml.OracleDeleteStatement;
import org.apache.shardingsphere.sql.parser.sql.dialect.statement.oracle.dml.OracleInsertStatement;
import org.apache.shardingsphere.sql.parser.sql.dialect.statement.oracle.dml.OracleLockTableStatement;
import org.apache.shardingsphere.sql.parser.sql.dialect.statement.oracle.dml.OracleMergeStatement;
import org.apache.shardingsphere.sql.parser.sql.dialect.statement.oracle.dml.OracleSelectStatement;
import org.apache.shardingsphere.sql.parser.sql.dialect.statement.oracle.dml.OracleUpdateStatement;
Expand Down Expand Up @@ -1452,10 +1450,4 @@ public ASTNode visitDeleteWhereClause(final DeleteWhereClauseContext ctx) {
ASTNode segment = visit(ctx.whereClause().expr());
return new WhereSegment(ctx.getStart().getStartIndex(), ctx.getStop().getStopIndex(), (ExpressionSegment) segment);
}

@Override
public ASTNode visitLockTable(final LockTableContext ctx) {
return new OracleLockTableStatement();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,14 @@
import org.apache.shardingsphere.sql.parser.api.ASTNode;
import org.apache.shardingsphere.sql.parser.api.visitor.statement.type.TCLStatementVisitor;
import org.apache.shardingsphere.sql.parser.autogen.OracleStatementParser.CommitContext;
import org.apache.shardingsphere.sql.parser.autogen.OracleStatementParser.LockContext;
import org.apache.shardingsphere.sql.parser.autogen.OracleStatementParser.RollbackContext;
import org.apache.shardingsphere.sql.parser.autogen.OracleStatementParser.SavepointContext;
import org.apache.shardingsphere.sql.parser.autogen.OracleStatementParser.SetConstraintsContext;
import org.apache.shardingsphere.sql.parser.autogen.OracleStatementParser.SetTransactionContext;
import org.apache.shardingsphere.sql.parser.oracle.visitor.statement.OracleStatementVisitor;
import org.apache.shardingsphere.sql.parser.sql.common.value.identifier.IdentifierValue;
import org.apache.shardingsphere.sql.parser.sql.dialect.statement.oracle.dml.OracleLockStatement;
import org.apache.shardingsphere.sql.parser.sql.dialect.statement.oracle.tcl.OracleCommitStatement;
import org.apache.shardingsphere.sql.parser.sql.dialect.statement.oracle.tcl.OracleRollbackStatement;
import org.apache.shardingsphere.sql.parser.sql.dialect.statement.oracle.tcl.OracleSavepointStatement;
Expand Down Expand Up @@ -67,4 +69,9 @@ public ASTNode visitSavepoint(final SavepointContext ctx) {
public ASTNode visitSetConstraints(final SetConstraintsContext ctx) {
return new OracleSetConstraintsStatement();
}

@Override
public ASTNode visitLock(final LockContext ctx) {
return new OracleLockStatement();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -447,10 +447,6 @@ dostmtOptItem
: STRING_ | LANGUAGE nonReservedWordOrSconst
;

checkpoint
: CHECKPOINT
;

copy
: copyWithTableOrQuery | copyWithTableOrQueryBinaryCsv | copyWithTableBinary
;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,3 +102,7 @@ lockType
prepareTransaction
: PREPARE TRANSACTION STRING_
;

checkpoint
: CHECKPOINT
;
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import org.apache.shardingsphere.sql.parser.api.visitor.statement.type.DMLStatementVisitor;
import org.apache.shardingsphere.sql.parser.autogen.PostgreSQLStatementParser.CallArgumentContext;
import org.apache.shardingsphere.sql.parser.autogen.PostgreSQLStatementParser.CallContext;
import org.apache.shardingsphere.sql.parser.autogen.PostgreSQLStatementParser.CheckpointContext;
import org.apache.shardingsphere.sql.parser.autogen.PostgreSQLStatementParser.CopyContext;
import org.apache.shardingsphere.sql.parser.autogen.PostgreSQLStatementParser.CopyWithTableBinaryContext;
import org.apache.shardingsphere.sql.parser.autogen.PostgreSQLStatementParser.CopyWithTableOrQueryBinaryCsvContext;
Expand All @@ -45,7 +44,6 @@
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.dialect.statement.postgresql.dml.PostgreSQLCallStatement;
import org.apache.shardingsphere.sql.parser.sql.dialect.statement.postgresql.dml.PostgreSQLCheckpointStatement;
import org.apache.shardingsphere.sql.parser.sql.dialect.statement.postgresql.dml.PostgreSQLCopyStatement;
import org.apache.shardingsphere.sql.parser.sql.dialect.statement.postgresql.dml.PostgreSQLDoStatement;

Expand Down Expand Up @@ -149,11 +147,6 @@ public ASTNode visitCopyWithTableBinary(final CopyWithTableBinaryContext ctx) {
return result;
}

@Override
public ASTNode visitCheckpoint(final CheckpointContext ctx) {
return new PostgreSQLCheckpointStatement();
}

@Override
public ASTNode visitReturningClause(final ReturningClauseContext ctx) {
return new ReturningSegment(ctx.start.getStartIndex(), ctx.stop.getStopIndex(), (ProjectionsSegment) visit(ctx.targetList()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import org.apache.shardingsphere.sql.parser.api.visitor.statement.type.TCLStatementVisitor;
import org.apache.shardingsphere.sql.parser.autogen.PostgreSQLStatementParser.AbortContext;
import org.apache.shardingsphere.sql.parser.autogen.PostgreSQLStatementParser.BeginTransactionContext;
import org.apache.shardingsphere.sql.parser.autogen.PostgreSQLStatementParser.CheckpointContext;
import org.apache.shardingsphere.sql.parser.autogen.PostgreSQLStatementParser.CommitContext;
import org.apache.shardingsphere.sql.parser.autogen.PostgreSQLStatementParser.CommitPreparedContext;
import org.apache.shardingsphere.sql.parser.autogen.PostgreSQLStatementParser.EndContext;
Expand All @@ -40,6 +41,7 @@
import org.apache.shardingsphere.sql.parser.sql.common.enums.TransactionAccessType;
import org.apache.shardingsphere.sql.parser.sql.common.enums.TransactionIsolationLevel;
import org.apache.shardingsphere.sql.parser.sql.common.segment.generic.table.SimpleTableSegment;
import org.apache.shardingsphere.sql.parser.sql.dialect.statement.postgresql.dml.PostgreSQLCheckpointStatement;
import org.apache.shardingsphere.sql.parser.sql.dialect.statement.postgresql.tcl.PostgreSQLBeginTransactionStatement;
import org.apache.shardingsphere.sql.parser.sql.dialect.statement.postgresql.tcl.PostgreSQLCommitPreparedStatement;
import org.apache.shardingsphere.sql.parser.sql.dialect.statement.postgresql.tcl.PostgreSQLCommitStatement;
Expand Down Expand Up @@ -193,4 +195,9 @@ private Collection<SimpleTableSegment> getLockTables(final List<RelationExprCont
public ASTNode visitPrepareTransaction(final PrepareTransactionContext ctx) {
return new PostgreSQLPrepareTransactionStatement();
}

@Override
public ASTNode visitCheckpoint(final CheckpointContext ctx) {
return new PostgreSQLCheckpointStatement();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,6 @@ public enum SQLVisitorRule {

HANDLER_STATEMENT("HandlerStatement", SQLStatementType.DML),

LOCKTABLE("LockTable", SQLStatementType.DML),

CREATE_TABLE("CreateTable", SQLStatementType.DDL),

CREATE_AGGREGATE("CreateAggregate", SQLStatementType.DDL),
Expand Down Expand Up @@ -645,14 +643,14 @@ public enum SQLVisitorRule {

FETCH("Fetch", SQLStatementType.DDL),

CHECKPOINT("Checkpoint", SQLStatementType.DML),

CLUSTER("Cluster", SQLStatementType.DDL),

CREATE_ACCESS_METHOD("CreateAccessMethod", SQLStatementType.DDL),

DO("DoStatement", SQLStatementType.DML),

CHECKPOINT("Checkpoint", SQLStatementType.TCL),

PREPARE_TRANSACTION("PrepareTransaction", SQLStatementType.TCL),

REASSIGN_OWNED("ReassignOwned", SQLStatementType.DCL),
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@
* limitations under the License.
*/

package org.apache.shardingsphere.sql.parser.sql.common.statement.dml;
package org.apache.shardingsphere.sql.parser.sql.common.statement.tcl;

import org.apache.shardingsphere.sql.parser.sql.common.statement.AbstractSQLStatement;

/**
* Checkpoint statement.
*/
public abstract class CheckpointStatement extends AbstractSQLStatement implements DMLStatement {
public abstract class CheckpointStatement extends AbstractSQLStatement implements TCLStatement {
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
* limitations under the License.
*/

package org.apache.shardingsphere.sql.parser.sql.dialect.statement.opengauss.dml;
package org.apache.shardingsphere.sql.parser.sql.dialect.statement.opengauss.tcl;

import org.apache.shardingsphere.sql.parser.sql.common.statement.dml.CheckpointStatement;
import org.apache.shardingsphere.sql.parser.sql.common.statement.tcl.CheckpointStatement;
import org.apache.shardingsphere.sql.parser.sql.dialect.statement.opengauss.OpenGaussStatement;

/**
Expand Down
Loading