Dataset SQLQuery crash on "IndexFieldNames"
Original Reporter info from Mantis: JoshyFun @joshyfun
-
Reporter name: José Mejuto
Original Reporter info from Mantis: JoshyFun @joshyfun
- Reporter name: José Mejuto
Description:
When using IndexFieldNames to alter the order of a read dataset the program will crash with a SIGSEGV.
Steps to reproduce:
Run attached project (It is a Lazarus one as it is quite difficult to me to create a pure fpc project for databases). Adjust the connection to any existing database and maybe the SQL command to fetch a bunch of records and press any DBGrid column to order data by that field.
Only strictly necessary fields has been configured. The same problem appears with any database access, in the example I'm using Firebird.
Additional information:
The problem seems to be in the TBufDataset.BuildIndex as the merge sort used does not reserve any additional space for the new list which from my point of view is mandatory in a merge sort. Also I had checked the referenced document (web page) and it also states that a temporal intermediate storage is needed, but in a non clear text, in fact in a paragraph he says something "[...] It avoids the need for the auxiliary space [...]" and a few lines below he says "[...] and also preparing an empty list L [...]" which denotes the need of an auxiliary space for the newly ordered list.
The prior-next releation seems to be broken after indexing, or if there are enought records just in the sort process. I was trying to fix it myself but the code is quite complex to understand and as I must recompile the compiler and lazarus lcl each time, and some problems with debugger converts it in a nightmare :( I think a more trained eyes will fix it in a "short" time.