I run tests using the dbXpress SQLite and MySQL driver (XE3), and your code just leaks using SQLite (also get a double exception in debug mode), but it is not with MySQL .
IMHO is a bug that should be reported in QC.
Stack trace when the first exception occurs in the debugger
:769cc41f KERNELBASE.RaiseException + 0x58 Data.DBXCommon.TDBXContext.Error(???,'column title is not unique') Data.DbxSqlite.CheckError(19,???,$2F12738) Data.DbxSqlite.TDBXSqliteCommand.DerivedExecuteQuery Data.DBXCommon.TDBXCommand.ExecuteQuery Data.DBXCommon.TDBXMorphicCommand.ExecuteQuery Data.SqlExpr.TCustomSQLDataSet.ExecuteStatement Data.SqlExpr.TCustomSQLDataSet.ExecSQL(???) Data.SqlExpr.TSQLQuery.ExecSQL(???) Main_ViewU.TForm1.RunQuery($2E7B870,'Title',10) Main_ViewU.TForm1.Button1Click($2E85AD0)
Stack trace when a second error occurs in the debugger
:769cc41f KERNELBASE.RaiseException + 0x58 // <-- Exception interrupts Destroy Data.DBXCommon.TDBXContext.Error(???,'column title is not unique') Data.DbxSqlite.CheckError(19,???,$2F12738) Data.DbxSqlite.TDBXSqliteCommand.DerivedClose Data.DBXCommon.TDBXCommand.Close Data.DBXCommon.TDBXMorphicCommand.DerivedClose Data.DBXCommon.TDBXCommand.Close Data.DBXCommon.TDBXCommand.Destroy // <-- DESTROY Data.DBXCommon.TDBXMorphicCommand.Destroy // <-- DESTROY System.TObject.Free Data.SqlExpr.TCustomSQLDataSet.CloseStatement Data.SqlExpr.TCustomSQLDataSet.InternalFreeCommand Data.SqlExpr.TCustomSQLDataSet.FreeCommand Data.SqlExpr.TCustomSQLDataSet.ExecSQL(???) Data.SqlExpr.TSQLQuery.ExecSQL(???) Main_ViewU.TForm1.RunQuery($2E7B870,'Title',10) Main_ViewU.TForm1.Button1Click($2E85AD0)
And this causes a memory leak ...
source share