Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

chore: oracle execute details (#10134)

Danny Xueefef1df512e
diff --git a/backend/plugin/db/dm/dm.go b/backend/plugin/db/dm/dm.go
index d7d5830e66..6c35791876 100644
--- a/backend/plugin/db/dm/dm.go
+++ b/backend/plugin/db/dm/dm.go
@@ -111,8 +111,26 @@ func (driver *Driver) Execute(ctx context.Context, statement string, opts db.Exe
}
defer tx.Rollback()
+ totalCommands := len(singleSQLs)
totalRowsAffected := int64(0)
- for _, singleSQL := range singleSQLs {
+ for i, singleSQL := range singleSQLs {
+ // Start the current chunk.
+ // Set the progress information for the current chunk.
+ if opts.UpdateExecutionStatus != nil {
+ opts.UpdateExecutionStatus(&v1pb.TaskRun_ExecutionDetail{
+ CommandsTotal: int32(totalCommands),
+ CommandsCompleted: int32(i),
+ CommandStartPosition: &v1pb.TaskRun_ExecutionDetail_Position{
+ Line: int32(singleSQL.FirstStatementLine),
+ Column: int32(singleSQL.FirstStatementColumn),
+ },
+ CommandEndPosition: &v1pb.TaskRun_ExecutionDetail_Position{
+ Line: int32(singleSQL.LastLine),
+ Column: int32(singleSQL.LastColumn),
+ },
+ })
+ }
+
sqlResult, err := tx.ExecContext(ctx, singleSQL.Text)
if err != nil {
return 0, err
@@ -121,9 +139,8 @@ func (driver *Driver) Execute(ctx context.Context, statement string, opts db.Exe
if err != nil {
// Since we cannot differentiate DDL and DML yet, we have to ignore the error.
slog.Debug("rowsAffected returns error", log.BBError(err))
- } else {
- totalRowsAffected += rowsAffected
}
+ totalRowsAffected += rowsAffected
}
if opts.EndTransactionFunc != nil {
diff --git a/backend/plugin/db/obo/obo.go b/backend/plugin/db/obo/obo.go
index 1129a70fca..46755518c4 100644
--- a/backend/plugin/db/obo/obo.go
+++ b/backend/plugin/db/obo/obo.go
@@ -105,8 +105,26 @@ func (driver *Driver) Execute(ctx context.Context, statement string, opts db.Exe
}
defer tx.Rollback()
+ totalCommands := len(singleSQLs)
totalRowsAffected := int64(0)
- for _, singleSQL := range singleSQLs {
+ for i, singleSQL := range singleSQLs {
+ // Start the current chunk.
+ // Set the progress information for the current chunk.
+ if opts.UpdateExecutionStatus != nil {
+ opts.UpdateExecutionStatus(&v1pb.TaskRun_ExecutionDetail{
+ CommandsTotal: int32(totalCommands),
+ CommandsCompleted: int32(i),
+ CommandStartPosition: &v1pb.TaskRun_ExecutionDetail_Position{
+ Line: int32(singleSQL.FirstStatementLine),
+ Column: int32(singleSQL.FirstStatementColumn),
+ },
+ CommandEndPosition: &v1pb.TaskRun_ExecutionDetail_Position{
+ Line: int32(singleSQL.LastLine),
+ Column: int32(singleSQL.LastColumn),
+ },
+ })
+ }
+
sqlResult, err := tx.ExecContext(ctx, singleSQL.Text)
if err != nil {
return 0, err
@@ -115,9 +133,8 @@ func (driver *Driver) Execute(ctx context.Context, statement string, opts db.Exe
if err != nil {
// Since we cannot differentiate DDL and DML yet, we have to ignore the error.
slog.Debug("rowsAffected returns error", log.BBError(err))
- } else {
- totalRowsAffected += rowsAffected
}
+ totalRowsAffected += rowsAffected
}
if opts.EndTransactionFunc != nil {
diff --git a/backend/plugin/db/oracle/oracle.go b/backend/plugin/db/oracle/oracle.go
index 1597db09ff..bbfdfd8953 100644
--- a/backend/plugin/db/oracle/oracle.go
+++ b/backend/plugin/db/oracle/oracle.go
@@ -126,8 +126,26 @@ func (driver *Driver) Execute(ctx context.Context, statement string, opts db.Exe
}
defer tx.Rollback()
+ totalCommands := len(singleSQLs)
totalRowsAffected := int64(0)
- for _, singleSQL := range singleSQLs {
+ for i, singleSQL := range singleSQLs {
+ // Start the current chunk.
+ // Set the progress information for the current chunk.
+ if opts.UpdateExecutionStatus != nil {
+ opts.UpdateExecutionStatus(&v1pb.TaskRun_ExecutionDetail{
+ CommandsTotal: int32(totalCommands),
+ CommandsCompleted: int32(i),
+ CommandStartPosition: &v1pb.TaskRun_ExecutionDetail_Position{
+ Line: int32(singleSQL.FirstStatementLine),
+ Column: int32(singleSQL.FirstStatementColumn),
+ },
+ CommandEndPosition: &v1pb.TaskRun_ExecutionDetail_Position{
+ Line: int32(singleSQL.LastLine),
+ Column: int32(singleSQL.LastColumn),
+ },
+ })
+ }
+
sqlResult, err := tx.ExecContext(ctx, singleSQL.Text)
if err != nil {
return 0, err
@@ -136,9 +154,8 @@ func (driver *Driver) Execute(ctx context.Context, statement string, opts db.Exe
if err != nil {
// Since we cannot differentiate DDL and DML yet, we have to ignore the error.
slog.Debug("rowsAffected returns error", log.BBError(err))
- } else {
- totalRowsAffected += rowsAffected
}
+ totalRowsAffected += rowsAffected
}
if opts.EndTransactionFunc != nil {
diff --git a/backend/runner/taskrun/executor.go b/backend/runner/taskrun/executor.go
index 15220148c9..e561562ec5 100644
--- a/backend/runner/taskrun/executor.go
+++ b/backend/runner/taskrun/executor.go
@@ -232,7 +232,7 @@ func executeMigration(
switch task.Type {
case api.TaskDatabaseSchemaUpdate, api.TaskDatabaseDataUpdate:
switch instance.Engine {
- case storepb.Engine_MYSQL, storepb.Engine_OCEANBASE, storepb.Engine_MARIADB, storepb.Engine_STARROCKS, storepb.Engine_POSTGRES, storepb.Engine_REDSHIFT, storepb.Engine_RISINGWAVE:
+ case storepb.Engine_MYSQL, storepb.Engine_OCEANBASE, storepb.Engine_MARIADB, storepb.Engine_STARROCKS, storepb.Engine_POSTGRES, storepb.Engine_REDSHIFT, storepb.Engine_RISINGWAVE, storepb.Engine_ORACLE, storepb.Engine_DM, storepb.Engine_OCEANBASE_ORACLE:
opts.ChunkedSubmission = true
opts.UpdateExecutionStatus = func(detail *v1pb.TaskRun_ExecutionDetail) {
stateCfg.TaskRunExecutionStatuses.Store(taskRunUID,