Skip to content

Commit 8ef8dfe

Browse files
authored
Merge pull request #22 from hymkor/rollback
Fix: SQL Server did not end transaction after ROLLBACK TRANSACTION (no savepoint)
2 parents 50f0461 + 0762472 commit 8ef8dfe

File tree

3 files changed

+11
-2
lines changed

3 files changed

+11
-2
lines changed

loop.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,11 +164,18 @@ func (ss *session) Loop(ctx context.Context, commandIn commandIn) error {
164164
err = doSelect(ctx, ss, query, nil, commandIn)
165165
case "ROLLBACK":
166166
misc.Echo(ss.spool, query)
167-
arg, _ = misc.CutField(arg)
167+
var rest string
168+
arg, rest = misc.CutField(arg)
168169
if arg == "" {
169170
err = ss.rollback()
170-
} else if strings.EqualFold(arg, "TO") || strings.EqualFold(arg, "TRANSACTION") {
171+
} else if strings.EqualFold(arg, "TO") {
171172
err = doTCL(ctx, ss, query)
173+
} else if strings.EqualFold(arg, "TRANSACTION") {
174+
if strings.TrimSpace(rest) == "" {
175+
err = ss.rollback()
176+
} else {
177+
err = doTCL(ctx, ss, query)
178+
}
172179
} else {
173180
err = ErrInvalidRollback
174181
}

release_note_en.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
### Bug fixes
44

55
- Fix: Errors were not reported during execution of `SAVEPOINT` and `SAVE TRANSACTION`. (#19)
6+
- SQL Server: Fixed an issue where `ROLLBACK TRANSACTION` without a savepoint was not recognized as ending the transaction, causing the prompt to remain as `SQL*`. (#22)
67

78
### Specification Changes
89

release_note_ja.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
### 不具合修正
44

55
- `SAVEPOINT`, `SAVE TRANSACTION` の実行中にエラーが発生してもメッセージが表示されなかった問題を修正 (#19)
6+
- SQL Server: SAVEPOINT を指定しない `ROLLBACK TRANSACTION` でトランザクションは終了するのに、それを認識せず、プロンプトがトランザクション中を意味する `SQL*` のままになっていた問題を修正 (#22)
67

78
### 仕様変更
89

0 commit comments

Comments
 (0)