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
2e131839
Commit
2e131839
authored
Mar 03, 2012
by
gwenn
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve Conn#exec and Conn#Close error/log message.
parent
7e10f97b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
5 deletions
+13
-5
driver.go
driver.go
+1
-0
sqlite.go
sqlite.go
+12
-5
No files found.
driver.go
View file @
2e131839
...
...
@@ -34,6 +34,7 @@ func (d *Driver) Open(name string) (driver.Conn, error) {
// PRAGMA schema_version may be used to detect when the database schema is altered
func
(
c
*
connImpl
)
Exec
(
query
string
,
args
[]
driver
.
Value
)
(
driver
.
Result
,
error
)
{
// http://code.google.com/p/go-wiki/wiki/InterfaceSlice
tmp
:=
make
([]
interface
{},
len
(
args
))
for
i
,
arg
:=
range
args
{
tmp
[
i
]
=
arg
...
...
sqlite.go
View file @
2e131839
...
...
@@ -440,9 +440,16 @@ func (c *Conn) Rollback() error {
}
func
(
c
*
Conn
)
exec
(
cmd
string
)
error
{
cmdstr
:=
C
.
CString
(
cmd
)
defer
C
.
free
(
unsafe
.
Pointer
(
cmdstr
))
return
c
.
error
(
C
.
sqlite3_exec
(
c
.
db
,
cmdstr
,
nil
,
nil
,
nil
))
s
,
err
:=
c
.
Prepare
(
cmd
)
if
err
!=
nil
{
return
err
}
defer
s
.
Finalize
()
rv
:=
C
.
sqlite3_step
(
s
.
stmt
)
if
Errno
(
rv
)
!=
Done
{
return
s
.
error
(
rv
)
}
return
nil
}
// Close a database connection and any dangling statements.
...
...
@@ -458,9 +465,9 @@ func (c *Conn) Close() error {
stmt
:=
C
.
sqlite3_next_stmt
(
c
.
db
,
nil
)
for
stmt
!=
nil
{
if
C
.
sqlite3_stmt_busy
(
stmt
)
!=
0
{
Log
(
C
.
SQLITE_MISUSE
,
"Dangling statement (not reset)"
)
Log
(
C
.
SQLITE_MISUSE
,
"Dangling statement (not reset)
:
\"
"
+
C
.
GoString
(
C
.
sqlite3_sql
(
stmt
))
+
"
\"
"
)
}
else
{
Log
(
C
.
SQLITE_MISUSE
,
"Dangling statement (not finalize)"
)
Log
(
C
.
SQLITE_MISUSE
,
"Dangling statement (not finalize)
:
\"
"
+
C
.
GoString
(
C
.
sqlite3_sql
(
stmt
))
+
"
\"
"
)
}
C
.
sqlite3_finalize
(
stmt
)
stmt
=
C
.
sqlite3_next_stmt
(
c
.
db
,
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