[bug_fixed] Zeos 6.6-Beta: func GetTableNames() / PingServer

In this forum all bug reports concerning the 6.x branch will be gahtered. You have the possibility to track the bug fix process.

Moderators: EgonHugeist, mdaems

Post Reply
Paulonki
Fresh Boarder
Fresh Boarder
Posts: 8
Joined: 24.03.2006, 17:50

[bug_fixed] Zeos 6.6-Beta: func GetTableNames() / PingServer

Post by Paulonki »

This for notice following bugs:

1) Function PingServer no has result value; This crashes application when
TZConnection.Disconnect:
function TZAbstractConnection.PingServer: Integer;
begin
RaiseUnsupportedException;
end;

2) TZConnection.GetTableNames() allways return empty TString.

Regards,

Paulo
User avatar
mdaems
Zeos Project Manager
Zeos Project Manager
Posts: 2766
Joined: 20.09.2005, 15:28
Location: Brussels, Belgium
Contact:

Post by mdaems »

Concerning GetTableNames : This could be fixed in the latest SVN Build (location see portal announcement). We did changes for PostGreSQL. Is that the database you use?

Concerning PingServer: Can it be implemented for your database server? That would be best solution.
Generally : Can it be solved by putting 'result := 1' before raising the exception? (Using mysql so no problem for me...)

Mark
Paulonki
Fresh Boarder
Fresh Boarder
Posts: 8
Joined: 24.03.2006, 17:50

Post by Paulonki »

It forgives not informed my platform: Delphi 2006 with Postgresql.
How much the GetTableNames() functions, I downloaded yesterday (22/12/2006) from SVN but not yet it is functioning.
Using to advantage the chance, desire to all a Happy Christmas.

Regards

Paulo
User avatar
mdaems
Zeos Project Manager
Zeos Project Manager
Posts: 2766
Joined: 20.09.2005, 15:28
Location: Brussels, Belgium
Contact:

Post by mdaems »

Hi Paulonki,

What SVN version did you get? It's only in Testing branch yet.

Please check if this GetTables function ends like this:

Code: Select all

    if (Types = nil) or (High(Types) = 0) then
    begin
      SetLength(LTypes, 5);
      LTypes[0] := 'TABLE';
      LTypes[1] := 'VIEW';
      LTypes[2] := 'INDEX';
      LTypes[3] := 'SEQUENCE';
      LTypes[4] := 'TEMPORARY TABLE';
    end
    else
      LTypes := Types;

    SQL := SQL + ' AND c.relname LIKE ''' + EscapeQuotes(ToLikeString(TableNamePattern))
      + ''' AND (false ';
    for I := 0 to High(LTypes) do


      SQL := SQL + ' OR ( ' + TableTypeSQLExpression(LTypes[i], UseSchemas) + ' ) ';
    SQL := SQL + ' )' + OrderBy;



    Result := CopyToVirtualResultSet(
      GetConnection.CreateStatement.ExecuteQuery(SQL),
      ConstructVirtualResultSet(TableColumnsDynArray));
    AddResultSetToCache(Key, Result);
  end;
end;
Mark
User avatar
fduenas
Zeos Dev Team
Zeos Dev Team
Posts: 132
Joined: 26.08.2005, 08:12
Location: Cancún

Post by fduenas »

Hi Mark, about PingServer Solution i think setting 'result := 1' can be the best solution for databases that doesn't implement yet PinServer functionality.

But something we have to be sure is what result does MySQL Ping functions returns if Pinging server is successfully, don't remember if it is 1 or 0.
User avatar
mdaems
Zeos Project Manager
Zeos Project Manager
Posts: 2766
Joined: 20.09.2005, 15:28
Location: Brussels, Belgium
Contact:

Post by mdaems »

0=successfull.

Can we still raise the 'unsupported' exception AND returning the function value? I don't think that makes sense.
And in my opinion we should only return a correct value if we do not raise an exception.

Do you know how current situation could crash the application? I think Paulonki should use a 'try...exception...' block when he does not know the protocol used and wants to call Pingserver when possible. So he can react to the event of the nonsupported call. The call itself doesn't change anything to the status of the Connection component when it fails. I don't understand how that could cause an error in the zeos components.

Paulonki, can you create (and eventually sent) a sample program only doing the ping which causes the error?

Mark

Mark
User avatar
fduenas
Zeos Dev Team
Zeos Dev Team
Posts: 132
Joined: 26.08.2005, 08:12
Location: Cancún

Post by fduenas »

Well I think it would only return a value and not an exception, coz i think this function cxan be used later internally in zeoslib components.

One important thing where we can add the PingServer a similar TestConnection function that can resume a connection if it is lost. Currently, for example, if mysql is shutted down and there is connection of zeoslib, when zeoslib connection tries to send a query or retreive data it will send a mysql connection errror, and there is no way, in an application, that w ecan resume or try to reconnect after this error. maybe we can add an event to tzconnection that can be called before tzconnection sends or retreives a query or resultset so we can manage that if there is an error we can tell zeoslib to resume the connection, like libmysql does.
Paulonki
Fresh Boarder
Fresh Boarder
Posts: 8
Joined: 24.03.2006, 17:50

Post by Paulonki »

Hello,

They forgive me for the delay in answering.
I am getting the Zeos in the address svn: /firmos.at/zeos/trunk.
The source of GetTableNames is:

procedure TZConnection.GetTableNames(const Pattern: string; List: TStrings);
var
Metadata: IZDatabaseMetadata;
ResultSet: IZResultSet;
begin
CheckConnected;
List.Clear;
Metadata := DbcConnection.GetMetadata;
ResultSet := Metadata.GetTables('', '', Pattern, nil);
while ResultSet.Next do
List.Add(ResultSet.GetStringByName('TABLE_NAME'));
end;

About crashing (not only my application, but delphi too).
First receive the message:
"SQL Error: could not transalate host name 'port=5432' to address: unkown host".
This is occurring since that I started to test the FastMM4 that report that a virtual method was called afther the destruction the component (disconnect) and alone I obtained to monitor until the function to pingserver ().

Regards,

Paulonki
User avatar
mdaems
Zeos Project Manager
Zeos Project Manager
Posts: 2766
Joined: 20.09.2005, 15:28
Location: Brussels, Belgium
Contact:

Post by mdaems »

Hi Paulonki,

I was refering to the Metadata.GetTables function. Never mind. As you use the trunk version, the latest bugfix is not in there yet. Just use the file in attach instead of yours. Can you confirm it works?

Mark
You do not have the required permissions to view the files attached to this post.
Paulonki
Fresh Boarder
Fresh Boarder
Posts: 8
Joined: 24.03.2006, 17:50

Post by Paulonki »

Mark

Excuse me but I am leaving vacation and I am very busy and without time to make the tests.
It seems that the ZSQLMetadata component is functioning well with new archive.
I promise to test more when to come back.

Happy 2007!!!

With best regards

Paulonki
Post Reply