Page 1 of 1

[patch_done] Patch for TZGenericStatementAnalyser

Posted: 15.05.2009, 12:53
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;

Posted: 20.05.2009, 21:22
by mdaems
Seems like this one is also in 6.6-patches. See http://fisheye2.atlassian.com/changelog/zeos?cs=512

Mark