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
1ee314b6
Commit
1ee314b6
authored
Aug 27, 2011
by
gwenn
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Wraps sqlite3_profile.
parent
a40e43f9
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
36 additions
and
0 deletions
+36
-0
sqlite.go
sqlite.go
+1
-0
sqlite_test.go
sqlite_test.go
+5
-0
trace.go
trace.go
+30
-0
No files found.
sqlite.go
View file @
1ee314b6
...
...
@@ -136,6 +136,7 @@ func (c *Conn) Error() os.Error {
type
Conn
struct
{
db
*
C
.
sqlite3
authorizer
*
sqliteAuthorizer
profile
*
sqliteProfile
trace
*
sqliteTrace
}
...
...
sqlite_test.go
View file @
1ee314b6
...
...
@@ -16,6 +16,10 @@ func authorizer(d interface{}, action Action, arg1, arg2, arg3, arg4 string) Aut
return
AUTH_OK
}
func
profile
(
d
interface
{},
sql
string
,
nanoseconds
uint64
)
{
fmt
.
Printf
(
"%s: %s = %d
\n
"
,
d
,
sql
,
nanoseconds
/
1000
)
}
func
open
(
t
*
testing
.
T
)
*
Conn
{
db
,
err
:=
Open
(
""
,
OPEN_READWRITE
,
OPEN_CREATE
,
OPEN_FULLMUTEX
,
OPEN_URI
)
if
err
!=
nil
{
...
...
@@ -31,6 +35,7 @@ func open(t *testing.T) *Conn {
t.Fatal("couldn't set an authorizer", err)
}
*/
//db.Profile(profile, "PROFILE")
return
db
}
...
...
trace.go
View file @
1ee314b6
...
...
@@ -15,6 +15,11 @@ extern void goXTrace(void *pArg, const char *t);
static void goSqlite3Trace(sqlite3 *db, void *pArg) {
sqlite3_trace(db, goXTrace, pArg);
}
extern void goXProfile(void *pArg, const char *sql, sqlite3_uint64 nanoseconds);
static void goSqlite3Profile(sqlite3 *db, void *pArg) {
sqlite3_profile(db, goXProfile, pArg);
}
extern int goXAuth(void *pUserData, int action, const char *arg1, const char *arg2, const char *arg3, const char *arg4);
...
...
@@ -54,6 +59,31 @@ func (c *Conn) Trace(f Tracer, arg interface{}) {
C
.
goSqlite3Trace
(
c
.
db
,
unsafe
.
Pointer
(
c
.
trace
))
}
type
Profiler
func
(
d
interface
{},
sql
string
,
nanoseconds
uint64
)
type
sqliteProfile
struct
{
f
Profiler
d
interface
{}
}
//export goXProfile
func
goXProfile
(
pArg
unsafe
.
Pointer
,
sql
*
C
.
char
,
nanoseconds
C
.
sqlite3_uint64
)
{
arg
:=
(
*
sqliteProfile
)(
pArg
)
arg
.
f
(
arg
.
d
,
C
.
GoString
(
sql
),
uint64
(
nanoseconds
))
}
// Calls sqlite3_profile, http://sqlite.org/c3ref/profile.html
func
(
c
*
Conn
)
Profile
(
f
Profiler
,
arg
interface
{})
{
if
f
==
nil
{
c
.
profile
=
nil
C
.
sqlite3_profile
(
c
.
db
,
nil
,
nil
)
return
}
// To make sure it is not gced, keep a reference in the connection.
c
.
profile
=
&
sqliteProfile
{
f
,
arg
}
C
.
goSqlite3Profile
(
c
.
db
,
unsafe
.
Pointer
(
c
.
profile
))
}
type
Auth
int
const
(
...
...
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