Bug #23579 Borland BDE: EAccess violation when running a SELECT
Submitted: 24 Oct 2006 10:51 Modified: 4 Jan 2008 9:39
Reporter: Herminio Gonzalez Email Updates:
Status: Closed Impact on me:
None 
Category:Connector / ODBC Severity:S2 (Serious)
Version:5.1 OS:Windows (WinXP SP2)
Assigned to: Jess Balint CPU Architecture:Any
Tags: BDE, Borland, EAccess Violation, MyODBC, ODBC5-RC, SELECT

[24 Oct 2006 10:51] Herminio Gonzalez
Description:
When attempting to run "SELECT * FROM tablename", an EAccess violation is caused in the BDE client program.

No errors appear in the server log.

This error does not happen on MyODBC 3.51 and MyODBC 2.5.x

This error was tested on another in-house BDE application and the same error occurred. The error was found to occur when calling the member function Open() of a TQuery object. (TQuery is a VCL class. VCL is part of Delphi/C++Builder)

How to repeat:
MySQL Server version 5.0.22 for Win32 (on Windows XP SP2)
Client: Borland Database Explorer (comes with C++ Builder, various versions)

(The Borland Database Explorer client uses Borland's BDE library to access an ODBC DSN)

- Create a DSN
- Open Database Explorer
- Open the DSN
- Submit SQL "SELECT * FROM tablename"
- EAccess violation appears, program aborts.

NOTE: executing "SELECT 'abc'" does not cause an error and works as expected.
[24 Oct 2006 14:13] Tonci Grgin
Hi Herminio and thanks for your problem report.
I was able to verify it as you described with dbExplorer that comes with Delphi6.
Indeed, making an alias does not help but what you missed is that "simple SELECT 'abc'" does not produce correct result! Try SELECT (1+2) AS a and see what you will get.
After first execution BDE is likely to throw an error of itself. But, after issuing query for several times in a row, Access violation might happen in connector/ODBC 5 driver crashing dbExplorer too.
In conclusion, no matter how I like Borland, please use MS generic ODBC client (odbct32w.exe [UC] or odbct32.exe) since it works without problems.
However I'll set this report to "Verified" but don't think MySQL can fix it.
[24 Oct 2006 20:52] Tonci Grgin
Borland dbExplorer crash with beta 5 DM log

Attachment: BDE-SQLlog.zip (application/x-zip-compressed, text), 13.46 KiB.

[19 Dec 2007 10:42] Tonci Grgin
DM trace, D7, MyODBC 5.1.2 (18.12.2007.)

Attachment: SQL.zip (application/zip, text), 1.68 KiB.

[19 Dec 2007 10:44] Tonci Grgin
Testing with WinXP in VM running D7 I get immediate crash of DBExplorer with latest MyODBC 5.1.2 version... As VM is not set for debugging (yet) I can't provide more info.
[4 Jan 2008 7:20] Jess Balint
Tonci,
Please test again with 5.1 svn r980 or above. The fix for bug#33130 has been committed which caused the crash.
[4 Jan 2008 9:39] Tonci Grgin
Thank you for your bug report. This issue has been committed to our source repository of that product and will be incorporated into the next release.

If necessary, you can access the source repository and build the latest available version, including the bug fix. More information about accessing the source trees is available at

    http://dev.mysql.com/doc/en/installing-source.html

Explanation: Being huge Borland fan I am more than happy to announce that testing with latest c/ODBC version (rev.986 win32) fixes the problem reported:
 - MySQL server 5.0.54BK on WinXP Pro SP2 localhost
 - CodeGear Delphi2007, dbexplorer v. 11.0.2627.5503, DataExplorer v. 11.0.2627.5503

Now for details:
 1) I have found the problem with several tables I tested, getting BDE error 8712. For example:
mysql> show create table a;
+-------+-------------+
| Table | Create Table|
+-------+-------------+
| a     | CREATE TABLE `a` (
  `id` int(10) unsigned NOT NULL auto_increment,
  `name` varchar(30) default NULL,
  PRIMARY KEY  (`id`)
) ENGINE=MyISAM AUTO_INCREMENT=31 DEFAULT CHARSET=utf8 |
+-------+----------------------------------------------+
1 row in set (0.00 sec)

mysql> check table a;
+--------+-------+----------+----------+
| Table  | Op    | Msg_type | Msg_text |
+--------+-------+----------+----------+
| test.a | check | status   | OK       |
+--------+-------+----------+----------+
1 row in set (0.08 sec)
This does not concern me as 8712 is a notorious BDE error before contacting ODBC driver.

 2) Same error but on Field level:
mysql> select * from bug27862;
+----+---------------------+---------------------------+
| Id | Str1                | Str2                      |
+----+---------------------+---------------------------+
|  1 | InsuranceArmstrong  | & Quaile Insurance Agency |
|  2 | RegularArmstrong &  | Quaile Associates Inc.    |
+----+---------------------+---------------------------+
2 rows in set (0.00 sec)

mysql> show create table bug27862;
+----------+-------------+
| Table    | Create Table|                                                                 +----------+-------------+
| bug27862 | CREATE TABLE `bug27862` (
  `Id` int(10) unsigned NOT NULL auto_increment,
  `Str1` varchar(50) NOT NULL,
  `Str2` varchar(50) NOT NULL,
  PRIMARY KEY  (`Id`)
) ENGINE=MyISAM AUTO_INCREMENT=3 DEFAULT CHARSET=utf8 |
+----------+------------------------------------------+
1 row in set (0.00 sec)

Now, the only thing I can think of is that dbExplorer has issues with UTF-8 (or MBCS in general) as I see no other difference between working/non-working tables. However, new DataExplorer has no such problems.