Page 1 of 1

GetCatalogNames bug

Posted: 08.06.2009, 08:36
by magrossi
Hello,

I'm doing an app that needs to delete, duplicate and move a few databases around. It is working as it should but unnexpectedly I started to see a few weird behaviour in my program. I traced them down to the GetCatalogNames function.
This function always returns the same thing after you've done it once even if you use the .Reconnect procedure. It only gets the new data after a .Disconnect followed by a .Connect (was't this what reconnect was supposed to do?).
So basically, in my opinion, this functions behaviour is wrong to everyone using a persistent connection to a database. Suggested solution as follows:

Function GetCatalogs from ZDbcMetadata.pas file, line 2220.

Code: Select all

function TZAbstractDatabaseMetadata.GetCatalogs%u3a IZResultSet;
//var
//  Key%u3a string;
begin
//  Key %u3a= GetCatalogsCacheKey;

//  Result %u3a= GetResultSetFromCache%u28Key%u29;
//  if Result = nil then
//  begin
    Result %u3a= UncachedGetCatalogs;
//    AddResultSetToCache%u28Key, Result%u29;
//  end;
end;
Just commenting out the cached results should do the trick. Or another GetUnchachedCatalogNames could also resolve the issue. Or perhaps a GetCachedCatalogNames would be best since this is not the expected behaviour.

Thank you,

Posted: 16.06.2009, 12:42
by mdaems
Did you look for a way to clean the cache? Not sure if it's possible yet. (guess I could search for a ay to do it myself, but I have not time to do it now.)
If not, you should try to write a way to clean the cache. It's a feature I will certainly add to the zeoslib library.

Just disabling it doesn't seem a good solution to me, but If you can add a connection option that (cleanly) disables metadata caching, I'm also positive for inclusion. I don't think it's that difficult, but we need a developer who wants to spend some time to implment and test it.

Mark

Posted: 22.06.2009, 16:27
by magrossi
As much as I think that a command to clear the cache is useful and don't think it should be used in this case. The GetCatalogs functions should always be up-to-date unless specifically told not to.
Something like a property "UseCachedCatalogs" should do the trick. I say this because I think that when someone not familiar with the inner-workings of the component should be confident at all times that the GetCatalogs functions returns the same as a mysql "show databases;" command..
If the user wants other behaviour it should be set by using either properties or an extra optional parameter like:

.. GetCatalogNames(UseCachedMetadata : Boolean = False) ..

I would love to help but as yourself I'm totally without time...even breathing is hard nowadays :(

Thank you very much for your consideration!