Page 1 of 1

Wrong definitions in ZPlainSqLiteDriver

Posted: 21.03.2023, 09:28
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,

Re: Wrong definitions in ZPlainSqLiteDriver

Posted: 21.03.2023, 11:23
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

Re: Wrong definitions in ZPlainSqLiteDriver

Posted: 22.04.2023, 17:21
by stoffman
I've just seen this message... I missed it...

Yes, the changes looks correct.