Page 1 of 1

autocommit

Posted: 29.01.2007, 05:34
by dhongu
In unit ZPlainMySQLDriver.pas function "TZMySQL40PlainDriver.SetAutocommit" is incorrect


[syntax="delphi"]
function TZMySQL40PlainDriver.SetAutocommit(Handle: PZMySQLConnect; mode: Boolean): Boolean;
var
query: AnsiString;
testResult: Integer;
begin
if (mode = True) then
query := 'AUTOCOMMIT=1'
else
query := 'AUTOCOMMIT=0';
testResult := MYSQL_API.mysql_query(ZPlainMySql40.PMYSQL(Handle),pchar(query));
Result := (testResult = 0);
end;
[/syntax]

Correct is

[syntax="delphi"]
function TZMySQL40PlainDriver.SetAutocommit(Handle: PZMySQLConnect; mode: Boolean): Boolean;
var
query: AnsiString;
testResult: Integer;
begin
if (mode = True) then
query := 'SET AUTOCOMMIT=1' // Add SET
else
query := 'SET AUTOCOMMIT=0'; // Add SET
testResult := MYSQL_API.mysql_query(ZPlainMySql40.PMYSQL(Handle),pchar(query));
Result := (testResult = 0);
end;
[/syntax]

Posted: 29.01.2007, 09:02
by mdaems
Hi Dorin,

Thanks for this report. Does this missing 'Set' cause the function call to fail? As far as I remember it always was without SET and this is the first complaint. For mysql versions 4.1 and up we use a direct library call.

Well, I'll change it like you said. Should it also be changed for mysql3.xx?

Can you please file new bugs in the bug tracker?

Mark

Posted: 29.01.2007, 09:22
by dhongu
Always was without SET but function never call.


Old procedure not call FPlaindriver.SetAutocommit

[syntax="delphi"]
procedure TZMySQLConnection.SetAutoCommit(AutoCommit: Boolean);
var
SQL: PChar;
begin
if AutoCommit <> Self.AutoCommit then
begin
inherited SetAutoCommit(AutoCommit);

if not Closed then
begin
if AutoCommit then
SQL := 'SET AUTOCOMMIT=1'
else SQL := 'SET AUTOCOMMIT=0';
FPlainDriver.ExecQuery(FHandle, SQL);
CheckMySQLError(FPlainDriver, FHandle, lcExecute, SQL);
DriverManager.LogMessage(lcExecute, FPlainDriver.GetProtocol, SQL);
end;
end;
end;

[/syntax]

new procedure call FPlaindriver.SetAutocommit

[syntax="delphi"]
procedure TZMySQLConnection.SetAutoCommit(AutoCommit: Boolean);
begin
if AutoCommit <> Self.AutoCommit then
begin
inherited SetAutoCommit(AutoCommit);

if not Closed then
begin
if not FPlaindriver.SetAutocommit(FHandle, AutoCommit) then
CheckMySQLError(FPlainDriver, FHandle, lcExecute, 'Native SetAutoCommit '+BoolToStrEx(AutoCommit)+'call');
DriverManager.LogMessage(lcExecute, FPlainDriver.GetProtocol, 'Native SetAutoCommit '+BoolToStrEx(AutoCommit)+'call');
end;
end;
end;

[/syntax]

Posted: 29.01.2007, 10:49
by mdaems
So I did this :mrgreen:
Thanks for finding the bug...

Mark

Posted: 01.02.2007, 00:00
by mdaems
Dorin,

The changes has been done for all mysql versions until 4.0. See SVN Testing revision 213.

Mark