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
62d699a6
Commit
62d699a6
authored
Oct 15, 2011
by
gwenn
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix dangling statements.
parent
fa0708e4
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
15 additions
and
2 deletions
+15
-2
README
README
+1
-0
meta.go
meta.go
+3
-0
sqlite.go
sqlite.go
+9
-1
sqlite_test.go
sqlite_test.go
+2
-1
No files found.
README
View file @
62d699a6
...
...
@@ -5,6 +5,7 @@ Yet another SQLite binding based on:
Open supports flags.
Conn#Exec handles multiple statements (separated by semicolons) properly.
Conn#Prepare can optionnaly #Bind as well.
Conn#Close ensures that all dangling statements are finalized.
Stmt#Exec is renamed in Stmt#Bind and a new Stmt#Exec method is introduced to #Bind and #Step.
Stmt#Bind uses native sqlite3_bind_x methods and failed if unsupported type.
Stmt#Next returns a (bool, os.Error) couple like Reader#Read.
...
...
meta.go
View file @
62d699a6
...
...
@@ -28,6 +28,7 @@ func (c *Conn) Tables() ([]string, os.Error) {
if
err
!=
nil
{
return
nil
,
err
}
defer
s
.
Finalize
()
var
tables
[]
string
=
make
([]
string
,
0
,
20
)
var
ok
bool
var
name
string
...
...
@@ -57,6 +58,7 @@ func (c *Conn) Columns(table string) ([]Column, os.Error) {
if
err
!=
nil
{
return
nil
,
err
}
defer
s
.
Finalize
()
var
columns
[]
Column
=
make
([]
Column
,
0
,
20
)
var
ok
bool
for
ok
,
err
=
s
.
Next
();
ok
;
ok
,
err
=
s
.
Next
()
{
...
...
@@ -86,6 +88,7 @@ func (c *Conn) ForeignKeys(table string) (map[int]*ForeignKey, os.Error) {
if
err
!=
nil
{
return
nil
,
err
}
defer
s
.
Finalize
()
var
fks
=
make
(
map
[
int
]
*
ForeignKey
)
var
ok
bool
var
id
,
seq
int
...
...
sqlite.go
View file @
62d699a6
...
...
@@ -263,6 +263,7 @@ func (c *Conn) Exists(query string, args ...interface{}) (bool, os.Error) {
if
err
!=
nil
{
return
false
,
err
}
defer
s
.
Finalize
()
return
s
.
Next
()
}
...
...
@@ -702,7 +703,14 @@ func (c *Conn) Close() os.Error {
if
c
==
nil
{
return
os
.
NewError
(
"nil sqlite database"
)
}
// TODO sqlite3_next_stmt & dangling statements?
// Dangling statements
stmt
:=
C
.
sqlite3_next_stmt
(
c
.
db
,
nil
)
for
stmt
!=
nil
{
//Log(1, "Dangling statement")
C
.
sqlite3_finalize
(
stmt
)
stmt
=
C
.
sqlite3_next_stmt
(
c
.
db
,
stmt
)
}
rv
:=
C
.
sqlite3_close
(
c
.
db
)
if
rv
!=
C
.
SQLITE_OK
{
return
c
.
error
(
rv
)
...
...
sqlite_test.go
View file @
62d699a6
...
...
@@ -200,7 +200,7 @@ func TestInsertWithStatement(t *testing.T) {
t
.
Errorf
(
"insert error: %d <> 1"
,
c
)
}
}
s
.
Finalize
()
if
err
:=
db
.
Commit
();
err
!=
nil
{
t
.
Fatalf
(
"Error: %s"
,
err
)
}
...
...
@@ -220,6 +220,7 @@ func TestInsertWithStatement(t *testing.T) {
}
rs
,
_
:=
db
.
Prepare
(
"SELECT float_num, int_num, a_string FROM test where a_string like ? ORDER BY int_num LIMIT 2"
,
"hel%"
)
defer
rs
.
Finalize
()
columnCount
:=
rs
.
ColumnCount
()
if
columnCount
!=
3
{
t
.
Errorf
(
"column count error: %d <> 3"
,
columnCount
)
...
...
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