Bug #27544 Calling stored procedure causes "Out of sync" and "Lost connection" errors
Submitted: 30 Mar 2007 10:01 Modified: 12 Jun 2007 10:26
Reporter: Bogdan Degtyariov Email Updates:
Status: Closed Impact on me:
Category:Connector / ODBC Severity:S2 (Serious)
Version:3.51 OS:Microsoft Windows
Assigned to: Georg Richter CPU Architecture:Any
Tags: ODBC, stored procedure, VB

[30 Mar 2007 10:01] Bogdan Degtyariov
When executing a select command or a stored procedure call AFTER making a stored procedure call the second execute fails. 

How to repeat:
DROP TABLE IF EXISTS `general_config`;
CREATE TABLE `general_config` (
  `id` int(11) NOT NULL auto_increment,
  `namecol` varchar(128) default NULL,
  `dt` datetime default NULL,
  PRIMARY KEY  (`id`)

INSERT INTO `general_config` VALUES (1,'name 01','2007-03-29 11:19:30'),(2,'name 02','2007-03-30 01:01:01');

CREATE PROCEDURE `sp_general_config_list`()
SELECT * from general_config;

CREATE PROCEDURE `sp_general_config_cats_list`()
SELECT * from general_config;

Run the following VB code:
Sub issue15561()
On Error GoTo TestMySQL_Error
Dim strCnn As String
Dim cnn As ADODB.Connection
Dim RS As ADODB.Recordset
Set cnn = New ADODB.Connection
Set RS = New ADODB.Recordset

strCnn = "Driver={MySQL ODBC 3.51 Driver};Server=localhost;Database=test;User=****;Password=****;Option=131075;"
cnn.CommandTimeout = 20
cnn.CursorLocation = adUseServer
cnn.Open strCnn

RS.Open "call sp_general_config_list();", cnn, adOpenForwardOnly, adLockReadOnly

Start = Timer ' Set start time.
Do While Timer < Start + 10
DoEvents ' Yield to other processes.

RS.Open "call sp_general_config_cats_list();", cnn, adOpenForwardOnly, adLockReadOnly
Exit Sub

MsgBox "Error " & err.Description

End Sub
[11 Jun 2007 13:02] Georg Richter
Fix for SQLFreeStmt: clear multi result sets

Attachment: bug27544.patch (text/x-patch), 1.64 KiB.

[11 Jun 2007 13:59] Bogdan Degtyariov
Verified on 3.51.14/3.51.15
This bug is not present in 3.51.12
[11 Jun 2007 16:12] Jim Winstead
Some things to fix in the patch before committing:

* Add space after while in addiion to driver/handle.c
* Remvoe space before = in driver/handle.c
* Two blank lines before/after new test
* Add header before test (see below)
* Use ok_sql() instead of tmysql_exec()/mystmt(). Also eliminates need for SQLRETURN rc.

 Bug #27544: Calling stored procedure causes "Out of sync" and "Lost connection" errors
[11 Jun 2007 17:06] Georg Richter
committed, will appear in 3.51.16
[12 Jun 2007 10:26] MC Brown
A note has been added to the 3.51.16 changelog.