Wrong definitions in ZPlainSqLiteDriver

The offical for ZeosLib 7.3 Report problems, ask for help, post proposals for the new version of Zeoslib 7.3/v8
Quick Info:
-We made two new drivers: odbc(raw and unicode version) and oledb
-GUID domain/field-defined support for FB
-extended error infos of Firebird
-performance ups are still in queue
In future some more feature will arrive, so stay tuned and don't hassitate to help
Post Reply
stoffman
Senior Boarder
Senior Boarder
Posts: 50
Joined: 03.12.2020, 06:55

Wrong definitions in ZPlainSqLiteDriver

Post by stoffman »

There are some wrong definitions in ZPlainSqLiteDriver, nothing big but it affects anyone who will try to work with SQLite directly

Current code (as of 2023/1/17)

Code: Select all

type 
   Tsqlite3_destructor_type = procedure(user: pointer); cdecl;
   SQLITE_STATIC = procedure(User: Pointer = Nil); cdecl;
   SQLITE_TRANSIENT = procedure(User: pointer = Pointer(-1)); cdecl;
But in the C header it is

Code: Select all

typedef void (*sqlite3_destructor_type)(void*);
#define SQLITE_STATIC      ((sqlite3_destructor_type)0)
#define SQLITE_TRANSIENT   ((sqlite3_destructor_type)-1)
meaning that SQLITE_STATIC and SQLITE_TRANSIENT are not types but values (or consts for that matter)

so the actual translation should be

Code: Select all

type
  Tsqlite3_destructor_type = procedure(Ptr: Pointer); cdecl;
const
  SQLITE_STATIC: Tsqlite3_destructor_type = nil;
  SQLITE_TRANSIENT: Tsqlite3_destructor_type = Pointer(-1);
This is also the case with Sqlite3 unit that comes with Lazarus (version 2.2.4):

Code: Select all

type
  sqlite3_destructor_type = procedure(user: pointer); cdecl;

const
  SQLITE_STATIC      = sqlite3_destructor_type(nil);
  SQLITE_TRANSIENT   = pointer(-1); //sqlite3_destructor_type(-1); 
Thanks,
marsupilami
Platinum Boarder
Platinum Boarder
Posts: 1956
Joined: 17.01.2011, 14:17

Re: Wrong definitions in ZPlainSqLiteDriver

Post by marsupilami »

Hello Stoffman,

I applied the fix to Zeos trunk / 8.0 / 7.2 and 7.1. Please check if it works. The changes should be available in SVN immediately and in Github by tomorrow.

Best regards,

Jan
stoffman
Senior Boarder
Senior Boarder
Posts: 50
Joined: 03.12.2020, 06:55

Re: Wrong definitions in ZPlainSqLiteDriver

Post by stoffman »

I've just seen this message... I missed it...

Yes, the changes looks correct.
Post Reply