The collation function used was as follows
int Compare(void* Data, int Len1, const void *s1, int Len2, const void *s2)
{
const UTF8String *S1 = static_cast<const UTF8String*>(s1),
*S2 = static_cast<const UTF8String*>(s2);
return 0;
}
Which was registered with the following code
if (sqlite3_create_collation(SQLiteDB, "Compare", SQLITE_UTF8, NULL,
&Compare) != SQLITE_OK)
throw Exception("Collation creation error");
The above is merely a tester where I’ve set a breakpoint at the ‘return 0’
line. I tried it with the following stmt
‘select ID from IDTbl order by Name collate Compare’.
I’m having the following problems
1. When it stops at the breakpoint the debugger shows the Len1 and Len2
params with correct looking values but the S1 and S2 appear to point to NULL
values. I just keep getting ‘???’ values. Am I casting wrongly or something.
1. If I change the select to ‘select ID from IDTbl order by ID collate
Compare’ the Compare function is never entered. Is this because ID is an
integer column? Is there no way to implement a custom collation on an integer
column?
1. If I change the registration to
if (sqlite3_create_collation16(SQLiteDB, "Compare", SQLITE_UTF16, NULL,
&Compare) != SQLITE_OK)
throw Exception("Collation creation error");
it seems to register OK but running the select yields a “no such
collation sequence: Compare” error.
Can any kind soul cast any light on this for me.
PS I’m using Embarcadero C++ builder 10.1 Berlin on windows 10 with the
sqlite3.c amalgamation included in my project.
_______________________________________________
sqlite-users mailing list
[email protected]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users