You are not logged in.
Hello,
today I have encountered a very obscure problem. The way a TDynArrayHashed is used in a TSQLDBZeosStatement a malfunction can be triggered in the fColumn.AddAndMakeUniqueName() method. The array is re-inited with just:
fColumnCount := 0;
fColumn.ReHash;
That works fine, but it leaves the fHashFindCount property unchanged, thus it raises further and after several tries with a query of eleven columns it crashes.
If I am correct the cause is a hit of the condition and reset of the fHashCounterTrigger property to zero in TDynArrayHashed.FindHashed() method (the code using the query is fetching values by the names of the columns). The core of the problem lies in the first call to the AddAndMakeUniqueName() method on a statement re-used after the fHashCounterTrigger was set to zero. The TDynArrayHashed.HashAdd does a ReHash (which effectively sets fHashs to nil for an empty array) and tries to write a hash to fHashs afterwards. Also, the Assert() in TDynArrayHashed.HashAdd() is hit, because ReHash clears hash and the following HashFind() finds the column (the data remained there, the Count was already incremented, search goes without a hash).
Either the fHashCounterTrigger should not be set to zero, or the ReHash should be able to prepare fHashs even for an empty array (perhaps calling it from HashAdd() with forAdd = True ?).
Best regards,
Joe
Offline
I have tried it now, but unfortunately it makes no difference.
Offline
Hello,
after some experimenting I have found out that, it works correctly if I modify the TDynArrayHashed.HashAdd() method in SynCommons.pas:
...
dec(fCountP^); // ignore latest entry (which is not filled yet)
--- ReHash;
+++ ReHash(True);
if fCountP<>nil then
...
Best regards,
Joe
Offline