Stored proc and Lost connection to mysql server - workaround
Posted: 20.01.2008, 01:45
when running a stored proc with call stmt on mysql, the next statement will raise a Lost connection to mysql server error.
this is because multiple-result processing is required when calling a sp with call stmt (see http://dev.mysql.com/doc/refman/5.0/en/ ... eries.html).
zeosdbo processes only the first result so when you execute the next statement the Lost connection error occures.
test project is attached and the workaround is here (note this code doesn't really process multiple statements just the first, then loop through and ignores the others).
i tested this with ZeosDBO6.6.0 and ZeosDBO6.6.2 on MySQL5.0.45.
this is because multiple-result processing is required when calling a sp with call stmt (see http://dev.mysql.com/doc/refman/5.0/en/ ... eries.html).
zeosdbo processes only the first result so when you execute the next statement the Lost connection error occures.
test project is attached and the workaround is here (note this code doesn't really process multiple statements just the first, then loop through and ignores the others).
i tested this with ZeosDBO6.6.0 and ZeosDBO6.6.2 on MySQL5.0.45.
Code: Select all
procedure TZMySQLResultSet.Open;
var
I: Integer;
ColumnInfo: TZColumnInfo;
FieldHandle: PZMySQLField;
FieldFlags: Integer;
begin
if ResultSetConcurrency = rcUpdatable then
raise EZSQLException.Create(SLiveResultSetsAreNotSupported);
if FUseResult then
begin
FQueryHandle := FPlainDriver.UseResult(FHandle);
LastRowNo := 0;
end
else
begin
FQueryHandle := FPlainDriver.StoreResult(FHandle);
if Assigned(FQueryHandle) then
LastRowNo := FPlainDriver.GetRowCount(FQueryHandle)
else LastRowNo := 0;
end;
// +law 20080120
repeat
until FPlainDriver.RetrieveNextRowset(FHandle)<>0;
// -law 20080120
if not Assigned(FQueryHandle) then
raise EZSQLException.Create(SCanNotRetrieveResultSetData);
{ Fills the column info. }
ColumnsInfo.Clear;
for I := 0 to FPlainDriver.GetFieldCount(FQueryHandle) - 1 do
begin
FPlainDriver.SeekField(FQueryHandle, I);
FieldHandle := FPlainDriver.FetchField(FQueryHandle);
if FieldHandle = nil then
Break;
ColumnInfo := TZColumnInfo.Create;
with ColumnInfo do
begin
FieldFlags := FPlainDriver.GetFieldFlags(FieldHandle);
ColumnLabel := FPlainDriver.GetFieldName(FieldHandle);
TableName := FPlainDriver.GetFieldTable(FieldHandle);
ReadOnly := (FPlainDriver.GetFieldTable(FieldHandle) = '');
ColumnType := ConvertMySQLHandleToSQLType(FPlainDriver,
FieldHandle, FieldFlags);
ColumnDisplaySize := FPlainDriver.GetFieldLength(FieldHandle);
Precision := Max(FPlainDriver.GetFieldMaxLength(FieldHandle),
FPlainDriver.GetFieldLength(FieldHandle));
Scale := FPlainDriver.GetFieldDecimals(FieldHandle);
if (AUTO_INCREMENT_FLAG and FieldFlags <> 0)
or (TIMESTAMP_FLAG and FieldFlags <> 0) then
AutoIncrement := True;
if UNSIGNED_FLAG and FieldFlags <> 0 then
Signed := False
else Signed := True;
if NOT_NULL_FLAG and FieldFlags <> 0 then
Nullable := ntNoNulls
else Nullable := ntNullable;
// Properties not set via query results here will be fetched from table metadata.
end;
ColumnsInfo.Add(ColumnInfo);
end;
inherited Open;
end;