🐛 fix(query-editor): 修复 Oracle 事务提交回滚失败

- 分离 Oracle 托管事务与单次查询执行上下文

- 避免查询结束后取消 BeginTx 上下文导致事务提前回滚

- 补充 sql.ErrTxDone 回归测试覆盖 Oracle 提交路径
This commit is contained in:
Syngnat
2026-06-11 20:38:50 +08:00
parent bd2bd49e6d
commit ca1c8559cf
3 changed files with 28 additions and 1 deletions

View File

@@ -2,6 +2,7 @@ package app
import (
"context"
"database/sql"
"errors"
"testing"
@@ -227,22 +228,30 @@ type fakeTransactionalDB struct {
func (f *fakeTransactionalDB) OpenTransactionExecer(ctx context.Context) (db.TransactionExecer, error) {
f.txSession = &fakeTransactionSession{
fakeBatchWriteSession: fakeBatchWriteSession{parent: &f.fakeBatchWriteDB},
beginCtx: ctx,
}
return f.txSession, nil
}
type fakeTransactionSession struct {
fakeBatchWriteSession
beginCtx context.Context
commitCalls int
rollbackCalls int
}
func (s *fakeTransactionSession) Commit() error {
if s.beginCtx != nil && s.beginCtx.Err() != nil {
return sql.ErrTxDone
}
s.commitCalls++
return nil
}
func (s *fakeTransactionSession) Rollback() error {
if s.beginCtx != nil && s.beginCtx.Err() != nil {
return sql.ErrTxDone
}
s.rollbackCalls++
return nil
}