Skip to content

Commit 7fa1c5e

Browse files
committed
split commit and rollback DDLs
1 parent c83b192 commit 7fa1c5e

3 files changed

Lines changed: 6 additions & 3 deletions

File tree

flow/connectors/mysql/cdc.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -628,7 +628,7 @@ func (c *MySqlConnector) PullRecords(
628628
}
629629
case ddlKindRenameTable:
630630
c.processRenameTableQuery(ctx, otelManager, req, renameStmt, string(ev.Schema))
631-
case ddlKindCommit:
631+
case ddlKindCommit, ddlKindRollback:
632632
// Non-transactional engines (e.g. MyISAM) end a binlog group with a COMMIT/ROLLBACK
633633
advanceCheckpoint(ev.GSet, event.Header.LogPos)
634634
inTx = false

flow/connectors/mysql/query_parser.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,7 @@ const (
223223
ddlKindAlterTable
224224
ddlKindRenameTable
225225
ddlKindCommit
226+
ddlKindRollback
226227
)
227228

228229
// classifyParsedStatement maps a successfully parsed statement to the handler that
@@ -236,8 +237,10 @@ func classifyParsedStatement(stmt ast.StmtNode) (ddlKind, *ast.AlterTableStmt, *
236237
return ddlKindAlterTable, s, nil
237238
case *ast.RenameTableStmt:
238239
return ddlKindRenameTable, nil, s
239-
case *ast.CommitStmt, *ast.RollbackStmt:
240+
case *ast.CommitStmt:
240241
return ddlKindCommit, nil, nil
242+
case *ast.RollbackStmt:
243+
return ddlKindRollback, nil, nil
241244
default:
242245
return ddlKindIgnored, nil, nil
243246
}

flow/connectors/mysql/query_parser_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ func TestClassifyParsedStatementTxControl(t *testing.T) {
194194
want ddlKind
195195
}{
196196
{name: "commit", query: "COMMIT", want: ddlKindCommit},
197-
{name: "rollback", query: "ROLLBACK", want: ddlKindCommit},
197+
{name: "rollback", query: "ROLLBACK", want: ddlKindRollback},
198198
{name: "begin", query: "BEGIN", want: ddlKindIgnored},
199199
{name: "alter table add column", query: "ALTER TABLE t ADD COLUMN c INT", want: ddlKindAlterTable},
200200
{name: "rename table", query: "RENAME TABLE a TO b", want: ddlKindRenameTable},

0 commit comments

Comments
 (0)