autocommit

Forum related to version 6.5.1 (alpha) and 6.6.x (beta) of ZeosLib's DBOs

Moderators: gto, cipto_kh, EgonHugeist

Post Reply
User avatar
dhongu
Junior Boarder
Junior Boarder
Posts: 37
Joined: 28.09.2005, 08:37
Location: Bucuresti
Contact:

autocommit

Post 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]
Dorin Hongu
User avatar
mdaems
Zeos Project Manager
Zeos Project Manager
Posts: 2766
Joined: 20.09.2005, 15:28
Location: Brussels, Belgium
Contact:

Post 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
User avatar
dhongu
Junior Boarder
Junior Boarder
Posts: 37
Joined: 28.09.2005, 08:37
Location: Bucuresti
Contact:

Post 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]
Dorin Hongu
User avatar
mdaems
Zeos Project Manager
Zeos Project Manager
Posts: 2766
Joined: 20.09.2005, 15:28
Location: Brussels, Belgium
Contact:

Post by mdaems »

So I did this :mrgreen:
Thanks for finding the bug...

Mark
User avatar
mdaems
Zeos Project Manager
Zeos Project Manager
Posts: 2766
Joined: 20.09.2005, 15:28
Location: Brussels, Belgium
Contact:

Post by mdaems »

Dorin,

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

Mark
Post Reply