write once compile anywhere: mysqlclient lazarus / 16-Databases ---------------------------------------------------------------------- hakelm · 2014-04-10 19:13 Using libmysqlclient I have written a program for querying a MySQL database. It compiles and runs without flaws under Linux i386 (Ubuntu) and Windows xp, 7, 8.1. Under Ubuntu AMD-64 queries, however, truncates fields and also returns empty fields. Has anyone else seen this behaviour? For the mysql-unit I use mysql.pp (Copyright (C) 2000 MySQL AB). I have both tried cdecl and stdcall for the function prototypes but this doesn't seem to matter. My AMD-64 library is /usr/lib/x86_64-linux-gnu/libmysqlclient.so.18 from 21/1 2014. Any tip is appreciated. H ---------------------------------------------------------------------- Mike.Cornflake · 2014-04-11 01:02 Both SQLDB and ZEOS provide working connections to MySQL.   I'm presuming you're writing your own for a reason, however you could look into their code, see how they do it... ---------------------------------------------------------------------- marcov · 2014-04-11 09:41 mysql protocol etc are highly versioned. Make sure your mysql unit is prepared for 64-bit mysql and for the correct version. Or use one of the supported versions that Mike named. ---------------------------------------------------------------------- LacaK · 2014-04-11 09:48 Quote from: hakelm on April 10, 2014, 09:13:03 pm For the mysql-unit I use mysql.pp (Copyright (C) 2000 MySQL AB). I have both tried cdecl and stdcall for the From where do you use mysql.pp ? It is your own unit ? (Can you try units (depends on version of your libmysqlclinet) from packages/mysql/src ?) ---------------------------------------------------------------------- hakelm · 2014-04-13 19:33 No it's not my own unit, it can still be found on the internet and is similar to mysql4.pp coming with Lazarus. I have used it without problems for around 10 years. I believe that I now have found the problem. The new libmysqlclient for AMD-64 seems to have a bug in mysql_fetch_lengths which returns erroneous values. The code below doesn't work: Code: [Select]............. row:=prow(mysql_fetch_row(fmysqlresult)); while row<>nil do begin fieldlengths:=plengths(mysql_fetch_lengths(fmysqlresult)); for x:=0 to fieldcount-1 do begin l:=fieldlengths^[x]; pf:=row^ [x]; s:=copy(pf,1,l); result[x,y]:=s; end; inc(y); row:=prow(mysql_fetch_row(fmysqlresult)); end; But this seems to correct the problem: Code: [Select]row:=prow(mysql_fetch_row(fmysqlresult)); while row<>nil do begin for x:=0 to fieldcount-1 do begin pf:=row^[x]; if pf<>nil then result[x,y]:=pf else result[x,y]:=''; end; inc(y); row:=prow(mysql_fetch_row(fmysqlresult)); end; H