Bug report: Postgres bytea fields twice decoded.

Forum related to version 6.5.1 (alpha) and 6.6.x (beta) of ZeosLib's DBOs

Moderators: gto, cipto_kh, EgonHugeist

Post Reply
niztor
Fresh Boarder
Fresh Boarder
Posts: 10
Joined: 04.11.2005, 19:05

Bug report: Postgres bytea fields twice decoded.

Post by niztor »

First, sorry my english.

I've found a bug in zeos's handling of bytea blob fields. It is
double decoding blob fields.

zeosdbo-6.5.1-alpha_cvs_13-10-2005.zip

ZDbcPostgresSqlResultSet.pas:

scope

Code: Select all

  
function TZPostgreSQLResultSet.GetBlob(ColumnIndex: Integer): IZBlob;
var
  BlobOid: Oid;
  Stream: TStream;
begin
{$IFNDEF DISABLE_CHECKING}
....

wrong code:

Code: Select all

        if (GetMetadata.GetColumnType(ColumnIndex) = stAsciiStream) then 
          Stream := TStringStream.Create(GetString(ColumnIndex))
        else
          Stream := TStringStream.Create(DecodeString(GetString(ColumnIndex)));        
As you can see, the line with

Code: Select all

DecodeString(GetString(ColumnIndex)) 
,
implicitly decode the field's content two times, since GetString also
calls DecodeString. It's :

Code: Select all

function TZPostgreSQLResultSet.GetString(ColumnIndex: Integer): String;
begin
  Result := DecodeString(GetRawString(ColumnIndex));
end;

I've fixed it not calling GetString instead GetRawString:

Code: Select all

        else
          Stream := TStringStream.Create(DecodeString(GetRawString(ColumnIndex)));        
niztor.-
cnliou
Zeos Dev Team
Zeos Dev Team
Posts: 31
Joined: 11.11.2005, 12:18

Re: Bug report: Postgres bytea fields twice decoded.

Post by cnliou »

You are right!

Thanks!
Post Reply