-
Notifications
You must be signed in to change notification settings - Fork 67
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add custom collation functions #97
base: master
Are you sure you want to change the base?
Conversation
special
commented
Aug 8, 2020
CreateCollation registers a Go function as a sqlite collation, similar to CreateFunction. These can be used in queries for custom sorting.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. minor changes please:
- use RWMutex
- Remove conn from xcollation
|
||
x := &xcollation{ | ||
name: name, | ||
conn: conn, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think a collation ever needs to know its own conn actually.
} | ||
|
||
var xcollations = struct { | ||
mu sync.Mutex |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please make this a sync.RWMutex
xcollations.mu.Lock() | ||
x := xcollations.m[int(ptr)] | ||
xcollations.mu.Unlock() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
xcollations.mu.Lock() | |
x := xcollations.m[int(ptr)] | |
xcollations.mu.Unlock() | |
xcollations.mu.RLock() | |
x := xcollations.m[int(ptr)] | |
xcollations.mu.RUnlock() |