Page 1 of 1

Zeos Metadata

Posted: 27.02.2008, 08:21
by sandeep_c24
Hi

I am attaching following files which I have changed to get the metadata information. The changes are mostly to Firebird/Interbase unit. There are other changes to TZSQLMetadata component.

This is still work in progress but I hope to get as much information for as many databases engines as I can.

I would like someone to just keep an eye and advice me if I am doing something wrong.


Regards

Sandeep

Edit by mdaems : patch removed.

Posted: 27.02.2008, 16:22
by mdaems
This is an ambitious one... Maybe we had better done this step by step.

Did you think about behaviour when IncludeSources was false at cache creation and 'true' at next pass? I'm afraid we forgot about that... I'm not sure how we can fix it. Maybe we'll have to dig into the cache behaviour.

A question : Did you try adding the parameter 'IncludeSources' by overloading the functions? I just tried if this is possible with interfaces and it looks like it is. D5+ and FPC2.2 compile. No idea if it really works, however. If it does we don't have to change the existing GetTable/Getxxx calls. Maybe a minor issue for the components, but there might be users using it directly.

Anyhow : I didn't test it yet, but it looks like good stuff... !!

Mark

Posted: 27.02.2008, 21:16
by sandeep_c24
The sources will not be fetched if IncludeSources is set to false in first pass and then to true after that. To re-fetch the source we could call ClearCache(not sure if this is the exact name of the method but there is something as I am using it) when IncludeSource is set to True or False.

I haven't added any overloaded methods but I have added another parameter to the methods where I needed and I am passing False (IncludeSources) everywhere, so sources are not fetched by default.

There are also some changes to the SQL in GetTables for Firebird. It was getting duplicate records for Views.

Would it possible for you or anyone to run the unit tests (with the changes) and make sure everything is fine?

Sandeep

Posted: 28.02.2008, 01:25
by mdaems
Hi,

I did run the tests against firebird (embedded) and some mysql versions.
I had to change the test sources for the new parameters. Please try using overloads to avoid this. (if your tries fail we'll have to live with it, however)

The logs are attached. I didn't really check them. All differences are situated in the dbc part. Probably the tests are wrong now. Can you check?

Mark

Posted: 28.02.2008, 06:56
by sandeep_c24
Hi Mark

I think you are right I should have used overloaded methods but on second thought I think it might be alright to just change the parameters as adding a new method would require a recompile of all the ZBPLs so would adding a new parameter. If you still think an overloaded method is the way to go then I could spend sometime adding a overloaded method.

Regards

Sandeep

Posted: 28.02.2008, 08:30
by sandeep_c24
Hi

I am posting some more changes. They are
  1. Added metadata stuff for firebird exceptions.
    Fix to sql statement used for getting current sequence value in Postgres.
Regards

Sandeep

Edit by mdaems : patch removed.

Posted: 28.02.2008, 09:36
by mdaems
Try overloading, please. That way we don't have to change anything existing unless we need the new functionallity. Compiling all packages we have to do anyway.
And the coding difference is limited to the Abstract class. There the method with the old parameters just refers to the same method with the new parameters. So no double coding :!:

Posted: 28.02.2008, 10:38
by sandeep_c24
Correct me if I am wrong but if I add overloaded method I would have to move the code from method without IncludeSources parameter to the one which has IncludeSources, as we want to keep the code in one place.
This means if I use GetTables with IncludeSources in TZSQLMetadata I would have to implement 2 methods with and without IncludeSources parameter in all Z[DATABASE]Metadata files as there are other places where the method without IncludeSources is called.

This is right isn't it?

Regards

Sandeep

Posted: 28.02.2008, 15:12
by mdaems
I may be wrong, but the Z[DATABASE]Metadata objects inherit from ZAbstractMetadata -> if you implement the call without the new param there, it should work for all inheriting classes.
It compiles that way. Not 100% sure about which version of the extended function will be called.

Posted: 29.02.2008, 11:13
by sandeep_c24
Hi Mark

I am attaching the changes as you requested. GetTables and GetProcedures now have overloaded methods.

Regards

Sandeep

Edit by mdaems : patch removed.

Posted: 07.03.2008, 23:53
by sandeep_c24
Hi Mark

Have you had a chance to look at the changes I posted?

I need to add constraints to metadata and I was thinking it might be better to add mdCheckConstraints to get check constraints. What do you think of it?

Regards

Sandeep

Posted: 09.03.2008, 22:57
by mdaems
I just tried to build the sources you posted. The automatic build scripts did not show any compilation problem. I'm having trouble with the tests suite, however. Loads of AV messages. For Mysql tests and also for Firebird tests. So I'll need to investigate that further.

Concerning the constraints question. Why only check constraints? Why not "not null" constraints and "FK constraints" or what other types of constraints do exist. Or are they already available in another metadata type?
Oh... Just checked information_schema on Wikipedia. Seems like fk and check constraints are usually treated seperately. And null constraints are part of the column definitions.
Conclusion: mdCheckConstraints seems logical.

Mark

Posted: 09.03.2008, 23:42
by mdaems
I started doing some research...

First problem looks like this:

Code: Select all

function TZAdoDatabaseMetadata.GetProcedures(const Catalog: string;
  const SchemaPattern: string; const ProcedureNamePattern: string): IZResultSet;
begin
  GetProcedures(Catalog, SchemaPattern, ProcedureNamePattern, False);
end;
This should be

Code: Select all

function TZAdoDatabaseMetadata.GetProcedures(const Catalog: string;
  const SchemaPattern: string; const ProcedureNamePattern: string): IZResultSet;
begin
  result := GetProcedures(Catalog, SchemaPattern, ProcedureNamePattern, False);
end;
Second remark : You didn't have to override GetTables and GetProcedures twice for every implementation.
In every ZDbcXXXXMetadata.pas unit you only had to change the old parameter sets to the new ones. The translation from 'old' to 'new' parameter layout will be done here for all databases at once:

Code: Select all

function TZAbstractDatabaseMetadata.GetProcedures(const Catalog, SchemaPattern,
  ProcedureNamePattern: string): IZResultSet;
begin
  result := GetProcedures(Catalog, SchemaPattern, ProcedureNamePattern, False);
end;

function TZAbstractDatabaseMetadata.GetTables(const Catalog, SchemaPattern,
  TableNamePattern: string; const Types: TStringDynArray): IZResultSet;
begin
  result := GetTables(Catalog, SchemaPattern, TableNamePattern, Types, False);
end;
I attach the corrected files.

Posted: 10.03.2008, 09:19
by sandeep_c24
Thanks for that. I should have picked those.

I'll add mdCheckConstraints.

Regards

Sandeep