[patch_done] Patch for TZGenericStatementAnalyser

Code patches written by our users to solve certain "problems" that were not solved, yet.

Moderators: gto, cipto_kh, EgonHugeist, mdaems

Post Reply
Ostfriese
Junior Boarder
Junior Boarder
Posts: 25
Joined: 12.05.2009, 10:48
Location: Coburg
Contact:

[patch_done] Patch for TZGenericStatementAnalyser

Post by Ostfriese »

The Delphi compiler throws a compiler hint for FillTableRefs beause CurrentType is never used in one case. So I modified the procedure to remove this hint

Code: Select all

procedure TZGenericStatementAnalyser.FillTableRefs(
  SelectSchema: IZSelectSchema; FromTokens: TStrings);
var
  TokenIndex: Integer;
  Catalog: string;
  Schema: string;
  Table: string;
  Alias: string;
  CurrentValue: string;
  CurrentType: TZTokenType;
  CurrentUpper: string;
  ReadTable: Boolean;

  procedure ClearElements;
  begin
    Catalog := '';
    Schema := '';
    Table := '';
    Alias := '';
    ReadTable := True;
  end;

begin
  TokenIndex := 1;

  ClearElements;
  while TokenIndex < FromTokens.Count do
  begin
    CurrentValue := FromTokens[TokenIndex];
    CurrentUpper := AnsiUpperCase(CurrentValue);
    CurrentType := TZTokenType({$IFDEF FPC}Pointer({$ENDIF}
      FromTokens.Objects[TokenIndex]{$IFDEF FPC}){$ENDIF});

    { Processes from join keywords. }
    if FromJoins.IndexOf(CurrentUpper) >= 0 then
    begin
      if Table <> '' then
        SelectSchema.AddTable(TZTableRef.Create(Catalog, Schema, Table, Alias));
      ClearElements;
      SkipOptionTokens(FromTokens, TokenIndex, FromJoins);
      Continue;
    end
    { Skips from clause keywords. }
    else if FromClauses.IndexOf(CurrentUpper) >= 0 then
    begin
      Inc(TokenIndex);
      while (TokenIndex < FromTokens.Count)
        and (FromJoins.IndexOf(CurrentUpper) < 0) and (CurrentUpper <> ',') do
      begin
        CurrentValue := FromTokens[TokenIndex];
        CurrentUpper := AnsiUpperCase(CurrentValue);
        //HA 090515 comment out because never used in this case ..
        //CurrentType := TZTokenType({$IFDEF FPC}Pointer({$ENDIF}
        //FromTokens.Objects[TokenIndex]{$IFDEF FPC}){$ENDIF});
        //..
        if CurrentUpper = '(' then
          SkipBracketTokens(FromTokens, TokenIndex)
        else Inc(TokenIndex);
      end;
    end
    { Switches to alias part. }
    else if (CurrentType = ttWhitespace) or (CurrentUpper = 'AS') then
    begin
      ReadTable := ReadTable and (Table = '') and (CurrentUpper <> 'AS');
    end
    { Reads table. }
    else if ReadTable and ((CurrentType = ttWord) or (CurrentType = ttQuotedIdentifier)) then
    begin
      Catalog := Schema;
      Schema := Table;
      Table := CurrentValue;
    end
    { Skips a '.' in table part. }
    else if ReadTable and (CurrentValue = '.') then
    begin
    end
    { Reads alias. }
    else if not ReadTable and (CurrentType = ttWord) then
    begin
      Alias := CurrentValue;
    end;
    { Ends field reading. }
    if CurrentValue = ',' then
    begin
      if Table <> '' then
        SelectSchema.AddTable(TZTableRef.Create(Catalog, Schema, Table, Alias));
      ClearElements;
    end;
    { Skips till the next field. }
    if CurrentValue = '(' then
      SkipBracketTokens(FromTokens, TokenIndex)
    else Inc(TokenIndex);
  end;

  { Creates a reference to the last processed field. }
  if Table <> '' then
    SelectSchema.AddTable(TZTableRef.Create(Catalog, Schema, Table, Alias));
end;
Thomas Jefferson wrote:Information ist die Währung der Demokratie
User avatar
mdaems
Zeos Project Manager
Zeos Project Manager
Posts: 2766
Joined: 20.09.2005, 15:28
Location: Brussels, Belgium
Contact:

Post by mdaems »

Seems like this one is also in 6.6-patches. See http://fisheye2.atlassian.com/changelog/zeos?cs=512

Mark
Image
Post Reply