Issue with CreateBlobStream and zeos 8

In this forum you may discuss all issues concerning the Lazarus IDE and Freepascal (both running on Windows or Linux).

Moderators: gto, cipto_kh, EgonHugeist

Post Reply
jabounet
Fresh Boarder
Fresh Boarder
Posts: 3
Joined: 30.10.2020, 11:50

Issue with CreateBlobStream and zeos 8

Post by jabounet »

Hello all !
I tried to install zeos 8 from svn, but I got this issue when I use createblobstream function, as it says I have to close the lob streams before closing the resultset... but I think the resultset is still in use at this time...

Code: Select all

 
 jmst : TMemoryStream;
 ....
 jquery := TZQuery.Create(nil);
  try
    with jquery do
    begin
      connection := modules.jconnect;
      SQL.Clear;
      SQL.add('SELECT * FROM PARAMS WHERE NOM=:NOM');
      ParamByName('NOM').AsString := 'IMGUSR_' + IntToStr(curusr);
      Open;
      if RecordCount > 0 then
      begin
        jmst := tmemorystream.Create;
        jmst.loadFromStream(CreateBlobStream(FieldByName('DATAS'), bmread));
....
Works fine with zeos 7.2.6, but displays error in zeos 8.
Best regards !
Last edited by jabounet on 30.10.2020, 17:00, edited 1 time in total.
marsupilami
Platinum Boarder
Platinum Boarder
Posts: 1918
Joined: 17.01.2011, 14:17

Re: Issue with CreateBlobStream and zeos 8

Post by marsupilami »

Hello,

we need to know the exact version of your database and compiler to look into that problem. Could you try to create a little sample application that raises the problem, including a create script for the database?

Best regards,

Jan
jabounet
Fresh Boarder
Fresh Boarder
Posts: 3
Joined: 30.10.2020, 11:50

Re: Issue with CreateBlobStream and zeos 8

Post by jabounet »

I use FPC 3.2.0 and Firebird 3.0.5

For example :

in Firebird

Code: Select all

CREATE TABLE PARAMS
(
  ID Integer NOT NULL,
  NOM Varchar(45),
  DATAS Blob sub_type 0,
  CONSTRAINT PK_PARAMS PRIMARY KEY (ID)
);
GRANT DELETE, INSERT, REFERENCES, SELECT, UPDATE
 ON PARAMS TO  SYSDBA WITH GRANT OPTION;
in datas is injected a png file that I try to retrieve with createblobstream. And it's OK with zeos 7.2.6, but not in zeos 8

In lazarus

Code: Select all

 jquery := TZQuery.Create(nil);
  try
    with jquery do
    begin
      connection := modules.jconnect;
      SQL.Clear;
      SQL.add('SELECT * FROM PARAMS WHERE NOM=:NOM);
      ParambyName('NOM').AsString := 'IMGUSR_' + IntToStr(curusr);
      Open;
      if RecordCount > 0 then
      begin
        jmst := tmemorystream.Create;
        jmst.loadFromStream(CreateBlobStream(FieldByName('DATAS'), bmread));
        usrimg := TPortableNetworkGraphic.Create;
        usrimg.LoadFromStream(jmst);
       /// work with usrimg
        usrimg.Free;
        jmst.Free;
      end;
      Close;      
    end;
  finally
    jquery.Free;
  end;     
it shows the error when executing CreateBlobStream(FieldByName('DATAS'), bmread).
It's more likely me doing something wrong rather than being a bug, but I can't manage to figure out why it doesn't work, or how to free the createblobStream's result.
Thanks a lot !
Regards
jabounet
Fresh Boarder
Fresh Boarder
Posts: 3
Joined: 30.10.2020, 11:50

Re: Issue with CreateBlobStream and zeos 8

Post by jabounet »

Hmmm, do you need a whole project to test this ? If I have some time, I'll try to post it soon.
Best regards
User avatar
EgonHugeist
Zeos Project Manager
Zeos Project Manager
Posts: 1936
Joined: 31.03.2011, 22:38

Re: Issue with CreateBlobStream and zeos 8

Post by EgonHugeist »

You don't need to post the project, jabounet.
I'm starting from the premisse it's a cross post to https://forum.lazarus.freepascal.org/in ... 878.0.html, is it, or related? Than:

Code: Select all

jmst.loadFromStream(CreateBlobStream(FieldByName('DATAS'), bmread));
Errrrrrrrm did you ever (Even if this was working on 7.2) test the project using the Heap-tracing unit? see https://wiki.freepascal.org/heaptrc
Using it would show you all memory-leaks you or other code would produce.
Just
In your example you're creating Lob-Streams but you never free them. I added this exception because, there have been users who did access the stream after the RecordSteam was closed ... Accssing dead mem isn't a good practice!

See: https://www.freepascal.org/docs-html/cu ... tream.html
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
Post Reply