Bug #43981 After MyODBC reconnects to MySQL server it forgots to execute initial statement
Submitted: 31 Mar 2009 11:27 Modified: 7 Apr 2009 17:02
Reporter: Eugene Maliavskyy Email Updates:
Status: Closed Impact on me:
None 
Category:Connector / ODBC Severity:S2 (Serious)
Version:3.51.27 OS:Windows
Assigned to: Tony Bedford CPU Architecture:Any
Tags: reconnect, SET NAMES

[31 Mar 2009 11:27] Eugene Maliavskyy
Description:
I use Delphi (BDS) and ADO to connect to MySQL Server through mysql-connector-odbc-3.51.27.

The following connection string is used:

DATABASE=mydatabase;DRIVER={MySQL ODBC 3.51 Driver};OPTION=4194304;PWD=****;PORT=3306;SERVER=195.138.198.130;STMT=set names cp1251;UID=user;

The word "OPTION=4194304" in connection string means that "enable auto reconnect" option is turned on in advanced tab of ODBC driver dialog.

Program connects to server and works fine. But after connection is lost and odbc driver reconnects automatically, all cyrillic symbols returned from server is replaced with '?' character

How to repeat:
1. Connect program to MySQL server with "enable auto reconnect" option turned on and initial statement "set names cp1251".
2. Force program to lose connection (for example disable and enable lan)
3. Execute some statement that should return cp1251 string.

Suggested fix:
ODBC driver should execute initial statement again after connection is lost
[7 Apr 2009 1:47] Jess Balint
Auto-reconnect is implemented in the MySQL client library which is incorporated into the ODBC driver. The initial statement execution is implemented in the driver itself. Due to the way these two options work, we will not support initial statement being executed at any time besides the initial connection. Unfortunately, we have no plan to fix this.
[7 Apr 2009 17:02] Tony Bedford
The main documentation has been updated with an appropriate note.