Page 1 of 1

Bug report: Postgres bytea fields twice decoded.

Posted: 04.11.2005, 19:32
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.-

Re: Bug report: Postgres bytea fields twice decoded.

Posted: 11.11.2005, 15:17
by cnliou
You are right!

Thanks!