[bug_fixed] error handling stUnicodeStream in ZDbcCache.pas

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

Moderators: gto, cipto_kh, EgonHugeist, mdaems

Post Reply
zx
Fresh Boarder
Fresh Boarder
Posts: 16
Joined: 13.10.2005, 14:05

[bug_fixed] error handling stUnicodeStream in ZDbcCache.pas

Post by zx »

bug report: error handling stUnicodeStream in ZDbcCache.pas
TZRowAccessor.CompareBuffers doesn't handle stUnicodeStream right way.

the code is:

Code: Select all

function TZRowAccessor.CompareBuffers(Buffer1, Buffer2: PZRowBuffer;
  ColumnIndices: TIntegerDynArray; ColumnDirs: TBooleanDynArray): Integer;
...  
else if FColumnTypes[ColumnIndex] = stAsciiStream then
Result := AnsiCompareStr(Blob1.GetString, Blob2.GetString)
else if FColumnTypes[ColumnIndex] = stBinaryStream then
Result := CompareStr(Blob1.GetString, Blob2.GetString)
else if FColumnTypes[ColumnIndex] = stAsciiStream then
{$IFNDEF VER130BELOW}
Result := WideCompareStr(Blob1.GetUnicodeString, Blob2.GetUnicodeString);
{$ELSE}
Result := AnsiCompareStr(Blob1.GetString, Blob2.GetString);
{$ENDIF}
but obviously there should be:

Code: Select all

function TZRowAccessor.CompareBuffers(Buffer1, Buffer2: PZRowBuffer;
  ColumnIndices: TIntegerDynArray; ColumnDirs: TBooleanDynArray): Integer;
...  
else if FColumnTypes[ColumnIndex] = stAsciiStream then
Result := AnsiCompareStr(Blob1.GetString, Blob2.GetString)
else if FColumnTypes[ColumnIndex] = stBinaryStream then
Result := CompareStr(Blob1.GetString, Blob2.GetString)
// here goes the difference
else if FColumnTypes[ColumnIndex] = stUnicodeStream then
{$IFNDEF VER130BELOW}
Result := WideCompareStr(Blob1.GetUnicodeString, Blob2.GetUnicodeString);
{$ELSE}
Result := AnsiCompareStr(Blob1.GetString, Blob2.GetString);
{$ENDIF}

[suggested solution]

(scope)
======== [component\ZAbstractDataset.pas] ========
function TZRowAccessor.CompareBuffers(Buffer1, Buffer2: PZRowBuffer;
ColumnIndices: TIntegerDynArray; ColumnDirs: TBooleanDynArray): Integer;
(origin)
{
else if FColumnTypes[ColumnIndex] = stAsciiStream then
{$IFNDEF VER130BELOW}
Result := WideCompareStr(Blob1.GetUnicodeString, Blob2.GetUnicodeString);
{$ELSE}
Result := AnsiCompareStr(Blob1.GetString, Blob2.GetString);
{$ENDIF}
}
(change into)
{
else if FColumnTypes[ColumnIndex] = stUnicodeStream then
{$IFNDEF VER130BELOW}
Result := WideCompareStr(Blob1.GetUnicodeString, Blob2.GetUnicodeString);
{$ELSE}
Result := AnsiCompareStr(Blob1.GetString, Blob2.GetString);
{$ENDIF}
}

[platform notes]
zeosdbo-6.6.1-beta
delphi7
User avatar
mdaems
Zeos Project Manager
Zeos Project Manager
Posts: 2766
Joined: 20.09.2005, 15:28
Location: Brussels, Belgium
Contact:

Post by mdaems »

Thanks for seeing the typo, zx (this is the cost of the wonderful copy/paste feature)

Committed in rev. 259.

Mark
Post Reply