Add support for collation sequences implemented in Go.

This allows Go programs to register custom comparison functions with
sqlite, and ORDER BY that comparator.
This commit is contained in:
David Anderson
2017-06-08 19:14:07 -07:00
parent 83772a7051
commit 0430b37250
3 changed files with 152 additions and 0 deletions

View File

@@ -53,6 +53,12 @@ func doneTrampoline(ctx *C.sqlite3_context) {
ai.Done(ctx)
}
//export compareTrampoline
func compareTrampoline(handlePtr uintptr, la C.int, a *C.char, lb C.int, b *C.char) C.int {
cmp := lookupHandle(handlePtr).(func(string, string) int)
return C.int(cmp(C.GoStringN(a, la), C.GoStringN(b, lb)))
}
// Use handles to avoid passing Go pointers to C.
type handleVal struct {