ZeosLib 7 64 bits support

The alpha/beta tester's forum for ZeosLib 7.0.x series

Report problems concerning our Delphi 2009+ version and new Zeoslib 7.0 features here.

This is a forum that will be removed once the 7.X version goes into stable!!

Moderators: gto, EgonHugeist, olehs

papelhigienico
Expert Boarder
Expert Boarder
Posts: 113
Joined: 06.10.2006, 14:41
Location: Chapecó - Santa Catarina
Contact:

ZeosLib 7 64 bits support

Post by papelhigienico »

After update to lastest revision (636), my applications that uses MySQL raises the exception:

Unknown MySQL data type!


Someone know how to solve this?

I was think that this is related with missing old functions (like mysql_connect) on MySQL client library, but that I could see, Zeos MySQL library is prepared for the new functions.

I'm using ubuntu Linux 9.04 x86_64. On Windows this not occurs.
User avatar
mdaems
Zeos Project Manager
Zeos Project Manager
Posts: 2766
Joined: 20.09.2005, 15:28
Location: Brussels, Belgium
Contact:

Post by mdaems »

Hi,

What branch (testing/trunk/6.6-patches) are you using and what revision did you come from? Just to give an indication about what may have changed.

Secondly, what field is this error coming from? Is it just a plain integer, string, some geographical thing or ...

Mark
Image
papelhigienico
Expert Boarder
Expert Boarder
Posts: 113
Joined: 06.10.2006, 14:41
Location: Chapecó - Santa Catarina
Contact:

Post by papelhigienico »

I'm using Zeos 7.0 rev 636.

My table have fields of types: datetime, Integer, tinyint(4), float and double. Only fields of types FLOAT and DOUBLE raises the exception.

So I create a test table like the table above without the types float and double, but now the exception is raised in another point.
User avatar
mdaems
Zeos Project Manager
Zeos Project Manager
Posts: 2766
Joined: 20.09.2005, 15:28
Location: Brussels, Belgium
Contact:

Post by mdaems »

Can you debug into the ConvertMySQLHandleToSQLType (ZDbcMySqlUtils.pas) function to see what value is returned by PlainDriver.GetFieldType(FieldHandle)?

This is a very strange error to find now at once, as this message is also in the current stable branch since rev. 306. I'm running the test suite on this release before (almost) every commit. On 3 different mysql versions (but all on windows as the suite is Delphi based and doesn't compile on FPC).

BUT wait... I see you're running on Ubuntu x86_64. Did there change something recently in your configuration? Mysql or fpc? Zeoslib is know to be not working correctly in 64 bit environments. Im not sure if the 64 bit libmysql version has the same interface data sizes as the 32 bit versions I'm testing with on Windows.

Mark
Image
papelhigienico
Expert Boarder
Expert Boarder
Posts: 113
Joined: 06.10.2006, 14:41
Location: Chapecó - Santa Catarina
Contact:

Post by papelhigienico »

When Float/Double fields are present, the type returned by the PlainDriver.GetFieldType is 31 and the exception is raised in the line 246 of ZDbcMysqlUtils (function ConvertMySQLHandleToSQLType).

But when it's not present, the exception is raised in the line 392 of the ZDbcMysqlUtils unit (function ConvertMySQLTypeToSQLType). In these function, the parameters TypeName and TypeNameFull are came NIL.
papelhigienico
Expert Boarder
Expert Boarder
Posts: 113
Joined: 06.10.2006, 14:41
Location: Chapecó - Santa Catarina
Contact:

Post by papelhigienico »

And everything is upgraded to x86_64, including lazarus, fpc and mysql.

I tried mysql 5.0 and 5.1.


Fabio
User avatar
mdaems
Zeos Project Manager
Zeos Project Manager
Posts: 2766
Joined: 20.09.2005, 15:28
Location: Brussels, Belgium
Contact:

Post by mdaems »

Fabio, that's where your trouble comes from. As I said above : Zeoslib is known to be not working correctly in 64 bit environments. Don't ask me what's the reason exactly. Maybe some pointer and buffer size calculation errors?

I'm afraid I can't exactly help you with this issue directly. Of course, I can help to get the necessary changes in the official zeoslib version, but then I'll need somebody to tell me what's working...

To point you in the right direction : a long time ago hgourvest wrote about it on the forum. Also a search on "64 bit" may help you going.

BTW: I didn't know it even compiles on 64-bit compilers.

Mark
Image
papelhigienico
Expert Boarder
Expert Boarder
Posts: 113
Joined: 06.10.2006, 14:41
Location: Chapecó - Santa Catarina
Contact:

Post by papelhigienico »

I changed the function bellow (near of line 393 of ZDbcMySqlResultSet.pas) to:

function TZMySQLResultSet.GetString(ColumnIndex: Integer): AnsiString;
var
LengthPointer: PLongInt;
Buffer: PAnsiChar;
begin
{$IFNDEF DISABLE_CHECKING}
CheckClosed;
if FRowHandle = nil then
raise EZSQLException.Create(SRowDataIsNotAvailable);
{$ENDIF}

ColumnIndex := ColumnIndex - 1;

Buffer := FPlainDriver.GetFieldData(FRowHandle, ColumnIndex);
LastWasNull := Buffer = nil;
Result := '';
if not LastWasNull then
Result := Buffer;
end;

And the error " Unknown MySQL data type" are solved, but now the exception "Bookmark was not found" is raised...

What is bookmark in Zeos?
skydiablo
Fresh Boarder
Fresh Boarder
Posts: 1
Joined: 11.06.2009, 19:27

Post by skydiablo »

hi,
i have the same problem, do you have solve this problem ?

greez & thx, sky....
User avatar
mdaems
Zeos Project Manager
Zeos Project Manager
Posts: 2766
Joined: 20.09.2005, 15:28
Location: Brussels, Belgium
Contact:

Post by mdaems »

skydiablo,
papelhigienico,
I think this can only be solved by making zeoslib 64-bit ready.
If you feel like helping us doing this?
I have no real idea what must change in order to do this. I think first thing to do is to check the places where integers are used to represent pointers and fix this.

papelhigienico,
did the change above make the program choose the right Mysqldata type? The I could try if it's safe on 32 bit systems and do the change anyway.

Mark
Image
papelhigienico
Expert Boarder
Expert Boarder
Posts: 113
Joined: 06.10.2006, 14:41
Location: Chapecó - Santa Catarina
Contact:

Post by papelhigienico »

Hi Mark!

The change above solves the exception "Unknown MySQL data type". But now, the exception "Bookmark was not found" is raised.

What is a Bookmark in MySQL driver? I'm very busy with my studies and job, but I can help. I need to see this working, my project depend of this.

Regards,
Fabio
User avatar
mdaems
Zeos Project Manager
Zeos Project Manager
Posts: 2766
Joined: 20.09.2005, 15:28
Location: Brussels, Belgium
Contact:

Post by mdaems »

Fabio,

I'm afraid you're still not on the right track. In my opinion this is a 64-bit incompatibility problem.
The bookmark object/method is just he Bookmark property defined on TDataset level. A qyuick scan says me there's some pointer code involved in zeoslib. This may explain the trouble you have.

Mark
Image
papelhigienico
Expert Boarder
Expert Boarder
Posts: 113
Joined: 06.10.2006, 14:41
Location: Chapecó - Santa Catarina
Contact:

Post by papelhigienico »

Yes, I'm wrong... but I want to understand what is a Bookmark to seek the problem...

And seeking this, I found some casting of pointer to Integer. Near of line 880 of ZAbstractRODataSet.pas is wrote

if FilterRow(ResultSet.GetRow) then
CurrentRows.Add(Pointer(ResultSet.GetRow))
else
Continue;


And ResultSet.GetRow is a Integer function defined in IZResultSet interface.

I will do the changes and see how many Access Violations I can do :)
User avatar
mdaems
Zeos Project Manager
Zeos Project Manager
Posts: 2766
Joined: 20.09.2005, 15:28
Location: Brussels, Belgium
Contact:

Post by mdaems »

As far as I can understand a bookmark is some pointer-like object that you can use to memorise your location in the dataset so you can easily jump back later after doing some browsing operations.

Mark
Image
papelhigienico
Expert Boarder
Expert Boarder
Posts: 113
Joined: 06.10.2006, 14:41
Location: Chapecó - Santa Catarina
Contact:

Post by papelhigienico »

Hi Mark!

Good news! The exception "Bookmark was not found" has been removed when opening the table (tested in Postgres and MySQL). But when I try to update a field, I got another exception, but I will seek this problem.

And yes, the problem is related with some casting of integer to pointer.
Locked