The new experimental sqlite3_collation_needed [1] functions seem ideal to use in a collation library, but I believe they have a design flaw that invalidate their use in the generic case.
The use case I see for a user using a 3rd party collation library is something like this: 1. open the database 2. invoke the collation library initialization routine 2.1. the collation library would call sqlite3_collation_needed on the database 3. use the database [steps 1-2 could be in a single function passed to sqlite3_auto_extension()] The problem is that we can't actually do this because the collation library has no way to know if the user has already defined some private collation for it's own use, or even use a second 3rd. party library for another collation functions (for example, one library for western languages and another for eastern languages). And even if we could know the previous callback (so we could call it in our function if we don't know how to handle it), then there is the problem of that function pointer being invalidated because it's in a "DLL" we later unload (which is probably the case in a 3rd. party library). I would propose to make sqlite3_collation_needed use some list of callbacks (a list of functions to search in some established direction) and have some way to remove the callback from the list. To avoid defining another function just to remove the callback, one could add some feature flags to define ordering and have a remove flag there, like: int sqlite3_collation_needed( sqlite3*, void*, callback_type_t, int flags ); #define SQLITE3_COLLATION_WANT_UTF8 0x0000 #define SQLITE3_COLLATION_WANT_UTF16 0x0001 #define SQLITE3_COLLATION_REMOVE 0x0002 #define SQLITE3_COLLATION_SEARCH_FIRST 0x0004 #define SQLITE3_COLLATION_SEARCH_LAST 0x0008 [the names and values of the constants are just for illustration purposes] This way you add features (choose to insert at front or back of the search list), fix the issue and even remove one function from the API (the UTF-16 variation). The reason I don't implement the code is because I believe it's trivial enough, and if I did then it would have to wait until the legal bureaucracy of copyright assignment was done before being merged into the tree. Best regards, ~Nuno Lucas [1] http://www.sqlite.org/capi3ref.html#sqlite3_collation_needed ----------------------------------------------------------------------------- To unsubscribe, send email to [EMAIL PROTECTED] -----------------------------------------------------------------------------