Option "BinaryAsString" and MySQL 4.1

Discussion of open issues, suggestions and bugs regarding MyDAC (Data Access Components for MySQL) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
upscene
Posts: 306
Joined: Thu 19 Oct 2006 08:13

Option "BinaryAsString" and MySQL 4.1

Post by upscene » Thu 16 Aug 2012 07:39

Hi,

In MySQL 4.1, with "BinaryAsString" OFF, a command SHOW VARIABLES returns a result set with datatype ftVarBytes.

In MySQL 5.x, this returns ftWideString.

Why the difference? Using .AsWideString on the field fails with access violations for MySQl 4.1.

With regards,

Martijn Tonies

AndreyZ

Re: Option "BinaryAsString" and MySQL 4.1

Post by AndreyZ » Thu 16 Aug 2012 09:21

Hello,
Why the difference?
The point is that MySQL 4 returns the fields of the SHOW VARIABLES statement as binary fields, when MySQL 5 returns them as string fields.
Using .AsWideString on the field fails with access violations for MySQl 4.1.
I cannot reproduce this problem. Please specify the following:
- the exact version of MyDAC. You can learn it from the About sheet of TMyConnection Editor;
- the exact version of your IDE;
- the exact version of MySQL server and client. You can learn it from the Info sheet of TMyConnection Editor.

upscene
Posts: 306
Joined: Thu 19 Oct 2006 08:13

Re: Option "BinaryAsString" and MySQL 4.1

Post by upscene » Thu 16 Aug 2012 09:27

AndreyZ wrote:Hello,
Why the difference?
The point is that MySQL 4 returns the fields of the SHOW VARIABLES statement as binary fields, when MySQL 5 returns them as string fields.
Using .AsWideString on the field fails with access violations for MySQl 4.1.
I cannot reproduce this problem. Please specify the following:
- the exact version of MyDAC. You can learn it from the About sheet of TMyConnection Editor;
- the exact version of your IDE;
- the exact version of MySQL server and client. You can learn it from the Info sheet of TMyConnection Editor.
OK, so it's MySQL at fault here in returning binary fields on version 4?

I'm using v6.10.0.7 in Delphi 2009.

When I use AsWideString on MySQL 4, it returns an AV.

AndreyZ

Re: Option "BinaryAsString" and MySQL 4.1

Post by AndreyZ » Thu 16 Aug 2012 10:27

OK, so it's MySQL at fault here in returning binary fields on version 4?
Yes.
When I use AsWideString on MySQL 4, it returns an AV.
I checked this question in the following environment:

Code: Select all

Delphi 2009 12.0.3170.16989 Architect
MyDAC 6.10.0.7
MySQL server version: 4.1.22-community
MySQL client version: Direct
, and used the following code:

Code: Select all

MyQuery.Options.BinaryAsString := False;
MyQuery.SQL.Text := 'SHOW VARIABLES';
MyQuery.Open;
ShowMessage(MyQuery.Fields[0].AsWideString);
There were no AVs when using AsWideString. Please try creating a small sample to demonstrate the problem and send it to andreyz*devart*com .

upscene
Posts: 306
Joined: Thu 19 Oct 2006 08:13

Re: Option "BinaryAsString" and MySQL 4.1

Post by upscene » Fri 17 Aug 2012 08:18

AndreyZ wrote:
OK, so it's MySQL at fault here in returning binary fields on version 4?
Yes.
When I use AsWideString on MySQL 4, it returns an AV.
I checked this question in the following environment:

Code: Select all

Delphi 2009 12.0.3170.16989 Architect
MyDAC 6.10.0.7
MySQL server version: 4.1.22-community
MySQL client version: Direct
, and used the following code:

Code: Select all

MyQuery.Options.BinaryAsString := False;
MyQuery.SQL.Text := 'SHOW VARIABLES';
MyQuery.Open;
ShowMessage(MyQuery.Fields[0].AsWideString);
There were no AVs when using AsWideString. Please try creating a small sample to demonstrate the problem and send it to andreyz*devart*com .
It seems that getting an AV depends on the actual data returned.

I've solved it differently now, checking to see if it's MySQL 4 and if it's a metadata statement of sorts.

Thanks for the explanation.

With regards,

Martijn Tonies

AndreyZ

Re: Option "BinaryAsString" and MySQL 4.1

Post by AndreyZ » Fri 17 Aug 2012 08:47

We are interested in solving of this problem, so if you reproduce it in a small test project, please send it to andreyz*devart*com . We are looking forward to receiving this project from you.

upscene
Posts: 306
Joined: Thu 19 Oct 2006 08:13

Re: Option "BinaryAsString" and MySQL 4.1

Post by upscene » Fri 17 Aug 2012 08:59

AndreyZ wrote:We are interested in solving of this problem, so if you reproduce it in a small test project, please send it to andreyz*devart*com . We are looking forward to receiving this project from you.
Try setting UseUnicode to TRUE, perhaps that makes the difference.

AndreyZ

Re: Option "BinaryAsString" and MySQL 4.1

Post by AndreyZ » Fri 17 Aug 2012 09:15

I checked this question with both UseUnicode=True and UseUnicode=False . There were no problems in both situations.

Post Reply