Hello jp, with DISQLite3, I use the the following colation callback function without problems:
function SQLite3_Compare_System_NoCase_Ansi( UserData: Pointer; l1: Integer; const s1: Pointer; l2: Integer; const s2: Pointer): Integer; begin Result := CompareStringA(LOCALE_SYSTEM_DEFAULT, NORM_IGNORECASE, s1, l1, s2, l2) - 2; end; This function should be functionally equivalent to your implementation, but accesses the Win32 API directly. Also, it does not implicitly convert the PChar pointers to AnsiStrings like your call "copy(B,1,lenB);" implicitly does. Notes: * The above function is not declared as "cdecl" because DISQLite3 uses the faster "register" calling convention instead. * The above function (just as yours) does not treat UTF-8 sequences properly. You might want to consider a WideString function instead, depending on the data you are processing. Regards, Ralf >I have a custom collation which worked well in 3.3.6, >but now gives random errors on 3.3.13. Might just be >coincidence but wanted to get feedback from the >community. > >Under random circumstances, my Delphi function >(compare function defined in sqlite3_create_collation) >doesn't seem to receive the right parameters. After >debugging, the error... > >"Access violation at address 00405190 in module >'app.exe'. Read of address 016D000" > >...happens in line #15, like if the pointer to the >second variable (B) is invalid: > > 1 FUNCTION fnComp(user:pointer; > 2 lenA:integer; A:pChar; > 3 lenB:integer; B:pChar > 4 ):integer; cdecl; > 5 > 6 VAR S1,S2 :string; > 7 i:integer; > 8 BEGIN > 9 S1 := ''; >10 S2 := ''; >11 IF lenA>0 THEN >12 S1 := copy(A,1,lenA); >13 >14 IF lenB>0 THEN >15 S2 := copy(B,1,lenB); // error happens here! >16 >17 i := ansiCompareText(S1,S2); >18 >19 IF (i=0) THEN >20 IF (lena<lenb) THEN >21 i := -1 >22 ELSE >23 i := 1 >24 ELSE ; >25 >26 Result := i; >27 END; >... >The collation is created using: > >sqlResult:=sqlite3_create_collation(db3, > 'myCollate', > SQLITE_UTF8, > self, > fnComp); > >- - - - >No error happens when using the BINARY and NOCASE >collation. > >Does anybody have similar experiences or have a clue >of what might be going on? The error happens after >processing several thousand records, but sometimes >happens on an INSERT, other times during a SELECT, and >never in exactly the same place (even with the same >set of data/database). > >jp > > > > > >____________________________________________________________________________________ >It's here! Your new message! >Get new email alerts with the free Yahoo! Toolbar. >http://tools.search.yahoo.com/toolbar/features/mail/ > >----------------------------------------------------------------------------- >To unsubscribe, send email to [EMAIL PROTECTED] >----------------------------------------------------------------------------- ----------------------------------------------------------------------------- To unsubscribe, send email to [EMAIL PROTECTED] -----------------------------------------------------------------------------