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
Show 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:
...
@@ -15,5 +15,5 @@ install:
before_script
:
before_script
:
-
go get github.com/bmizerany/assert
-
go get github.com/bmizerany/assert
script
:
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
-
GODEBUG=cgocheck=0 go test -v -tags all github.com/gwenn/gosqlite
driver.go
View file @
96e70462
...
@@ -15,7 +15,6 @@ import (
...
@@ -15,7 +15,6 @@ import (
"os"
"os"
"reflect"
"reflect"
"time"
"time"
"unsafe"
)
)
func
init
()
{
func
init
()
{
...
@@ -112,53 +111,21 @@ func (c *conn) Ping(ctx context.Context) error {
...
@@ -112,53 +111,21 @@ func (c *conn) Ping(ctx context.Context) error {
if
c
.
c
.
IsClosed
()
{
if
c
.
c
.
IsClosed
()
{
return
driver
.
ErrBadConn
return
driver
.
ErrBadConn
}
}
_
,
err
:=
c
.
Exec
(
"PRAGMA schema_verion"
,
[]
driver
.
Value
{})
_
,
err
:=
c
.
Exec
Context
(
ctx
,
"PRAGMA schema_verion"
,
[]
driver
.
Named
Value
{})
return
err
return
err
}
}
// PRAGMA schema_version may be used to detect when the database schema is altered
// 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
)
{
func
(
c
*
conn
)
Exec
(
query
string
,
args
[]
driver
.
Value
)
(
driver
.
Result
,
error
)
{
if
c
.
c
.
IsClosed
()
{
panic
(
"ExecContext was not called."
)
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
}
}
func
(
c
*
conn
)
Prepare
(
query
string
)
(
driver
.
Stmt
,
error
)
{
func
(
c
*
conn
)
Prepare
(
query
string
)
(
driver
.
Stmt
,
error
)
{
if
c
.
c
.
IsClosed
()
{
panic
(
"use PrepareContext"
)
return
nil
,
driver
.
ErrBadConn
}
s
,
err
:=
c
.
c
.
Prepare
(
query
)
if
err
!=
nil
{
return
nil
,
err
}
return
&
stmt
{
s
:
s
},
nil
}
}
func
(
c
*
conn
)
PrepareContext
(
ctx
context
.
Context
,
query
string
)
(
driver
.
Stmt
,
error
)
{
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
()
{
if
c
.
c
.
IsClosed
()
{
return
nil
,
driver
.
ErrBadConn
return
nil
,
driver
.
ErrBadConn
}
}
...
@@ -166,8 +133,7 @@ func (c *conn) QueryContext(ctx context.Context, query string, args []driver.Nam
...
@@ -166,8 +133,7 @@ func (c *conn) QueryContext(ctx context.Context, query string, args []driver.Nam
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
st
:=
stmt
{
s
:
s
}
return
&
stmt
{
s
:
s
},
nil
return
st
.
QueryContext
(
ctx
,
args
)
}
}
func
(
c
*
conn
)
ExecContext
(
ctx
context
.
Context
,
query
string
,
args
[]
driver
.
NamedValue
)
(
driver
.
Result
,
error
)
{
func
(
c
*
conn
)
ExecContext
(
ctx
context
.
Context
,
query
string
,
args
[]
driver
.
NamedValue
)
(
driver
.
Result
,
error
)
{
...
@@ -277,24 +243,11 @@ func (s *stmt) NumInput() int {
...
@@ -277,24 +243,11 @@ func (s *stmt) NumInput() int {
}
}
func
(
s
*
stmt
)
Exec
(
args
[]
driver
.
Value
)
(
driver
.
Result
,
error
)
{
func
(
s
*
stmt
)
Exec
(
args
[]
driver
.
Value
)
(
driver
.
Result
,
error
)
{
if
err
:=
s
.
bind
(
args
);
err
!=
nil
{
panic
(
"Using ExecContext"
)
return
nil
,
err
}
if
err
:=
s
.
s
.
exec
();
err
!=
nil
{
return
nil
,
err
}
return
s
.
s
.
c
.
result
(),
nil
}
}
func
(
s
*
stmt
)
Query
(
args
[]
driver
.
Value
)
(
driver
.
Rows
,
error
)
{
func
(
s
*
stmt
)
Query
(
args
[]
driver
.
Value
)
(
driver
.
Rows
,
error
)
{
if
s
.
rowsRef
{
panic
(
"Use QueryContext"
)
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
}
}
func
(
s
*
stmt
)
ExecContext
(
ctx
context
.
Context
,
args
[]
driver
.
NamedValue
)
(
driver
.
Result
,
error
)
{
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
...
@@ -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
)
{
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
{
if
err
:=
s
.
s
.
bindNamedValue
(
args
);
err
!=
nil
{
return
nil
,
err
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