You are not logged in.
Hi,
we have manually created a FTS5 Fulltext-Index, where the following SQL code will crash, when using TSQLRequest:
SELECT GlobalID, Module, Service, DefaultDisplayText FROM ukiFtsMap JOIN (SELECT RowID, Rank FROM ukiFtsIndex WHERE ukiFtsIndex MATCH 'max') ON ID = RowID ORDER BY Rank LIMIT 15 OFFSET 0
When removing the Rank from the SELECT statement, all will execute just fine, however, the important match ranking is lost:
SELECT GlobalID, Module, Service, DefaultDisplayText FROM ukiFtsMap JOIN (SELECT RowID FROM ukiFtsIndex WHERE ukiFtsIndex MATCH 'max') ON ID = RowID LIMIT 15 OFFSET 0
First time, I try to execute this statement in the SynDB Explorer, I get the following error message:
[Window Title]
SynDB Explorer 1.18.5030 (compiled with Delphi 10.3 Rio 32 bit) - FTS
[Main Instruction]
Error
[Content]
Invalid floating point operation
[Expanded Information]
Exception class: EInvalidOp
[^] Hide details [OK]
Subsequent request will fail with following error:
[Window Title]
SynDB Explorer 1.18.5030 (compiled with Delphi 10.3 Rio 32 bit) - FTS
[Main Instruction]
Error
[Content]
Access violation at address 0084C1CC in module 'SynDBExplorer.exe'. Read of address 00000008
[Expanded Information]
Exception class: EAccessViolation
[^] Hide details [OK]
Please note, that the same SQL will run fine with other SQLite Browsers, so I believe the problem is with the mORMot implementation. However, debugging did not get me very far. :-(
The problem can be recreated with the latest nightly build.
Kind regards,
Daniel
@Arnaud: I can send you a copy of the DB3 file for checking into this.
Offline
I have created a simple sample, that will reproduce the problem.
Start SynDB Explorer with a new, empty SQLITE3 DB.
Execute each of the following statement separately, the last on will reproduce the error:
CREATE VIRTUAL TABLE Idx USING fts5(A, tokenize='unicode61');
INSERT INTO Idx (RowID, A) VALUES (1, 'hello world');
INSERT INTO Idx (RowID, A) VALUES (2, 'hello max');
INSERT INTO Idx (RowID, A) VALUES (3, 'hello frank');
SELECT RowID, A FROM Idx WHERE Idx MATCH 'max';
SELECT RowID, A FROM Idx WHERE Idx MATCH 'max' ORDER BY Rank;
Regards,
Daniel
Offline
Well, as I said, I did not get very far. From
function TSQLDBStatement.FetchAllToJSON(JSON: TStream; Expanded: boolean;
RewindToFirst: boolean): PtrInt;
...
while Step(RewindToFirst) do begin
it goes into
function TSQLDBSQLite3Statement.Step(SeekFirst: boolean): boolean;
...
result := fStatement.Step=SQLITE_ROW;
to
function TSQLRequest.Step: integer;
...
result := sqlite3_check(RequestDB,sqlite3.step(Request),'Step');
Which seems to be a function within the SQLite driver. (sqlite3.step(Request))
Then it jumps into
function memset(P: Pointer; B: Integer; count: Integer): pointer; cdecl; { always cdecl }
// a fast full pascal version of the standard C library function
begin
FillCharFast(P^, count, B);
result := P;
end;
and upon return into the CPU view... :-(
Regards,
Daniel
Last edited by sakura (2019-02-11 18:25:57)
Offline
At some point, following function gets called (Unit SynSQLite3Static):
function log(const val: extended): extended;
asm
fld val
fldln2
fxch
fyl2x
fwait
end;
Upon coming to fwait, the exception is thrown.
Offline
Could you try to replace the low-level asm code by the following:
function log(const val: extended): extended;
begin
result := ln(val);
end;
OR
just comment the fwait ?
My guess is that the SQlite3.obj code doesn't use FPU exceptions, so the linked log() value shouldn't be used either...
Offline
Update: I guess I found the root cause.
On my side after https://synopse.info/fossil/info/fe4a3b9b56 FTS+RANK works fine now.
Offline