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
88bba055
Commit
88bba055
authored
Jul 06, 2014
by
gwenn
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Go lint and vet.
parent
60ba4c36
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
8 additions
and
9 deletions
+8
-9
intarray_test.go
intarray_test.go
+5
-5
sqlite.go
sqlite.go
+2
-3
util.go
util.go
+1
-1
No files found.
intarray_test.go
View file @
88bba055
...
...
@@ -78,7 +78,7 @@ func TestIntArrayModule(t *testing.T) {
checkNoError
(
t
,
p3
.
Drop
(),
"%s"
)
}
const
I
NTARRAY_SIZE
=
100
const
I
ntArraySize
=
100
func
BenchmarkNoIntArray
(
b
*
testing
.
B
)
{
b
.
StopTimer
()
...
...
@@ -87,14 +87,14 @@ func BenchmarkNoIntArray(b *testing.B) {
defer
db
.
Close
()
panicOnError
(
b
,
db
.
Exec
(
"CREATE TABLE rand (r INT)"
))
values
:=
rand
.
Perm
(
I
NTARRAY_SIZE
)
values
:=
rand
.
Perm
(
I
ntArraySize
)
for
_
,
v
:=
range
values
{
panicOnError
(
b
,
db
.
Exec
(
"INSERT INTO rand (r) VALUES (?)"
,
v
))
}
b
.
StartTimer
()
for
i
:=
0
;
i
<
b
.
N
;
i
++
{
l
:=
rand
.
Intn
(
I
NTARRAY_SIZE
-
1
)
+
1
// at least one value
l
:=
rand
.
Intn
(
I
ntArraySize
-
1
)
+
1
// at least one value
sql
:=
fmt
.
Sprintf
(
"SELECT * FROM rand WHERE r IN (?%s)"
,
strings
.
Repeat
(
", ?"
,
l
-
1
))
s
,
err
:=
db
.
Prepare
(
sql
)
panicOnError
(
b
,
err
)
...
...
@@ -122,7 +122,7 @@ func BenchmarkIntArray(b *testing.B) {
defer
db
.
Close
()
panicOnError
(
b
,
db
.
Exec
(
"CREATE TABLE rand (r INT)"
))
perms
:=
rand
.
Perm
(
I
NTARRAY_SIZE
)
perms
:=
rand
.
Perm
(
I
ntArraySize
)
values
:=
make
([]
int64
,
len
(
perms
))
for
i
,
v
:=
range
perms
{
panicOnError
(
b
,
db
.
Exec
(
"INSERT INTO rand (r) VALUES (?)"
,
v
))
...
...
@@ -139,7 +139,7 @@ func BenchmarkIntArray(b *testing.B) {
defer
s
.
Finalize
()
for
i
:=
0
;
i
<
b
.
N
;
i
++
{
l
:=
rand
.
Intn
(
I
NTARRAY_SIZE
-
1
)
+
1
// at least one value
l
:=
rand
.
Intn
(
I
ntArraySize
-
1
)
+
1
// at least one value
p
.
Bind
(
values
[
0
:
l
])
nr
:=
0
err
=
s
.
Select
(
func
(
s
*
Stmt
)
error
{
...
...
sqlite.go
View file @
88bba055
...
...
@@ -359,11 +359,11 @@ func (c *Conn) Select(query string, rowCallbackHandler func(s *Stmt) error, args
return
s
.
Select
(
rowCallbackHandler
,
args
...
)
}
// SelectByI
d
helps executing SELECT statement that is expected to return only one row.
// SelectByI
D
helps executing SELECT statement that is expected to return only one row.
// Args are for scanning (not binding).
// Returns false if there is no matching row.
// No check is done to ensure that no more than one row is returned by the statement.
func
(
c
*
Conn
)
SelectByI
d
(
query
string
,
id
interface
{},
args
...
interface
{})
(
found
bool
,
err
error
)
{
func
(
c
*
Conn
)
SelectByI
D
(
query
string
,
id
interface
{},
args
...
interface
{})
(
found
bool
,
err
error
)
{
s
,
err
:=
c
.
Prepare
(
query
,
id
)
if
err
!=
nil
{
return
false
,
err
...
...
@@ -470,7 +470,6 @@ func (c *Conn) BeginTransaction(t TransactionType) error {
return
c
.
FastExec
(
"BEGIN EXCLUSIVE"
)
}
panic
(
fmt
.
Sprintf
(
"Unsupported transaction type: '%#v'"
,
t
))
return
nil
// Go 1.1 unreachable code
}
// Commit commits transaction
...
...
util.go
View file @
88bba055
...
...
@@ -45,7 +45,7 @@ func btocint(b bool) C.int {
return
0
}
func
cstring
(
s
string
)
(
*
C
.
char
,
C
.
int
)
{
cs
:=
*
(
*
reflect
.
StringHeader
)(
unsafe
.
Pointer
(
&
s
))
cs
:=
(
*
reflect
.
StringHeader
)(
unsafe
.
Pointer
(
&
s
))
return
(
*
C
.
char
)(
unsafe
.
Pointer
(
cs
.
Data
)),
C
.
int
(
cs
.
Len
)
}
...
...
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