Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gosqlite
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
gosqlite
Commits
7a9d5708
Commit
7a9d5708
authored
Dec 31, 2017
by
gwenn
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rollback the transaction if an error occurs on Commit.
Caveat: it will not be possible to retry on SQLITE_BUSY.
parent
dd5964ff
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
1 deletion
+9
-1
sqlite.go
sqlite.go
+9
-1
No files found.
sqlite.go
View file @
7a9d5708
...
@@ -500,7 +500,15 @@ func (c *Conn) BeginTransaction(t TransactionType) error {
...
@@ -500,7 +500,15 @@ func (c *Conn) BeginTransaction(t TransactionType) error {
// Commit commits transaction.
// Commit commits transaction.
// It is strongly discouraged to defer Commit without checking the error returned.
// It is strongly discouraged to defer Commit without checking the error returned.
func
(
c
*
Conn
)
Commit
()
error
{
func
(
c
*
Conn
)
Commit
()
error
{
return
c
.
FastExec
(
"COMMIT"
)
// Although there are situations when it is possible to recover and continue a transaction,
// it is considered a best practice to always issue a ROLLBACK if an error is encountered.
// In situations when SQLite was already forced to roll back the transaction and has returned to autocommit mode,
// the ROLLBACK will do nothing but return an error that can be safely ignored.
err
:=
c
.
FastExec
(
"COMMIT"
)
if
err
!=
nil
&&
!
c
.
GetAutocommit
()
{
c
.
Rollback
()
}
return
err
}
}
// Rollback rollbacks transaction
// Rollback rollbacks transaction
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment