View Issue Details

IDProjectCategoryView StatusLast Update
0036148FPCPackagespublic2019-10-09 12:00
ReporterOndrej PokornyAssigned ToMichael Van Canneyt 
PrioritynormalSeverityminorReproducibilityhave not tried
Status resolvedResolutionreopened 
Product VersionProduct Build 
Target VersionFixed in Version3.3.1 
Summary0036148: Regression in MSSQL: transactions are not committed
DescriptionThe changes are not committed to the server.

I tried to bisect the guilty version but gave up now with the following:

42965 fail
42737 OK
Steps To Reproduceprogram MSSQLtrans;
uses
  SysUtils, MSSQLConn, SQLDB;

procedure TestCommit(const RealTest: Boolean);
var
  C: TMSSQLConnection;
  T: TSQLTransaction;
  Q: TSQLQuery;

  procedure CreateObjects;
  begin
    C := TMSSQLConnection.Create(nil);
    T := TSQLTransaction.Create(C);
    C.Transaction := T;
    C.HostName := 'ONDREJ-HP';
    C.DatabaseName := 'Aldat';
    C.Connected := True;
    Q := TSQLQuery.Create(C);
    Q.SQLConnection := C;
    Q.Transaction := T;
  end;
begin
  CreateObjects;

  Q.SQL.Text := 'CREATE TABLE testtrans (ID int)';
  Q.ExecSQL;
  Q.SQL.Text := 'INSERT INTO testtrans VALUES(1)';
  Q.ExecSQL;

  T.Commit;

  if RealTest then // recreate connection to test if the commit succeded
  begin
    C.Free;
    CreateObjects;
  end;

  Q.SQL.Text := 'SELECT * FROM testtrans';
  try
    Q.Open;
    WriteLn(Q.Fields[0].AsInteger);
  except
    on E: Exception do
      WriteLn(E.Message);
  end;
  C.Free;
end;

begin
  WriteLn('one connection&transaction:');
  TestCommit(False);

  WriteLn('split connections&transactions:');
  TestCommit(True);

  ReadLn;
end.

----

Output:
one connection&transaction:
1
split connections&transactions:
TMSSQLConnection : Error 20018 :
General SQL Server error: Check messages from the SQL Server

Invalid object name 'testtrans'.
TagsNo tags attached.
Fixed in Revision43154
FPCOldBugId
FPCTarget3.2.0
Attached Files

Relationships

child of 0035246 resolvedMichael Van Canneyt error on destroy transaction and connection 

Activities

LacaK

2019-10-09 07:16

developer   ~0118437

Yes rev. 42944 cased it.

Christian Hadi

2019-10-09 08:30

reporter   ~0118438

confirmed this also cause regression on MySQL/MariaDB,
I tracked to rev. 42944 also.

Michael Van Canneyt

2019-10-09 09:10

administrator   ~0118439

Fixed. Please test and close if OK.

LacaK

2019-10-09 11:34

developer   ~0118441

IMO same order of call must be applied also to procedure TSQLTransaction.Rollback;

Michael Van Canneyt

2019-10-09 12:00

administrator   ~0118442

You are right. Fixed in rev. 43156.

Issue History

Date Modified Username Field Change
2019-10-08 13:40 Ondrej Pokorny New Issue
2019-10-09 07:16 LacaK Note Added: 0118437
2019-10-09 07:17 LacaK Assigned To => Michael Van Canneyt
2019-10-09 07:17 LacaK Status new => assigned
2019-10-09 07:26 Ondrej Pokorny Relationship added child of 0035246
2019-10-09 08:30 Christian Hadi Note Added: 0118438
2019-10-09 09:10 Michael Van Canneyt Status assigned => resolved
2019-10-09 09:10 Michael Van Canneyt Resolution open => fixed
2019-10-09 09:10 Michael Van Canneyt Fixed in Version => 3.3.1
2019-10-09 09:10 Michael Van Canneyt Fixed in Revision => 43154
2019-10-09 09:10 Michael Van Canneyt FPCTarget => 3.2.0
2019-10-09 09:10 Michael Van Canneyt Note Added: 0118439
2019-10-09 11:34 LacaK Status resolved => feedback
2019-10-09 11:34 LacaK Resolution fixed => reopened
2019-10-09 11:34 LacaK Note Added: 0118441
2019-10-09 12:00 Michael Van Canneyt Status feedback => resolved
2019-10-09 12:00 Michael Van Canneyt Note Added: 0118442