Problem with upload file into PostgresDb

Forum related to PostgreSQL

Moderators: gto, cipto_kh, EgonHugeist, olehs

Post Reply
supercim
Fresh Boarder
Fresh Boarder
Posts: 4
Joined: 12.10.2009, 08:49

Problem with upload file into PostgresDb

Post by supercim »

For upload a file into db i use this code

Code: Select all

  ot := TOpenDialog.Create(self);
  qry := TZQuery.Create(self);
  qry.Connection := db1;

  ot.Execute;

  qry.SQL.Add('insert into tbfile (filename,content) values (:filename,:content)');
  qry.ParamByName('filename').AsString := ExtractFileName(ot.FileName);
  qry.ParamByName('content').LoadFromFile(ot.FileName,ftBlob);
  qry.Open;
for a small file under 150 mb this right but for larger file i receive this error : EOutOfMemory with message 'out of memory'....
I also tried with loadfromstream and receive the same error....
I use Postgres 8.2.14 and zeos 5.5.0...

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

Post by seawolf »

Have you tried updating zeos to lastest stable version (6.6.5)?
supercim
Fresh Boarder
Fresh Boarder
Posts: 4
Joined: 12.10.2009, 08:49

Post by supercim »

Yes, my last test was with zeos 6.6.5, Delphi 2007 and Postgres 8.4.1 ... the Stream of vcl working properly upon 1gb of allocation ... I also try lazarus and Zeos 6.6.5 and receive the same error...
User avatar
mdaems
Zeos Project Manager
Zeos Project Manager
Posts: 2766
Joined: 20.09.2005, 15:28
Location: Brussels, Belgium
Contact:

Post by mdaems »

Seems like this may be a consequence of the way BLOB are loaded by zeoslib. Blob's are encoded and inserted into the sql statement, causing big strings to be used.
I'm afraid this is the only way we know to load blob's using libpq.dll.
So the one BLOB you have may be stored multiple times (encode/not encoded) in memory.

If you know how this can be done better, please tell us.

Mark
Image
supercim
Fresh Boarder
Fresh Boarder
Posts: 4
Joined: 12.10.2009, 08:49

Post by supercim »

Thanks, when i found a solution i post the code bye
David
Post Reply