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
808b499d
Commit
808b499d
authored
Aug 27, 2011
by
gwenn
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Wraps sqlite_busy_handler.
parent
1ee314b6
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
37 additions
and
4 deletions
+37
-4
sqlite.go
sqlite.go
+5
-4
trace.go
trace.go
+32
-0
No files found.
sqlite.go
View file @
808b499d
...
@@ -134,10 +134,11 @@ func (c *Conn) Error() os.Error {
...
@@ -134,10 +134,11 @@ func (c *Conn) Error() os.Error {
// Connection
// Connection
type
Conn
struct
{
type
Conn
struct
{
db
*
C
.
sqlite3
db
*
C
.
sqlite3
authorizer
*
sqliteAuthorizer
authorizer
*
sqliteAuthorizer
profile
*
sqliteProfile
busyHandler
*
sqliteBusyHandler
trace
*
sqliteTrace
profile
*
sqliteProfile
trace
*
sqliteTrace
}
}
// Calls http://sqlite.org/c3ref/libversion.html
// Calls http://sqlite.org/c3ref/libversion.html
...
...
trace.go
View file @
808b499d
...
@@ -26,6 +26,12 @@ extern int goXAuth(void *pUserData, int action, const char *arg1, const char *ar
...
@@ -26,6 +26,12 @@ extern int goXAuth(void *pUserData, int action, const char *arg1, const char *ar
static int goSqlite3SetAuthorizer(sqlite3 *db, void *pUserData) {
static int goSqlite3SetAuthorizer(sqlite3 *db, void *pUserData) {
return sqlite3_set_authorizer(db, goXAuth, pUserData);
return sqlite3_set_authorizer(db, goXAuth, pUserData);
}
}
extern int goXBusy(void *pArg, int n);
static int goSqlite3BusyHandler(sqlite3 *db, void *pArg) {
return sqlite3_busy_handler(db, goXBusy, pArg);
}
*/
*/
import
"C"
import
"C"
...
@@ -154,3 +160,29 @@ func (c *Conn) SetAuthorizer(f Authorizer, arg interface{}) os.Error {
...
@@ -154,3 +160,29 @@ func (c *Conn) SetAuthorizer(f Authorizer, arg interface{}) os.Error {
c
.
authorizer
=
&
sqliteAuthorizer
{
f
,
arg
}
c
.
authorizer
=
&
sqliteAuthorizer
{
f
,
arg
}
return
c
.
error
(
C
.
goSqlite3SetAuthorizer
(
c
.
db
,
unsafe
.
Pointer
(
c
.
authorizer
)))
return
c
.
error
(
C
.
goSqlite3SetAuthorizer
(
c
.
db
,
unsafe
.
Pointer
(
c
.
authorizer
)))
}
}
type
BusyHandler
func
(
d
interface
{},
n
int
)
int
type
sqliteBusyHandler
struct
{
f
BusyHandler
d
interface
{}
}
//export goXBusy
func
goXBusy
(
pArg
unsafe
.
Pointer
,
n
C
.
int
)
C
.
int
{
arg
:=
(
*
sqliteBusyHandler
)(
pArg
)
result
:=
arg
.
f
(
arg
.
d
,
int
(
n
))
return
C
.
int
(
result
)
}
// TODO NOT TESTED
// Calls http://sqlite.org/c3ref/busy_handler.html
func
(
c
*
Conn
)
BusyHandler
(
f
BusyHandler
,
arg
interface
{})
os
.
Error
{
if
f
==
nil
{
c
.
busyHandler
=
nil
return
c
.
error
(
C
.
sqlite3_busy_handler
(
c
.
db
,
nil
,
nil
))
}
// To make sure it is not gced, keep a reference in the connection.
c
.
busyHandler
=
&
sqliteBusyHandler
{
f
,
arg
}
return
c
.
error
(
C
.
goSqlite3BusyHandler
(
c
.
db
,
unsafe
.
Pointer
(
c
.
busyHandler
)))
}
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