Page 1 of 1

Corrupted large objects after update

Posted: Tue 03 May 2022 07:57
by gside
Hello,

When I update an existing large object, with a large object smaller than the currently stored one, the written data is corrupted by trailing data, because the previous large object size is not updated (the large object is not truncated to the new size).
For example, I store a large object 1000 bytes long. Then I update data for this same large object, with a content of 900 bytes. The stored data is corrupted because its lenght is still 1000 bytes: The last 100 bytes were not truncated.

I tried multiple ways to store the updated large object, but everything fails with the same result.
Tried using directly TPgLargeObject, then by using a TPgTable and a TPgLargeObjectField, tried with ou without large object caching.

Here is a code sample used to write the large object:

Code: Select all

    pgConnection.StartTransaction;
    ms.LoadFromFile(FilePath);
    lobj := TPgLargeObject.Create(pgConnection);
    lobj.Cached := False; // Setting it to true wont resolve the issue
    lobj.OID := OID; // For this example, we assume that the large object already exist
    lobj.ReadBlob;
    lobj.Clear; // With cached=False, the size is not reset to 0 here. I also tried Truncate(0)
    ms.Position := 0;
    lobj.LoadFromStream(ms); // The large object size is not set to the ms size
    lobj.WriteBlob; // Here, the large object seems to be written on top of the previous object, without truncating data to the new size
    lobj.CloseObject;
    pgConnection.Commit;
I directly checked the size on postgres, so the ReadBlob is not part of the problem.

Using PgDAC version 6.3.2 and Delphi 10.3 update 2

I need a workaround for a commercial product
Thank you

Re: Corrupted large objects after update

Posted: Thu 05 May 2022 11:53
by evgeniym
Hi there,

Kindly be informed we were able to reproduce the issue and fixed it.
This fix will be added to the next build of our product and it will be available to all customers. Please note that as a temporary workaround until a new build is released, we can provide you with a PgDAC nightly build that includes this fix.
To create this build for you, please provide us with your license number and the version of the IDE you are interested in.

Regards,
Evgeniy

Re: Corrupted large objects after update

Posted: Fri 06 May 2022 15:07
by gside
Hi Evgeniym,
Much appreciated, thank you.
I'll try to send you my licence number and versions through private msg
Regards,

Re: Corrupted large objects after update

Posted: Mon 09 May 2022 16:16
by evgeniym
Hi.
The link was sent in a private message.
Regards,
Evgeniy

Re: Corrupted large objects after update

Posted: Tue 10 May 2022 19:13
by gside
Hi,
I received your email but no nightly build, only a message that asks me to renew my licence.
My bad, my understanding was that reporting a major bug that could benefit to all was worth a nightly build ;-)
I have developed a workaround so I guess everything is "ok" now...

Re: Corrupted large objects after update

Posted: Wed 11 May 2022 11:12
by evgeniym
Hi,

I’m glad that your issue is fully resolved now and you can use all the features of our product.
You can download the trial version of night build by this link:
http://download.devart.com/dac/pgdac26(08.05.2022).exe
You can use Truncate(size) to resize the object.

Regards,
Evgeniy