Repository navigation
Open
Description
On the UniDAC adapter, index descriptions fail for every engine without an IndexInfoTemplate, SQLite among them, and TBoldUniDACTable never frees the TUniTable it wraps. Found while adding the UniDAC twin of the evolutor tests for #112.
Symptom
- On UniDAC with SQLite (
dbeGenericANSISQL92), everyIBoldDatabase.GetIndexDescriptionscall raisesTBoldUniDACTable.GetIndexDefs: not supported/implemented. The database evolutor (TBoldDataBaseEvolutor.CalculateScript) and the structure validator's index check cannot run there. - After such a run, FastMM reports the internals of a
TUniTableas leaked (TFieldDefs,TUniDataSetOptions,TUniParams, ...).
On UniDAC with SQL Server and PostgreSQL the same tests pass: those engines have an IndexInfoTemplate and never reach the table path.
Root cause
TBoldDatabaseWrapper.GetIndexDescriptions(Source/Persistence/DB/BoldDBInterfaces.pas) falls back toGetIndexDescriptionsViaTablewhenSQLDatabaseConfig.IndexInfoTemplateis empty. That readsIBoldTable.IndexDefs, andTBoldUniDACTable.GetIndexDefs(Source/Persistence/UniDAC/BoldUniDACInterfaces.pas) raisesEBoldunconditionally. On FireDAC the same fallback works throughTFDTable.IndexDefs.TBoldUniDACTablehas no destructor.TBoldUniDACConnection.GetTablecreates itsTUniTablewithout an owner, so neitherReleaseTable(when the cache is occupied) norReleaseCachedObjectsfrees the dataset when it frees the wrapper.TBoldFireDACTable.Destroyfrees itsTFDTable.
Change
- TBoldUniDACTable: a destructor frees the wrapped
TUniTable, likeTBoldFireDACTable. - Index descriptions on SQLite:
TBoldUniDACConnectionoverridesGetIndexDescriptions. On the SQLite provider without anIndexInfoTemplateit readspragma_index_listandpragma_index_info(UniDAC datasets have noIndexDefs, so implementingGetIndexDefswould have meant building them from metadata). The index with originpkis the primary key. AnINTEGER PRIMARY KEYhas no index (it is the rowid alias), so it is added frompragma_table_infounder the constraint name insqlite_master, as SQLite: Bold sees no primary key, so evolve re-plans the BOLD_ID indexes and cannot move data #110 does on FireDAC. - Other UniDAC providers without an
IndexInfoTemplatekeep the table path and still raise inGetIndexDefs, as before.
Commit: 0426f46
Testing
-
Test.BoldDbEvolutorUniDAC(Run the test suite on PostgreSQL in run_matrix.ps1 (UniDAC first) #112) green on UniDAC x SQLite: 5/5 with UniDAC 11.0.1. The early pass that named this issue is gone. - No leak: the new
TestFreedTablesFreeTheirTUniTablefrees table wrappers both ways (ReleaseTablewith an occupied cache,ReleaseCachedObjects) and failed before the fix with 4 leakedTUniTables. Matrix green: FireDAC 2224 on SQLite and SQL Server; UniDAC 2243 on SQLite and SQL Server with-UniDACFull; UniDAC x PostgreSQL 19; vendored UniDAC 10.4 on Delphi 12 green as well.
Metadata
Metadata
Assignees
Labels
No labels
Activity
Add a UniDAC x PostgreSQL row to the test matrix #112
Free the UniDAC table and read SQLite indexes on UniDAC #116