From 0430b37250c76ab632ed1b3e61d967666b31312a Mon Sep 17 00:00:00 2001 From: David Anderson Date: Thu, 8 Jun 2017 19:14:07 -0700 Subject: Add support for collation sequences implemented in Go. This allows Go programs to register custom comparison functions with sqlite, and ORDER BY that comparator. --- callback.go | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'callback.go') diff --git a/callback.go b/callback.go index 48fc63a..244e739 100644 --- a/callback.go +++ b/callback.go @@ -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 { -- cgit v1.2.3