[fpc-pascal] Sqlite error sqlite3_extended_errcode SIGSDEV (better format)

Santiago A. svaa at ciberpiula.net
Wed Mar 14 18:50:57 CET 2018


I had problems with Sqlite3 it raised SIGSDEV exception, but I think it
worked with FPC 2.6.4 from Lazarus 1.6. (not sure because It is a new
PC, but with 1.8.0) . Finally I have found where the problem is.

The problem is in sqlite3conn.pp:

procedure TSQLite3Connection.checkerror(const aerror: integer);
  ErrMsg : String;
  ErrCode : integer;
 if (aerror<>sqlite_ok) then   
     ErrMsg := strpas(sqlite3_errmsg(fhandle));
     ErrCode :=sqlite3_extended_errcode(fhandle);  // <========== here is the problem
     raise ESQLDatabaseError.CreateFmt(ErrMsg, [], Self, ErrCode, '');

The problem is that sqlite3_extended_errcode is not a regular function,
is a pointer to a function, and it is nil.

So I added:

if  assigned(sqlite3_extended_errcode) then
  ErrCode :=sqlite3_extended_errcode(fhandle);
 ErrCode := 0;

Why is sqlite3_extended_errcode nil? It is assigned in sqlite.inc as a
pointer to a function of sqlite3.dll.
  pointer(sqlite3_extended_errcode) :=
I downloaded the last version of sqlite3.dll and now it works. Was my
dll corrupted or was too old and hadn't such entry?. Nevertheless, I
think this check of nil should be done, or check the version and rise
"Not valied for this version". A SIGSDEV may drive you nuts.


Santiago A.

More information about the fpc-pascal mailing list