Backslash truncated delphi7 + postgres8.1 + zeosdbo 6.6.2-rc

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

Moderators: gto, cipto_kh, EgonHugeist

Post Reply
_dbczl2007_
Fresh Boarder
Fresh Boarder
Posts: 2
Joined: 13.01.2008, 15:17

Backslash truncated delphi7 + postgres8.1 + zeosdbo 6.6.2-rc

Post by _dbczl2007_ »

Hi,

I have the following table:
CREATE TABLE test (a text)
then I insert some data:
INSERT INTO test VALUES ('\\path\\testdir\\')
When doing
SELECT * FROM test
in the pqAdmin III Query application the results are as expected (\path\testdir\).

When using Delphi7 + zeosdbo-6.6.2-rc I get
pathtestdir
The backslash is gone! Why? I have tried a lot of different stuff codepage, client_encoding, forcing binary stream instead of ascii stream.

I have also been experiencing with different implementations of utf8_encoding, but no matter how I do it, my client app wont display (or retreive for that matter) the backslash, only pgAdmin will...

Can someone please help me on this.

Kind regards,

Jon
gto
Zeos Dev Team
Zeos Dev Team
Posts: 278
Joined: 11.11.2005, 18:35
Location: Porto Alegre / Brasil

Post by gto »

I think you can use \\\\ instead of \\.

The backslash is used to escape the next char at right. If you post four backslashes, you'll be escaping two, and then it will work. At least it should :)
Use the FU!!!!!IN Google !

gto's Zeos Quick Start Guide

Te Amo Taís!
_dbczl2007_
Fresh Boarder
Fresh Boarder
Posts: 2
Joined: 13.01.2008, 15:17

Post by _dbczl2007_ »

A workaround is to use the postgresql-7 driver instead of version 8! Why I don't know. See related issue posted here Backward slash (\) problem...

Well well. If anyone have another solution, I am very interested!!!
btrewern
Expert Boarder
Expert Boarder
Posts: 193
Joined: 06.10.2005, 18:51

Post by btrewern »

It seems there is a problem in TZPostgreSQLResultSet.GetBlob.

if you replace

Code: Select all

    if FPlainDriver.GetIsNull(FQueryHandle, RowNo - 1, ColumnIndex - 1) = 0 then
    begin
      Stream := nil;
      try
//        Stream := TStringStream.Create(DecodeString(GetRawString(ColumnIndex)));
        Stream := TStringStream.Create(FPlainDriver.DecodeBYTEA(GetString(ColumnIndex)));
        Result := TZAbstractBlob.CreateWithStream(Stream);
      finally
        if Assigned(Stream) then
          Stream.Free;
      end;
with

Code: Select all

    if FPlainDriver.GetIsNull(FQueryHandle, RowNo - 1, ColumnIndex - 1) = 0 then
    begin
      Stream := nil;
      try
//        Stream := TStringStream.Create(DecodeString(GetRawString(ColumnIndex)));
        Stream := TStringStream.Create(GetString(ColumnIndex));
        Result := TZAbstractBlob.CreateWithStream(Stream);
      finally
        if Assigned(Stream) then
          Stream.Free;
      end;
text fields look like they work correctly:). I'm not sure if this then affects bytea fields though. Could anyone who uses bytea fields check to see if this messes them up.

Ben.
btrewern
Expert Boarder
Expert Boarder
Posts: 193
Joined: 06.10.2005, 18:51

Post by btrewern »

It looks as if the following works correctly. In the TZPostgreSQLResultSet.GetBlob function of the ZDbcPostgreSqlResultSet file replace

Code: Select all

    if FPlainDriver.GetIsNull(FQueryHandle, RowNo - 1, ColumnIndex - 1) = 0 then
    begin
      Stream := nil;
      try
//        Stream := TStringStream.Create(DecodeString(GetRawString(ColumnIndex)));
        Stream := TStringStream.Create(FPlainDriver.DecodeBYTEA(GetString(ColumnIndex)));
        Result := TZAbstractBlob.CreateWithStream(Stream);
      finally
        if Assigned(Stream) then
          Stream.Free;
      end;
    end else
      Result := TZAbstractBlob.CreateWithStream(nil);
with

Code: Select all

    if FPlainDriver.GetIsNull(FQueryHandle, RowNo - 1, ColumnIndex - 1) = 0 then
    begin
      Stream := nil;
      try
//        Stream := TStringStream.Create(DecodeString(GetRawString(ColumnIndex)));
        if GetMetadata.GetColumnType(ColumnIndex) = stBinaryStream then
          Stream := TStringStream.Create(FPlainDriver.DecodeBYTEA(GetString(ColumnIndex)))
        else
          Stream := TStringStream.Create(GetString(ColumnIndex));
        Result := TZAbstractBlob.CreateWithStream(Stream);
      finally
        if Assigned(Stream) then
          Stream.Free;
      end;
    end else
      Result := TZAbstractBlob.CreateWithStream(nil);
Regards,

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

Post by mdaems »

Ben,

I have to believe you and hope this code is also compatible with versions before 8.1.

SVN rev. 330

Mark
Image
Post Reply