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
cc56fa03
Commit
cc56fa03
authored
Mar 04, 2012
by
gwenn
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Activate Stmt cache by default.
parent
e2ff8991
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
26 additions
and
14 deletions
+26
-14
README
README
+14
-8
cache.go
cache.go
+1
-1
driver.go
driver.go
+1
-1
sqlite.go
sqlite.go
+10
-4
No files found.
README
View file @
cc56fa03
...
...
@@ -6,6 +6,7 @@ This binding implements the "database/sql/driver" interface.
Open supports flags.
Conn#Exec handles multiple statements (separated by semicolons) properly.
Conn#Prepare can optionnaly #Bind as well.
Conn#CacheOrPrepare can reused already prepared Stmt.
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.
...
...
@@ -82,10 +83,15 @@ Conn#CreateAggregateFunction
$ go test -test.bench '.*'
BenchmarkValuesScan 500000 4658 ns/op
BenchmarkScan
500000 4
324 ns/op
BenchmarkScan
500000
324 ns/op
BenchmarkNamedScan 200000 9221 ns/op
BenchmarkInsert 500000 6088 ns/op
BenchmarkNamedInsert 500000 6726 ns/op
BenchmarkDisabledCache 100000 19235 ns/op
BenchmarkEnabledCache 1000000 1133 ns/op
BenchmarkLike 1000000 2508 ns/op
BenchmarkHalf 500000 4811 ns/op
BenchmarkRegexp 500000 6170 ns/op
\ No newline at end of file
cache.go
View file @
cc56fa03
...
...
@@ -11,7 +11,7 @@ import (
)
const
(
defaultCacheSize
=
0
defaultCacheSize
=
1
0
)
// Like http://www.sqlite.org/tclsqlite.html#cache
...
...
driver.go
View file @
cc56fa03
...
...
@@ -56,7 +56,7 @@ func (c *connImpl) RowsAffected() (int64, error) {
}
func
(
c
*
connImpl
)
Prepare
(
query
string
)
(
driver
.
Stmt
,
error
)
{
s
,
err
:=
c
.
c
.
Prepare
(
query
)
s
,
err
:=
c
.
c
.
CacheOr
Prepare
(
query
)
if
err
!=
nil
{
return
nil
,
err
}
...
...
sqlite.go
View file @
cc56fa03
...
...
@@ -345,22 +345,28 @@ func (c *Conn) Exec(cmd string, args ...interface{}) error {
// Return true if the specified query returns at least one row.
func
(
c
*
Conn
)
Exists
(
query
string
,
args
...
interface
{})
(
bool
,
error
)
{
s
,
err
:=
c
.
Prepare
(
query
,
args
...
)
s
,
err
:=
c
.
CacheOr
Prepare
(
query
,
args
...
)
if
err
!=
nil
{
return
false
,
err
}
defer
s
.
finalize
()
defer
func
()
{
s
.
Reset
()
s
.
Finalize
()
}()
return
s
.
Next
()
}
// Use it with SELECT that returns only one row with only one column.
// Returns io.EOF when there is no row.
func
(
c
*
Conn
)
OneValue
(
query
string
,
value
interface
{},
args
...
interface
{})
error
{
s
,
err
:=
c
.
Prepare
(
query
,
args
...
)
s
,
err
:=
c
.
CacheOr
Prepare
(
query
,
args
...
)
if
err
!=
nil
{
return
err
}
defer
s
.
finalize
()
defer
func
()
{
s
.
Reset
()
s
.
Finalize
()
}()
b
,
err
:=
s
.
Next
()
if
err
!=
nil
{
return
err
...
...
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