Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2018-03

Sqlite error sqlite3_extended_errcode SIGSDEV

4 messages · 2 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Santiago A.

Hello:

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);Var 
ErrMsg : String;  ErrCode : integer;begin if (aerrorsqlite_ok) then   
begin   ErrMsg := strpas(sqlite3_errmsg(fhandle));   ErrCode :=
sqlite3_extended_errcode(fhandle);  // <========== here is the problem  
raise ESQLDatabaseError.CreateFmt(ErrMsg, [], Self, ErrCode, '');   end;end;

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); else 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) :=
GetProcedureAddress(LibHandle,'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.

Saludos Santiago A.

Reply by email

Santiago A.
to Santiago A.

Hello:

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);
Var 
  ErrMsg : String;
  ErrCode : integer;
begin
 if (aerrorsqlite_ok) then   
   begin  
     ErrMsg := strpas(sqlite3_errmsg(fhandle));
     ErrCode :=sqlite3_extended_errcode(fhandle);  // <========== here is the problem
     raise ESQLDatabaseError.CreateFmt(ErrMsg, [], Self, ErrCode, '');
   end;
end;

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);
else
 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) :=
GetProcedureAddress(LibHandle,'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.

Saludos Santiago A.

Reply by email

Luca Olivetti
to Santiago A.

El 14/03/18 a les 18:50, Santiago A. ha escrit:

Show quoted text 5 lines
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.

According to https://sqlite.org/changes.html, sqlite3_extended_errcode was added in version 3.6.5 in 2008.

Bye

Luca

Reply by email

Santiago A.
to Luca Olivetti
Luca Olivetti wrote 11 lines
El 14/03/18 a les 18:50, Santiago A. ha escrit: >   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. According to https://sqlite.org/changes.html, sqlite3_extended_errcode was added in version 3.6.5 in 2008. Bye

Yeah, my version is a little outdated ;-). I searched sqlite3.dll in this computer and I found more than fifteen instances, it looks like each application installs its own instance of the dll. So there are a lot of versions. I'm replacing a Delphi5 small utility, so probably it was one of the oldest.

Nevertheless, it wouldn't be a bad idea to check the minimal version after loading the lib.

Saludos Santiago A.

Reply by email