When I connect to MySQL under Linux on Delphi, it throws an error(Unknown MySQL data type!) at ConvertMySQLHandleToSQLType.
Under Delphi 64bit Posix targets, LongWord is 8 Bytes, which is different from FPC.
https://docwiki.embarcadero.com/Libraries/Sydney/en/System.LongWord
https://docwiki.embarcadero.com/RADStudio/Florence/en/Simple_Types_%28Delphi%29#Integer_Types
According to the doc, this issue should exists for all 64bit POSIX platforms on Delphi, including iOS 64bit, macOS 64bit, Android 64bit, Linux 64bit.
This is what I change in ZCompatibility.pas, after these 2 changes, it works under Delphi 64bit Linux.
UInt = Cardinal
Change all LongWord, PLongWord to Cardinal and PCardinal in function Hash in ZCompatibility.pas.
function Hash(const S: RawByteString): Cardinal;
var
k: LongWord;
Len: LongWord;
P, PEnd: PAnsiChar;
const
// 'm' and 'r' are mixing constants generated offline.
// They're not really 'magic', they just happen to work well.
m = $5bd1e995;
r = 24;
begin
//The default seed, $9747b28c, is from the original C library
P := Pointer(S);
if P = nil then
Result := $ffffffff
else
begin
Len := {%Result-}PLengthInt(P - StringLenOffSet)^;
// Initialize the hash to a 'random' value
Result := $9747b28c xor len;
// Mix 4 bytes at a time into the hash
PEnd := P + Len - 4;
while P < PEnd do
begin
k := PCardinal(P)^;
k := k * m;
k := k xor (k shr r);
k := k * m;
Result := Result * m;
Result := Result xor k;
Inc(P, 4);
end;
Inc(PEnd, 4);
Len := PEnd-P;
{ Handle the last few bytes of the input array
P: ... $69 $18 $2f
}
if len = 3 then
Result := Result xor (Cardinal((P+2)^) shl 16);
if len >= 2 then
Result := Result xor (Cardinal((P+1)^) shl 8);
if len >= 1 then
begin
Result := Result xor (Cardinal(P^));
Result := Result * m;
end;
// Do a few final mixes of the hash to ensure the last few
// bytes are well-incorporated.
Result := Result xor (Result shr 13);
Result := Result * m;
Result := Result xor (Result shr 15);
Result := Result;
end;
end;
This is the original post on the forum: https://zeoslib.sourceforge.io/viewtopic.php?p=317764
Also, should we review all LongWord usage? It should affect all 64bit mobile platforms on Delphi.
Hello Artie,
Yes - you are right. We need to review all the header translations which typically are on the plain driver layer of Zeos. This will become tedious and hard to test for several reasons:
I don't have a way to test all the DBMs with Delphi for Linux or even Delphi for Android. I don't have an Embarcadero license, that includes Linux and most database libraries (libpq, libmysql, ...) are not available for Android. I do know that Firebird and SQLite are available for Android.
Also the test suite is not prepared to run on FMX. So it will be some work to get it to run on Linux or Android...
Best regards,
Jan
Why not just replace all LongWord to Cardinal?
In FPC, LongWord is always 32bit.
https://www.freepascal.org/docs-html/rtl/system/longword.html
https://wiki.freepascal.org/LongWord
So all usages of LongWord currently in ZeosLib should be 32bit.
Also, it does not require FMX to run ZeosLib on Delphi for Linux. I'm migrating a Windows server program (which does not have GUIs) to Linux. It works now after the 2 changes I mentioned.
Also, I would like to ask something about the versions of ZeosLib. I can see all the latest changes first appear on 8.0-patches, and later on the trunk. I thought trunk is the dev branch, and 8.0-patches just receives some maintenance fixes, so am I wrong?
Last edit: Artie 2026-02-23