[bug_fixed] PostgresSQL EncodeString Bug Delphi 2009

The alpha/beta tester's forum for ZeosLib 7.0.x series

Report problems concerning our Delphi 2009+ version and new Zeoslib 7.0 features here.

This is a forum that will be removed once the 7.X version goes into stable!!

Moderators: gto, EgonHugeist, olehs

Locked
cyberal77
Fresh Boarder
Fresh Boarder
Posts: 1
Joined: 16.03.2009, 17:08

[bug_fixed] PostgresSQL EncodeString Bug Delphi 2009

Post by cyberal77 »

hi,

the "EncodeString" function in ZDbcPostgresqlUtils.pas has a bug. If parameters of function is "String" (in D2009) the variables SrcBuffer and DestBuffer must be PChar. It work if applied this, but i do not know what is the impact with the other type of 'string' (stBytes or stAsciiStream).

PS: sorry for my poor english


Alex
User avatar
mdaems
Zeos Project Manager
Zeos Project Manager
Posts: 2766
Joined: 20.09.2005, 15:28
Location: Brussels, Belgium
Contact:

Post by mdaems »

cyberal77,

Thanks for reporting. I just committed the patch you propose.
(SVN rev. 607

Mark
Image
fhaut
Junior Boarder
Junior Boarder
Posts: 29
Joined: 10.04.2009, 15:55

Post by fhaut »

mdaems wrote:cyberal77,

Thanks for reporting. I just committed the patch you propose.
(SVN rev. 607

Mark

Hi i´m using the 628 revision and the problem happend again. I attached a file project to produce the error. In this project is used a ExecSQL method with parameters.

tracing into source the problem occurs on
ZDbcPostgreSqlUtils.pas -> function EncodeString lines 596 to 610

Using Pg 8.3
Database encoding win1252
D2009
Zeos revision 628
You do not have the required permissions to view the files attached to this post.
seawolf
Zeos Dev Team *
Zeos Dev Team *
Posts: 385
Joined: 04.06.2008, 19:50
Contact:

Post by seawolf »

Did you have download it through SVN? Or Did you have download a snapshot?
Because it looks like that patch not have been committed yet, so you must apply manually
fhaut
Junior Boarder
Junior Boarder
Posts: 29
Joined: 10.04.2009, 15:55

Post by fhaut »

seawolf wrote:Did you have download it through SVN? Or Did you have download a snapshot?
Because it looks like that patch not have been committed yet, so you must apply manually
I have downloaded through SVN, who i can download this path ?

I thinked that the path was applied on revision 607..


thanks
seawolf
Zeos Dev Team *
Zeos Dev Team *
Posts: 385
Joined: 04.06.2008, 19:50
Contact:

Post by seawolf »

Take a look here and check if ZDbcPostgreSqlUtils.pas is patched
fhaut
Junior Boarder
Junior Boarder
Posts: 29
Joined: 10.04.2009, 15:55

Post by fhaut »

seawolf wrote:Take a look here and check if ZDbcPostgreSqlUtils.pas is patched

Yes, it´s patched... problem remain :cry:
seawolf
Zeos Dev Team *
Zeos Dev Team *
Posts: 385
Joined: 04.06.2008, 19:50
Contact:

Post by seawolf »

In unit ZDbcPostgreSqlUtils.pas there is one more function to patch

(line 585 more or less)

function EncodeString(CharactersetCode: TZPgCharactersetType; Value: string): string;
var
I, LastState: Integer;
SrcLength, DestLength: Integer;
SrcBuffer, DestBuffer: PChar;
begin
SrcLength := Length(Value);
SrcBuffer := PChar(Value);
DestLength := 2;
LastState := 0;
for I := 1 to SrcLength do
begin
LastState := pg_CS_stat(LastState,integer(SrcBuffer^),CharactersetCode);
if (SrcBuffer^ in [#0, '''']) or ((SrcBuffer^ = '\') and (LastState = 0)) then
Inc(DestLength, 4)
else
Inc(DestLength);
Inc(SrcBuffer);
end;

SrcBuffer := PChar(Value);
SetLength(Result, DestLength);
DestBuffer := PChar(Result);
DestBuffer^ := '''';
Inc(DestBuffer);

LastState := 0;
for I := 1 to SrcLength do
begin
LastState := pg_CS_stat(LastState,integer(SrcBuffer^),CharactersetCode);
if (SrcBuffer^ in [#0, '''']) or ((SrcBuffer^ = '\') and (LastState = 0)) then
begin
DestBuffer[0] := '\';
DestBuffer[1] := Char(Ord('0') + (Byte(SrcBuffer^) shr 6));
DestBuffer[2] := Char(Ord('0') + ((Byte(SrcBuffer^) shr 3) and $07));
DestBuffer[3] := Char(Ord('0') + (Byte(SrcBuffer^) and $07));

Inc(DestBuffer, 4);
end
else
begin
DestBuffer^ := SrcBuffer^;
Inc(DestBuffer);
end;
Inc(SrcBuffer);
end;
DestBuffer^ := '''';
end;

Try do this changing. It works fine to me
fhaut
Junior Boarder
Junior Boarder
Posts: 29
Joined: 10.04.2009, 15:55

Post by fhaut »

Now works

:thanks:
fhaut
Junior Boarder
Junior Boarder
Posts: 29
Joined: 10.04.2009, 15:55

Post by fhaut »

fhaut wrote:Now works

:thanks:
[bug_report] created issue 181 on bugtracker

http://zeosbugs.firmos.at/view.php?id=181
User avatar
mdaems
Zeos Project Manager
Zeos Project Manager
Posts: 2766
Joined: 20.09.2005, 15:28
Location: Brussels, Belgium
Contact:

Post by mdaems »

SVN Rev 632
Image
Locked