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
041796b7
Commit
041796b7
authored
Sep 11, 2011
by
gwenn
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use sqlite3_exec for transaction commands.
parent
f687a5d8
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
7 deletions
+17
-7
sqlite.go
sqlite.go
+17
-7
No files found.
sqlite.go
View file @
041796b7
...
...
@@ -293,7 +293,7 @@ func (c *Conn) GetAutocommit() bool {
type
TransactionType
int
const
(
DEFERRED
TransactionType
=
0
DEFERRED
TransactionType
=
0
IMMEDIATE
TransactionType
=
1
EXCLUSIVE
TransactionType
=
2
)
...
...
@@ -304,11 +304,11 @@ func (c *Conn) Begin() os.Error {
func
(
c
*
Conn
)
BeginTransaction
(
t
TransactionType
)
os
.
Error
{
if
t
==
DEFERRED
{
return
c
.
E
xec
(
"BEGIN"
)
}
else
if
t
==
IMMEDIATE
{
return
c
.
E
xec
(
"BEGIN IMMEDIATE"
)
return
c
.
e
xec
(
"BEGIN"
)
}
else
if
t
==
IMMEDIATE
{
return
c
.
e
xec
(
"BEGIN IMMEDIATE"
)
}
else
if
t
==
EXCLUSIVE
{
return
c
.
E
xec
(
"BEGIN EXCLUSIVE"
)
return
c
.
e
xec
(
"BEGIN EXCLUSIVE"
)
}
panic
(
fmt
.
Sprintf
(
"Unsupported transaction type: '%#v'"
,
t
))
return
nil
...
...
@@ -316,11 +316,21 @@ func (c *Conn) BeginTransaction(t TransactionType) os.Error {
func
(
c
*
Conn
)
Commit
()
os
.
Error
{
// TODO Check autocommit?
return
c
.
E
xec
(
"COMMIT"
)
return
c
.
e
xec
(
"COMMIT"
)
}
func
(
c
*
Conn
)
Rollback
()
os
.
Error
{
// TODO Check autocommit?
return
c
.
Exec
(
"ROLLBACK"
)
return
c
.
exec
(
"ROLLBACK"
)
}
func
(
c
*
Conn
)
exec
(
cmd
string
)
os
.
Error
{
cmdstr
:=
C
.
CString
(
cmd
)
defer
C
.
free
(
unsafe
.
Pointer
(
cmdstr
))
rv
:=
C
.
sqlite3_exec
(
c
.
db
,
cmdstr
,
nil
,
nil
,
nil
)
if
rv
!=
C
.
SQLITE_OK
{
return
c
.
error
(
rv
)
}
return
nil
}
// Prepared Statement (sqlite3_stmt)
...
...
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