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
3107a54d
Commit
3107a54d
authored
Oct 31, 2014
by
gwenn
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve call to sqlite3_bind_text.
parent
740da6cc
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
7 deletions
+6
-7
stmt.go
stmt.go
+6
-7
No files found.
stmt.go
View file @
3107a54d
...
...
@@ -18,7 +18,7 @@ package sqlite
// #define SQLITE_TRANSIENT ((sqlite3_destructor_type)-1)
static inline int my_bind_text(sqlite3_stmt *stmt, int pidx, const char *data, int data_len) {
return sqlite3_bind_text(stmt, pidx, data, data_len,
SQLITE_TRANSIENT
);
return sqlite3_bind_text(stmt, pidx, data, data_len,
free
);
}
static inline int my_bind_empty_text(sqlite3_stmt *stmt, int pidx) {
return sqlite3_bind_text(stmt, pidx, "", 0, SQLITE_STATIC);
...
...
@@ -357,8 +357,7 @@ func (s *Stmt) BindByIndex(index int, value interface{}) error {
if
i64
&&
len
(
value
)
>
math
.
MaxInt32
{
return
s
.
specificError
(
"string too big: %d at index %d"
,
len
(
value
),
index
)
}
cs
,
l
:=
cstring
(
value
)
rv
=
C
.
my_bind_text
(
s
.
stmt
,
i
,
cs
,
l
)
rv
=
C
.
my_bind_text
(
s
.
stmt
,
i
,
C
.
CString
(
value
),
C
.
int
(
len
(
value
)))
}
case
int
:
if
i64
{
...
...
@@ -393,8 +392,8 @@ func (s *Stmt) BindByIndex(index int, value interface{}) error {
}
else
if
s
.
c
.
DefaultTimeLayout
==
""
{
rv
=
C
.
sqlite3_bind_int64
(
s
.
stmt
,
i
,
C
.
sqlite3_int64
(
value
.
Unix
()))
}
else
{
cs
,
l
:=
cstring
(
value
.
Format
(
s
.
c
.
DefaultTimeLayout
)
)
rv
=
C
.
my_bind_text
(
s
.
stmt
,
i
,
cs
,
l
)
v
:=
value
.
Format
(
s
.
c
.
DefaultTimeLayout
)
rv
=
C
.
my_bind_text
(
s
.
stmt
,
i
,
C
.
CString
(
v
),
C
.
int
(
len
(
v
))
)
}
case
ZeroBlobLength
:
rv
=
C
.
sqlite3_bind_zeroblob
(
s
.
stmt
,
i
,
C
.
int
(
value
))
...
...
@@ -419,8 +418,8 @@ func (s *Stmt) BindReflect(index int, value interface{}) error {
v
:=
reflect
.
ValueOf
(
value
)
switch
v
.
Kind
()
{
case
reflect
.
String
:
cs
,
l
:=
cstring
(
v
.
String
())
rv
=
C
.
my_bind_text
(
s
.
stmt
,
i
,
cs
,
l
)
vs
:=
v
.
String
()
// TODO NullIfEmptyString
rv
=
C
.
my_bind_text
(
s
.
stmt
,
i
,
C
.
CString
(
vs
),
C
.
int
(
len
(
vs
))
)
case
reflect
.
Int
,
reflect
.
Int8
,
reflect
.
Int16
,
reflect
.
Int32
,
reflect
.
Int64
:
rv
=
C
.
sqlite3_bind_int64
(
s
.
stmt
,
i
,
C
.
sqlite3_int64
(
v
.
Int
()))
case
reflect
.
Uint
,
reflect
.
Uint8
,
reflect
.
Uint16
,
reflect
.
Uint32
,
reflect
.
Uint64
,
reflect
.
Uintptr
:
...
...
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