MCPcopy Index your code
hub / github.com/bytebase/bytebase / executeInAutoCommitMode

Method executeInAutoCommitMode

backend/plugin/db/oracle/oracle.go:204–226  ·  view source on GitHub ↗

executeInAutoCommitMode executes statements sequentially in auto-commit mode

(ctx context.Context, conn *sql.Conn, commands []base.Statement, opts db.ExecuteOptions)

Source from the content-addressed store, hash-verified

202
203// executeInAutoCommitMode executes statements sequentially in auto-commit mode
204func (*Driver) executeInAutoCommitMode(ctx context.Context, conn *sql.Conn, commands []base.Statement, opts db.ExecuteOptions) (int64, error) {
205 totalRowsAffected := int64(0)
206 for _, command := range commands {
207 opts.LogCommandExecute(command.Range, command.Text)
208
209 sqlResult, err := conn.ExecContext(ctx, command.Text)
210 if err != nil {
211 opts.LogCommandResponse(0, nil, err.Error())
212 // In auto-commit mode, we stop at the first error
213 // The database is left in a partially migrated state
214 return totalRowsAffected, err
215 }
216 rowsAffected, err := sqlResult.RowsAffected()
217 if err != nil {
218 // Since we cannot differentiate DDL and DML yet, we have to ignore the error.
219 slog.Debug("rowsAffected returns error", log.BBError(err))
220 rowsAffected = 0
221 }
222 opts.LogCommandResponse(rowsAffected, []int64{rowsAffected}, "")
223 totalRowsAffected += rowsAffected
224 }
225 return totalRowsAffected, nil
226}
227
228// QueryConn queries a SQL statement in a given connection.
229func (d *Driver) QueryConn(ctx context.Context, conn *sql.Conn, statement string, queryContext db.QueryContext) ([]*v1pb.QueryResult, error) {

Callers 1

ExecuteMethod · 0.95

Implementers 15

MockDriverbackend/plugin/advisor/utils_for_tests
Driverbackend/plugin/db/bigquery/bigquery.go
Driverbackend/plugin/db/mongodb/mongodb.go
Driverbackend/plugin/db/trino/trino.go
Driverbackend/plugin/db/redshift/redshift.go
Driverbackend/plugin/db/oracle/oracle.go
Driverbackend/plugin/db/dynamodb/dynamodb.go
Driverbackend/plugin/db/cosmosdb/cosmosdb.go
Driverbackend/plugin/db/spanner/spanner.go
Driverbackend/plugin/db/mssql/mssql.go
Driverbackend/plugin/db/mysql/mysql.go
Driverbackend/plugin/db/pg/pg.go

Calls 5

BBErrorFunction · 0.92
LogCommandExecuteMethod · 0.80
LogCommandResponseMethod · 0.80
DebugMethod · 0.80
ErrorMethod · 0.45

Tested by

no test coverage detected