Jump to content
Zdeněk Hanuš

TIBSQLMonitor truncates the result in the "EventText" event "OnSQL"

Recommended Posts

Hello,
I use IBX to connect to Firebird 3.0. If I monitor communication with the server using the TIBSQLMonitor component, the monitor truncates the text "EventText" in the "OnSQL" event for longer commands to some 506 characters. The remaining characters are just the character #0.

Has anyone solved it?

I have Delphi 10.3.3 and Delphi 10.4.2 and the bug is in both.
I was looking for a bug and I think I found it, but I'm not able to "beat" the system package.

Thank you for your help.

Share this post


Link to post

Hello,

If you fix the bug in original files (C:\Program Files (x86)\Embarcadero\Studio\21.0\source\IBX\IBX.IBSQLMonitor.pas?), it should be enough to add this file to your project and rebuild the project.

Kind regards,

Karel

 

Share this post


Link to post
5 hours ago, Vandrovnik said:

If you fix the bug in original files (C:\Program Files (x86)\Embarcadero\Studio\21.0\source\IBX\IBX.IBSQLMonitor.pas?), it should be enough to add this file to your project and rebuild the project.

Yes. It works. How simple. Thank you very much.

Zdeněk

Edited by Zdeněk Hanuš

Share this post


Link to post

Hello, I modified these two methods. The problem was that Char is no longer 1 byte, but 2 bytes.

The fixes are between "// Start of fix" and "// End of fix".

procedure TWriterThread.WriteToBuffer;
var
  i, len, Step: Integer;
  Text : String;
begin
  Lock;
  try
    { If there are no monitors throw out the message
      The alternative is to have messages queue up until a
      monitor is ready.}

    if FMonitorCount^ = 0 then
    begin
      CS.BeginWrite;
      FMsgs.Remove(FMsgs[0]);
      CS.EndWrite;
    end
    else
    begin
      Text := TTraceObject(FMsgs[0]).FMsg;
      i := 1;
      len := Length(Text);
      while (len > 0) do begin
        BeginWrite;
        try
          FillChar(FBuffer[0], cMaxBufferSize, #0);   // Clear the buffer of previous data
          FTraceDataType^ := Integer(TTraceObject(FMsgs[0]).FDataType);
          FTimeStamp^ := TTraceObject(FMsgs[0]).FTimeStamp;
          FBufferSize^ := Min(len * Sizeof(Char), cMaxBufferSize);
          Move(Text[i], FBuffer[0], FBufferSize^);
          // Start of fix
          Step := cMaxBufferSize div SizeOf(Char);
          Inc(i, Step);  //Inc(i, cMaxBufferSize);
          Dec(len, Step);  //Dec(len, cMaxBufferSize);
          // End of fix
        finally
          EndWrite;
        end;
      end;
      CS.BeginWrite;
      FMsgs.Remove(FMsgs[0]);
      CS.EndWrite;
    end;
  finally
    Unlock;
  end;
end;


procedure TReaderThread.ReadSQLData;
var
  S: String;
  BL, CL: Integer;
begin
  st.FMsg := '';     {do not localize}
  BeginRead;
  if not bDone then
  try
    // Start of fix
    //SetString(st.FMsg, FBuffer, FBufferSize^);
    BL := FBufferSize^;
    SetString(S, FBuffer, BL);
    CL := SizeOf(Char);
    if CL > 1 then begin
      BL := BL div CL;
      S := Copy(S, 1, BL);
    end;
    st.FMsg := S;
    // End of fix
    st.FDataType := TTraceFlag(FTraceDataType^);
    st.FTimeStamp := TDateTime(FTimeStamp^);
  finally
    EndRead;
  end;
end;

 

Share this post


Link to post

Great THANK YOU

But not enough, data still truncates.

 

The call to the function is IBSQLMonitor1SQL(EventText: String; EventTime: TDateTime); since EventText is String... the result is still truncated

 

P.S. : Changing variables to widestring or AnsiString doesnt work either

Edited by devisluis@gmail.com

Share this post


Link to post

Hello,

I'm sorry, but the fix works without any problems for me.

Did you use the advice that Vandrovnik gave me in your program? It doesn't work without it.

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×