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
fa0708e4
Commit
fa0708e4
authored
Oct 15, 2011
by
gwenn
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add support to extension loading.
parent
75ce7b1c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
49 additions
and
0 deletions
+49
-0
sqlite.go
sqlite.go
+36
-0
sqlite_test.go
sqlite_test.go
+13
-0
No files found.
sqlite.go
View file @
fa0708e4
...
...
@@ -515,6 +515,10 @@ func (s *Stmt) ClearBindings() os.Error {
func
(
s
*
Stmt
)
ColumnCount
()
int
{
return
int
(
C
.
sqlite3_column_count
(
s
.
stmt
))
}
// Calls http://sqlite.org/c3ref/data_count.html
func
(
s
*
Stmt
)
DataCount
()
int
{
return
int
(
C
.
sqlite3_data_count
(
s
.
stmt
))
}
// The leftmost column is number 0.
// Calls http://sqlite.org/c3ref/column_name.html
...
...
@@ -688,6 +692,11 @@ func (s *Stmt) Finalize() os.Error {
return
nil
}
// Like http://sqlite.org/c3ref/db_handle.html
func
(
s
*
Stmt
)
Conn
()
*
Conn
{
return
s
.
c
}
// Calls http://sqlite.org/c3ref/close.html
func
(
c
*
Conn
)
Close
()
os
.
Error
{
if
c
==
nil
{
...
...
@@ -702,6 +711,33 @@ func (c *Conn) Close() os.Error {
return
nil
}
// Calls http://sqlite.org/c3ref/enable_load_extension.html
func
(
c
*
Conn
)
EnableLoadExtension
(
b
bool
)
{
C
.
sqlite3_enable_load_extension
(
c
.
db
,
btocint
(
b
))
}
// Calls http://sqlite.org/c3ref/load_extension.html
func
(
c
*
Conn
)
LoadExtension
(
file
string
,
proc
...
string
)
os
.
Error
{
cfile
:=
C
.
CString
(
file
)
defer
C
.
free
(
unsafe
.
Pointer
(
cfile
))
var
cproc
*
C
.
char
if
len
(
proc
)
>
0
{
cproc
=
C
.
CString
(
proc
[
0
])
defer
C
.
free
(
unsafe
.
Pointer
(
cproc
))
}
var
errMsg
*
C
.
char
rv
:=
C
.
sqlite3_load_extension
(
c
.
db
,
cfile
,
cproc
,
&
errMsg
)
if
rv
!=
C
.
SQLITE_OK
{
defer
C
.
sqlite3_free
(
unsafe
.
Pointer
(
errMsg
))
return
os
.
NewError
(
Errno
(
rv
)
.
String
()
+
": "
+
C
.
GoString
(
errMsg
))
}
return
nil
}
// Calls http://sqlite.org/c3ref/enable_shared_cache.html
func
EnableSharedCache
(
b
bool
)
{
C
.
sqlite3_enable_shared_cache
(
btocint
(
b
))
}
// Must is a helper that wraps a call to a function returning (bool, os.Error)
// and panics if the error is non-nil.
func
Must
(
b
bool
,
err
os
.
Error
)
bool
{
...
...
sqlite_test.go
View file @
fa0708e4
...
...
@@ -455,6 +455,19 @@ func TestNamedScanColumn(t *testing.T) {
}
}
/*
func TestLoadExtension(t *testing.T) {
db := open(t)
db.EnableLoadExtension(true)
err := db.LoadExtension("/tmp/myext.so")
if err != nil {
t.Errorf("load extension error: %s", err)
}
}
*/
func
BenchmarkScan
(
b
*
testing
.
B
)
{
b
.
StopTimer
()
db
,
_
:=
Open
(
""
)
...
...
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