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
96e70462
Commit
96e70462
authored
Mar 05, 2017
by
gwenn
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove old (go 1.7) code
parent
9f7bc846
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
54 deletions
+10
-54
.travis.yml
.travis.yml
+1
-1
driver.go
driver.go
+9
-53
No files found.
.travis.yml
View file @
96e70462
...
...
@@ -15,5 +15,5 @@ install:
before_script
:
-
go get github.com/bmizerany/assert
script
:
-
GODEBUG=cgocheck=2 go test -v -tags all github.com/gwenn/gosqlite
#
- GODEBUG=cgocheck=2 go test -v -tags all github.com/gwenn/gosqlite
-
GODEBUG=cgocheck=0 go test -v -tags all github.com/gwenn/gosqlite
driver.go
View file @
96e70462
...
...
@@ -15,7 +15,6 @@ import (
"os"
"reflect"
"time"
"unsafe"
)
func
init
()
{
...
...
@@ -112,53 +111,21 @@ func (c *conn) Ping(ctx context.Context) error {
if
c
.
c
.
IsClosed
()
{
return
driver
.
ErrBadConn
}
_
,
err
:=
c
.
Exec
(
"PRAGMA schema_verion"
,
[]
driver
.
Value
{})
_
,
err
:=
c
.
Exec
Context
(
ctx
,
"PRAGMA schema_verion"
,
[]
driver
.
Named
Value
{})
return
err
}
// PRAGMA schema_version may be used to detect when the database schema is altered
func
(
c
*
conn
)
Exec
(
query
string
,
args
[]
driver
.
Value
)
(
driver
.
Result
,
error
)
{
if
c
.
c
.
IsClosed
()
{
return
nil
,
driver
.
ErrBadConn
}
if
len
(
args
)
==
0
{
if
query
==
"unwrap"
{
return
nil
,
ConnError
{
c
:
c
.
c
}
}
if
err
:=
c
.
c
.
FastExec
(
query
);
err
!=
nil
{
return
nil
,
err
}
return
c
.
c
.
result
(),
nil
}
// https://code.google.com/p/go-wiki/wiki/cgo#Turning_C_arrays_into_Go_slices
var
iargs
[]
interface
{}
h
:=
(
*
reflect
.
SliceHeader
)(
unsafe
.
Pointer
(
&
iargs
))
h
.
Data
=
uintptr
(
unsafe
.
Pointer
(
&
args
[
0
]))
h
.
Len
=
len
(
args
)
h
.
Cap
=
cap
(
args
)
if
err
:=
c
.
c
.
Exec
(
query
,
iargs
...
);
err
!=
nil
{
return
nil
,
err
}
return
c
.
c
.
result
(),
nil
panic
(
"ExecContext was not called."
)
}
func
(
c
*
conn
)
Prepare
(
query
string
)
(
driver
.
Stmt
,
error
)
{
if
c
.
c
.
IsClosed
()
{
return
nil
,
driver
.
ErrBadConn
}
s
,
err
:=
c
.
c
.
Prepare
(
query
)
if
err
!=
nil
{
return
nil
,
err
}
return
&
stmt
{
s
:
s
},
nil
panic
(
"use PrepareContext"
)
}
func
(
c
*
conn
)
PrepareContext
(
ctx
context
.
Context
,
query
string
)
(
driver
.
Stmt
,
error
)
{
return
c
.
Prepare
(
query
)
}
func
(
c
*
conn
)
QueryContext
(
ctx
context
.
Context
,
query
string
,
args
[]
driver
.
NamedValue
)
(
driver
.
Rows
,
error
)
{
if
c
.
c
.
IsClosed
()
{
return
nil
,
driver
.
ErrBadConn
}
...
...
@@ -166,8 +133,7 @@ func (c *conn) QueryContext(ctx context.Context, query string, args []driver.Nam
if
err
!=
nil
{
return
nil
,
err
}
st
:=
stmt
{
s
:
s
}
return
st
.
QueryContext
(
ctx
,
args
)
return
&
stmt
{
s
:
s
},
nil
}
func
(
c
*
conn
)
ExecContext
(
ctx
context
.
Context
,
query
string
,
args
[]
driver
.
NamedValue
)
(
driver
.
Result
,
error
)
{
...
...
@@ -277,24 +243,11 @@ func (s *stmt) NumInput() int {
}
func
(
s
*
stmt
)
Exec
(
args
[]
driver
.
Value
)
(
driver
.
Result
,
error
)
{
if
err
:=
s
.
bind
(
args
);
err
!=
nil
{
return
nil
,
err
}
if
err
:=
s
.
s
.
exec
();
err
!=
nil
{
return
nil
,
err
}
return
s
.
s
.
c
.
result
(),
nil
panic
(
"Using ExecContext"
)
}
func
(
s
*
stmt
)
Query
(
args
[]
driver
.
Value
)
(
driver
.
Rows
,
error
)
{
if
s
.
rowsRef
{
return
nil
,
errors
.
New
(
"previously returned Rows still not closed"
)
}
if
err
:=
s
.
bind
(
args
);
err
!=
nil
{
return
nil
,
err
}
s
.
rowsRef
=
true
return
&
rowsImpl
{
s
,
nil
,
nil
},
nil
panic
(
"Use QueryContext"
)
}
func
(
s
*
stmt
)
ExecContext
(
ctx
context
.
Context
,
args
[]
driver
.
NamedValue
)
(
driver
.
Result
,
error
)
{
...
...
@@ -310,6 +263,9 @@ func (s *stmt) ExecContext(ctx context.Context, args []driver.NamedValue) (drive
}
func
(
s
*
stmt
)
QueryContext
(
ctx
context
.
Context
,
args
[]
driver
.
NamedValue
)
(
driver
.
Rows
,
error
)
{
if
s
.
rowsRef
{
return
nil
,
errors
.
New
(
"previously returned Rows still not closed"
)
}
if
err
:=
s
.
s
.
bindNamedValue
(
args
);
err
!=
nil
{
return
nil
,
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