[solved] PostgreSQL WideMemo field

The forum for ZeosLib 7.2 Report problems. Ask for help, post proposals for the new version and Zeoslib 7.2 features here. This is a forum that will be edited once the 7.2.x version goes into RC/stable!!

My personal intention for 7.2 is to speed up the internals as optimal a possible for all IDE's. Hope you can help?! Have fun with testing 7.2
Post Reply
markus
Senior Boarder
Senior Boarder
Posts: 58
Joined: 17.10.2011, 12:43
Location: Piotrków Trybunalski, Poland

[solved] PostgreSQL WideMemo field

Post by markus »

Hi,
I've recently updated my Zeos source code from svn, and i've stumbled upon such problem:
When using AsString method of TField on text column from DB i get Access Violation when value in column is empty string.
If it's NULL or column have actual value then it works ok.

This error occurs first in rev. 2746.

Best regards,
Marek
User avatar
EgonHugeist
Zeos Project Manager
Zeos Project Manager
Posts: 1936
Joined: 31.03.2011, 22:38

Re: PostgreSQL WideMemo field

Post by EgonHugeist »

Hi Marek,

I made a testcase to reproduce your report:

Code: Select all

procedure TZGenericTestDbcResultSetMBCs.TestClobEmptyString;
var
  Query: TZQuery;
  TextLob: String;
begin
  Query := CreateQuery;
  try
    with Query do
    begin
      SQL.Text := 'DELETE FROM blob_values where b_id = '+ IntToStr(TEST_ROW_ID-2);
      ExecSQL;
      if StartsWith(LowerCase(Connection.Protocol), 'oracle') then
        TextLob := 'b_clob'
      else if StartsWith(LowerCase(Connection.Protocol), 'sqlite') then
        TextLob := 'b_text'
      else
        TextLob := 'b_text';
      Sql.Text := 'INSERT INTO blob_values (b_id,'+TextLob+')'
        + ' VALUES (:b_id,:b_text)';
      CheckEquals(2, Params.Count);
      Params[0].DataType := ftInteger;
      {$IFDEF WITH_WIDEMEMO}
      if Connection.DbcConnection.GetConSettings.CPType = cCP_UTF16 then
        Params[1].DataType := ftWideMemo
      else
      {$ENDIF}
        Params[1].DataType := ftMemo;
      Params[0].AsInteger := TEST_ROW_ID-2;
      {$IFDEF WITH_WIDEMEMO}
      if Connection.DbcConnection.GetConSettings.CPType = cCP_UTF16 then
        Params[1].AsWideString := ''
      else
      {$ENDIF}
        Params[1].AsString := '';
      ExecSQL;

      CheckEquals(1, RowsAffected);

      SQL.Text := 'SELECT * FROM blob_values where b_id = '+ IntToStr(TEST_ROW_ID-2);
      CheckEquals(0, Query.Params.Count);

      Open;
      CheckEquals(1, RecordCount);
      CheckEquals(False, IsEmpty);
      CheckEquals(TEST_ROW_ID-2, FieldByName('b_id').AsInteger);
      CheckEquals(False, FieldByName(TextLob).IsNull, 'Memo is not empty.');
      CheckEquals('', FieldByName(TextLob).AsString, 'Empty but not null String');
      Close;
      SQL.Text := 'DELETE FROM blob_values where b_id = '+ IntToStr(TEST_ROW_ID-1);
      ExecSQL;
    end;
  finally
    Query.Free;
  end;
end;
But i can't see the AV your are talking about. Can you have a look and tell me what i have to change to catch the bug?

EDIT: Found a possible index overflow for empty strings and fixed this by switching to pointers. R2839 \testing-7.2
Best regards, Michael

You want to help? http://zeoslib.sourceforge.net/viewtopic.php?f=4&t=3671
You found a (possible) bug? Use the new bugtracker dude! http://sourceforge.net/p/zeoslib/tickets/

Image
markus
Senior Boarder
Senior Boarder
Posts: 58
Joined: 17.10.2011, 12:43
Location: Piotrków Trybunalski, Poland

Re: PostgreSQL WideMemo field

Post by markus »

Hi Michael,

Sorry for late reply, i've downloaded latest rev from svn and i don't have this error anymore.
Thanks a lot for your support.

Best regards,
Marek
Post Reply