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
e2dd408b
Commit
e2dd408b
authored
Feb 21, 2017
by
gwenn
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Go 1.8: Ping and BeginTx
To be continued
parent
eb1ee648
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
36 additions
and
1 deletion
+36
-1
.travis.yml
.travis.yml
+1
-1
driver.go
driver.go
+35
-0
No files found.
.travis.yml
View file @
e2dd408b
language
:
go
sudo
:
false
go
:
-
1.
7.4
-
1.
8
-
tip
addons
:
apt
:
...
...
driver.go
View file @
e2dd408b
...
...
@@ -5,9 +5,11 @@
package
sqlite
import
(
"context"
"database/sql"
"database/sql/driver"
"errors"
"fmt"
"io"
"log"
"os"
...
...
@@ -105,6 +107,14 @@ func Unwrap(db *sql.DB) *Conn {
return
nil
}
func
(
c
*
conn
)
Ping
(
ctx
context
.
Context
)
error
{
if
c
.
c
.
IsClosed
()
{
return
driver
.
ErrBadConn
}
_
,
err
:=
c
.
Exec
(
"PRAGMA schema_verion"
,
[]
driver
.
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
)
{
...
...
@@ -157,6 +167,31 @@ func (c *conn) Begin() (driver.Tx, error) {
return
c
,
nil
}
func
(
c
*
conn
)
BeginTx
(
ctx
context
.
Context
,
opts
driver
.
TxOptions
)
(
driver
.
Tx
,
error
)
{
if
c
.
c
.
IsClosed
()
{
return
nil
,
driver
.
ErrBadConn
}
if
!
c
.
c
.
GetAutocommit
()
{
return
nil
,
errors
.
New
(
"Nested transcations are not supported"
)
}
if
err
:=
c
.
c
.
SetQueryOnly
(
""
,
opts
.
ReadOnly
);
err
!=
nil
{
return
nil
,
err
}
switch
sql
.
IsolationLevel
(
opts
.
Isolation
)
{
case
sql
.
LevelDefault
,
sql
.
LevelSerializable
:
if
err
:=
c
.
c
.
FastExec
(
"PRAGMA read_uncommitted=0"
);
err
!=
nil
{
return
nil
,
err
}
case
sql
.
LevelReadUncommitted
:
if
err
:=
c
.
c
.
FastExec
(
"PRAGMA read_uncommitted=1"
);
err
!=
nil
{
return
nil
,
err
}
default
:
return
nil
,
fmt
.
Errorf
(
"Isolation level %d is not supported."
,
opts
.
Isolation
)
}
return
c
.
Begin
()
}
func
(
c
*
conn
)
Commit
()
error
{
return
c
.
c
.
Commit
()
}
...
...
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