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
bf209594
Commit
bf209594
authored
Jan 13, 2014
by
gwenn
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix some error messages.
parent
fa8e3f86
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
26 additions
and
13 deletions
+26
-13
blob.go
blob.go
+4
-4
driver.go
driver.go
+19
-6
pragma.go
pragma.go
+1
-1
sqlite.go
sqlite.go
+1
-1
stmt.go
stmt.go
+1
-1
No files found.
blob.go
View file @
bf209594
...
...
@@ -127,21 +127,21 @@ func (r *BlobReader) Seek(offset int64, whence int) (int64, error) {
switch
whence
{
case
0
:
// SEEK_SET
if
offset
<
0
||
offset
>
int64
(
size
)
{
return
0
,
r
.
c
.
specificError
(
"
I
nvalid offset: %d"
,
offset
)
return
0
,
r
.
c
.
specificError
(
"
i
nvalid offset: %d"
,
offset
)
}
r
.
offset
=
int32
(
offset
)
case
1
:
// SEEK_CUR
if
(
int64
(
r
.
offset
)
+
offset
)
<
0
||
(
int64
(
r
.
offset
)
+
offset
)
>
int64
(
size
)
{
return
0
,
r
.
c
.
specificError
(
"
I
nvalid offset: %d"
,
offset
)
return
0
,
r
.
c
.
specificError
(
"
i
nvalid offset: %d"
,
offset
)
}
r
.
offset
+=
int32
(
offset
)
case
2
:
// SEEK_END
if
(
int64
(
size
)
+
offset
)
<
0
||
offset
>
0
{
return
0
,
r
.
c
.
specificError
(
"
I
nvalid offset: %d"
,
offset
)
return
0
,
r
.
c
.
specificError
(
"
i
nvalid offset: %d"
,
offset
)
}
r
.
offset
=
size
+
int32
(
offset
)
default
:
return
0
,
r
.
c
.
specificError
(
"
B
ad seekMode: %d"
,
whence
)
return
0
,
r
.
c
.
specificError
(
"
b
ad seekMode: %d"
,
whence
)
}
return
int64
(
r
.
offset
),
nil
}
...
...
driver.go
View file @
bf209594
...
...
@@ -58,14 +58,21 @@ func (d *impl) Open(name string) (driver.Conn, error) {
// 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
err
:=
c
.
c
.
FastExec
(
query
);
err
!=
nil
{
return
nil
,
err
}
return
c
,
nil
}
// https://code.google.com/p/go-wiki/wiki/cgo#Turning_C_arrays_into_Go_slices
var
iargs
[]
interface
{}
if
len
(
args
)
>
0
{
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
}
...
...
@@ -83,6 +90,9 @@ func (c *conn) RowsAffected() (int64, error) {
}
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
...
...
@@ -95,6 +105,9 @@ func (c *conn) Close() error {
}
func
(
c
*
conn
)
Begin
()
(
driver
.
Tx
,
error
)
{
if
c
.
c
.
IsClosed
()
{
return
nil
,
driver
.
ErrBadConn
}
if
err
:=
c
.
c
.
Begin
();
err
!=
nil
{
return
nil
,
err
}
...
...
pragma.go
View file @
bf209594
...
...
@@ -32,7 +32,7 @@ func (c *Conn) IntegrityCheck(dbName string, max int, quick bool) error {
return
err
}
if
msg
!=
"ok"
{
return
c
.
specificError
(
"
I
ntegrity check failed on %q (%s)"
,
dbName
,
msg
)
return
c
.
specificError
(
"
i
ntegrity check failed on %q (%s)"
,
dbName
,
msg
)
}
return
nil
}
...
...
sqlite.go
View file @
bf209594
...
...
@@ -64,7 +64,7 @@ type Errno int
func
(
e
Errno
)
Error
()
string
{
var
s
string
if
e
==
ErrSpecific
{
s
=
"
W
rapper specific error"
s
=
"
w
rapper specific error"
}
else
{
s
=
C
.
GoString
(
C
.
sqlite3_errstr
(
C
.
int
(
e
)))
// thread safe
}
...
...
stmt.go
View file @
bf209594
...
...
@@ -159,7 +159,7 @@ func (s *Stmt) exec() error {
err
:=
Errno
(
rv
)
if
err
!=
Done
{
if
err
==
Row
{
return
s
.
specificError
(
"
Don't use exec with anything that returns data such as SELECT"
)
return
s
.
specificError
(
"
don't use exec with anything that returns data such as %q"
,
s
.
SQL
()
)
}
return
s
.
error
(
rv
,
"Stmt.exec"
)
}
...
...
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