Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


Welcome, Guest
Guest Settings
Help

Thread: IBDataSet, Blob SaveToStream cut NULL char with delphi 2010!



Permlink Replies: 10 - Last Post: Feb 21, 2017 11:54 AM Last Post By: Jeff Overcash (...
Marco Andreolli

Posts: 10
Registered: 5/10/13
IBDataSet, Blob SaveToStream cut NULL char with delphi 2010!
Click to report abuse...   Click to reply to this thread Reply
  Posted: Feb 15, 2017 6:42 AM
Hi,
I have this problem, when I save a value of a blob field into stream, delphi 2010 cut the last byte when it is NULL (0x00 character)
Why?
Is there a possibility to change this behaviour?

NB: This is a problem for me because i calculate SHA-256 on the blob!
with delphi 2007 (it don't cut NULL char) it give me a result different from delphi 2010 (that cut NULL char)
Jeff Overcash (...

Posts: 1,529
Registered: 9/23/99
Re: IBDataSet, Blob SaveToStream cut NULL char with delphi 2010!
Click to report abuse...   Click to reply to this thread Reply
  Posted: Feb 15, 2017 8:55 AM   in response to: Marco Andreolli in response to: Marco Andreolli
Marco Andreolli wrote:
Hi,
I have this problem, when I save a value of a blob field into stream, delphi 2010 cut the last byte when it is NULL (0x00 character)
Why?
Is there a possibility to change this behaviour?

NB: This is a problem for me because i calculate SHA-256 on the blob!
with delphi 2007 (it don't cut NULL char) it give me a result different from delphi 2010 (that cut NULL char)

How are you streaming it and what class are you creating for your Blob?

--
Jeff Overcash (TeamB)
(Please do not email me directly unless asked. Thank You)
Learning is finding out what you already know. Doing is demonstrating that you
know it. Teaching is reminding others that they know it as well as you. We are
all leaners, doers, teachers. (R Bach)
Marco Andreolli

Posts: 10
Registered: 5/10/13
Re: IBDataSet, Blob SaveToStream cut NULL char with delphi 2010!
Click to report abuse...   Click to reply to this thread Reply
  Posted: Feb 15, 2017 9:10 AM   in response to: Jeff Overcash (... in response to: Jeff Overcash (...
Jeff Overcash (TeamB) wrote:
Marco Andreolli wrote:
Hi,
I have this problem, when I save a value of a blob field into stream, delphi 2010 cut the last byte when it is NULL (0x00 character)
Why?
Is there a possibility to change this behaviour?

NB: This is a problem for me because i calculate SHA-256 on the blob!
with delphi 2007 (it don't cut NULL char) it give me a result different from delphi 2010 (that cut NULL char)

How are you streaming it and what class are you creating for your Blob?

--
Jeff Overcash (TeamB)
(Please do not email me directly unless asked. Thank You)
Learning is finding out what you already know. Doing is demonstrating that you
know it. Teaching is reminding others that they know it as well as you. We are
all leaners, doers, teachers. (R Bach)

var
BlobStream : TMemoryStream;
b : TBlobField;
begin
[...]
BlobStream.Clear;
b := TBlobField(DataSet.FieldByName(FieldName));
b.BlobType := ftTypedBinary;
b.SaveToStream(BlobStream); // or SaveToFile
BlobStream.Seek(0,soBeginning);
Result := Hash(BlobStream);
[..]

But not always, with the same code above, in a simple program now I don't have this problem (but still remain in main project...)

Edited by: Marco Andreolli on Feb 15, 2017 9:11 AM
Marco Andreolli

Posts: 10
Registered: 5/10/13
Re: IBDataSet, Blob SaveToStream cut NULL char with delphi 2010!
Click to report abuse...   Click to reply to this thread Reply
  Posted: Feb 16, 2017 2:37 AM   in response to: Marco Andreolli in response to: Marco Andreolli
Marco Andreolli wrote:
Jeff Overcash (TeamB) wrote:
Marco Andreolli wrote:
Hi,
I have this problem, when I save a value of a blob field into stream, delphi 2010 cut the last byte when it is NULL (0x00 character)
Why?
Is there a possibility to change this behaviour?

NB: This is a problem for me because i calculate SHA-256 on the blob!
with delphi 2007 (it don't cut NULL char) it give me a result different from delphi 2010 (that cut NULL char)

How are you streaming it and what class are you creating for your Blob?

--
Jeff Overcash (TeamB)
(Please do not email me directly unless asked. Thank You)
Learning is finding out what you already know. Doing is demonstrating that you
know it. Teaching is reminding others that they know it as well as you. We are
all leaners, doers, teachers. (R Bach)

var
BlobStream : TMemoryStream;
b : TBlobField;
begin
[...]
BlobStream.Clear;
b := TBlobField(DataSet.FieldByName(FieldName));
b.BlobType := ftTypedBinary;
b.SaveToStream(BlobStream); // or SaveToFile
BlobStream.Seek(0,soBeginning);
Result := Hash(BlobStream);
[..]

But not always, with the same code above, in a simple program now I don't have this problem (but still remain in main project...)

Edited by: Marco Andreolli on Feb 15, 2017 9:11 AM

I found a solution/workaround: remove the "Character Set" property in database object

If I have the charset in database object (IBDatabase) lc_ctype=ISO8859_1, when I save the blob into a strem/file the value is without the NULL char
If I remove the charset, the save method work fine!

This is what I have noticed, but only with Delphi 2010!; not with Delphi 2007 and Delphi 2009 (where work also with charset).
I do not know if this may be a bug of Delphi 2010
Jeff Overcash (...

Posts: 1,529
Registered: 9/23/99
Re: IBDataSet, Blob SaveToStream cut NULL char with delphi 2010!
Click to report abuse...   Click to reply to this thread Reply
  Posted: Feb 16, 2017 9:51 AM   in response to: Marco Andreolli in response to: Marco Andreolli
Marco Andreolli wrote:

var
BlobStream : TMemoryStream;
b : TBlobField;
begin
[...]
BlobStream.Clear;
b := TBlobField(DataSet.FieldByName(FieldName));
b.BlobType := ftTypedBinary;
b.SaveToStream(BlobStream); // or SaveToFile
BlobStream.Seek(0,soBeginning);
Result := Hash(BlobStream);
[..]

But not always, with the same code above, in a simple program now I don't have this problem (but still remain in main project...)

Edited by: Marco Andreolli on Feb 15, 2017 9:11 AM

I found a solution/workaround: remove the "Character Set" property in database object

If I have the charset in database object (IBDatabase) lc_ctype=ISO8859_1, when I save the blob into a strem/file the value is without the NULL char
If I remove the charset, the save method work fine!

This is what I have noticed, but only with Delphi 2010!; not with Delphi 2007 and Delphi 2009 (where work also with charset).
I do not know if this may be a bug of Delphi 2010

Blobs were a little problematic in early Unicode versions, they have been fixed
in in around the XE timeframe. If you have an example that reproduces this
problem I will test it on the most recent version to ensure that this case is
fixed too.

--
Jeff Overcash (TeamB)
(Please do not email me directly unless asked. Thank You)
Learning is finding out what you already know. Doing is demonstrating that you
know it. Teaching is reminding others that they know it as well as you. We are
all leaners, doers, teachers. (R Bach)
Marco Andreolli

Posts: 10
Registered: 5/10/13
Re: IBDataSet, Blob SaveToStream cut NULL char with delphi 2010!
Click to report abuse...   Click to reply to this thread Reply
  Posted: Feb 17, 2017 12:40 AM   in response to: Jeff Overcash (... in response to: Jeff Overcash (...
Jeff Overcash (TeamB) wrote:
Marco Andreolli wrote:

var
BlobStream : TMemoryStream;
b : TBlobField;
begin
[...]
BlobStream.Clear;
b := TBlobField(DataSet.FieldByName(FieldName));
b.BlobType := ftTypedBinary;
b.SaveToStream(BlobStream); // or SaveToFile
BlobStream.Seek(0,soBeginning);
Result := Hash(BlobStream);
[..]

But not always, with the same code above, in a simple program now I don't have this problem (but still remain in main project...)

Edited by: Marco Andreolli on Feb 15, 2017 9:11 AM

I found a solution/workaround: remove the "Character Set" property in database object

If I have the charset in database object (IBDatabase) lc_ctype=ISO8859_1, when I save the blob into a strem/file the value is without the NULL char
If I remove the charset, the save method work fine!

This is what I have noticed, but only with Delphi 2010!; not with Delphi 2007 and Delphi 2009 (where work also with charset).
I do not know if this may be a bug of Delphi 2010

Blobs were a little problematic in early Unicode versions, they have been fixed
in in around the XE timeframe. If you have an example that reproduces this
problem I will test it on the most recent version to ensure that this case is
fixed too.

--
Jeff Overcash (TeamB)
(Please do not email me directly unless asked. Thank You)
Learning is finding out what you already know. Doing is demonstrating that you
know it. Teaching is reminding others that they know it as well as you. We are
all leaners, doers, teachers. (R Bach)

Ok, I don't know how send you a simple project, in this forum I don't know where is it possible...
Jeff Overcash (...

Posts: 1,529
Registered: 9/23/99
Re: IBDataSet, Blob SaveToStream cut NULL char with delphi 2010!
Click to report abuse...   Click to reply to this thread Reply
  Posted: Feb 17, 2017 9:53 AM   in response to: Marco Andreolli in response to: Marco Andreolli
Marco Andreolli wrote:

Ok, I don't know how send you a simple project, in this forum I don't know where is it possible...

Put it in the attachments group. If you feel there is sensitive material then
you can just email it to me.

--
Jeff Overcash (TeamB)
(Please do not email me directly unless asked. Thank You)
Learning is finding out what you already know. Doing is demonstrating that you
know it. Teaching is reminding others that they know it as well as you. We are
all leaners, doers, teachers. (R Bach)
Marco Andreolli

Posts: 10
Registered: 5/10/13
Re: IBDataSet, Blob SaveToStream cut NULL char with delphi 2010!
Click to report abuse...   Click to reply to this thread Reply
  Posted: Feb 20, 2017 3:29 AM   in response to: Jeff Overcash (... in response to: Jeff Overcash (...
Jeff Overcash (TeamB) wrote:
Marco Andreolli wrote:

Ok, I don't know how send you a simple project, in this forum I don't know where is it possible...

Put it in the attachments group. If you feel there is sensitive material then
you can just email it to me.

--
Jeff Overcash (TeamB)
(Please do not email me directly unless asked. Thank You)
Learning is finding out what you already know. Doing is demonstrating that you
know it. Teaching is reminding others that they know it as well as you. We are
all leaners, doers, teachers. (R Bach)

Ok, the sample is at this url
[https://forums.embarcadero.com/thread.jspa?threadID=246817&stqc=true]
Jeff Overcash (...

Posts: 1,529
Registered: 9/23/99
Re: IBDataSet, Blob SaveToStream cut NULL char with delphi 2010!
Click to report abuse...   Click to reply to this thread Reply
  Posted: Feb 20, 2017 10:26 AM   in response to: Marco Andreolli in response to: Marco Andreolli
Marco Andreolli wrote:
Jeff Overcash (TeamB) wrote:
Marco Andreolli wrote:
Ok, I don't know how send you a simple project, in this forum I don't know where is it possible...
Put it in the attachments group. If you feel there is sensitive material then
you can just email it to me.

--
Jeff Overcash (TeamB)
(Please do not email me directly unless asked. Thank You)
Learning is finding out what you already know. Doing is demonstrating that you
know it. Teaching is reminding others that they know it as well as you. We are
all leaners, doers, teachers. (R Bach)

Ok, the sample is at this url
[https://forums.embarcadero.com/thread.jspa?threadID=246817&stqc=true]

I can't test that since it is against Firebird and not InterBase. I do not have
Firebird installed since IBX does not support FB. While it is probably not a FB
(there have been none I can remember over the years even though IBX does not
support FB) specific bug, I can't test unless it is against IB.

--
Jeff Overcash (TeamB)
(Please do not email me directly unless asked. Thank You)
Learning is finding out what you already know. Doing is demonstrating that you
know it. Teaching is reminding others that they know it as well as you. We are
all leaners, doers, teachers. (R Bach)
Marco Andreolli

Posts: 10
Registered: 5/10/13
Re: IBDataSet, Blob SaveToStream cut NULL char with delphi 2010!
Click to report abuse...   Click to reply to this thread Reply
  Posted: Feb 21, 2017 1:35 AM   in response to: Jeff Overcash (... in response to: Jeff Overcash (...
Jeff Overcash (TeamB) wrote:
Marco Andreolli wrote:
Jeff Overcash (TeamB) wrote:
Marco Andreolli wrote:
Ok, I don't know how send you a simple project, in this forum I don't know where is it possible...
Put it in the attachments group. If you feel there is sensitive material then
you can just email it to me.

--
Jeff Overcash (TeamB)
(Please do not email me directly unless asked. Thank You)
Learning is finding out what you already know. Doing is demonstrating that you
know it. Teaching is reminding others that they know it as well as you. We are
all leaners, doers, teachers. (R Bach)

Ok, the sample is at this url
[https://forums.embarcadero.com/thread.jspa?threadID=246817&stqc=true]

I can't test that since it is against Firebird and not InterBase. I do not have
Firebird installed since IBX does not support FB. While it is probably not a FB
(there have been none I can remember over the years even though IBX does not
support FB) specific bug, I can't test unless it is against IB.

--
Jeff Overcash (TeamB)
(Please do not email me directly unless asked. Thank You)
Learning is finding out what you already know. Doing is demonstrating that you
know it. Teaching is reminding others that they know it as well as you. We are
all leaners, doers, teachers. (R Bach)

[http://www.firebirdfaq.org/faq8/]

I always use IBX component with Firebird and previous version of delphi and always work well (and no problem with blob)
Ok, probably IBX are not officially support Firebird but always work (in previous version of Delphi)
Jeff Overcash (...

Posts: 1,529
Registered: 9/23/99
Re: IBDataSet, Blob SaveToStream cut NULL char with delphi 2010!
Click to report abuse...   Click to reply to this thread Reply
  Posted: Feb 21, 2017 11:54 AM   in response to: Marco Andreolli in response to: Marco Andreolli
Marco Andreolli wrote:
Jeff Overcash (TeamB) wrote:
Marco Andreolli wrote:
Jeff Overcash (TeamB) wrote:
Marco Andreolli wrote:
Ok, I don't know how send you a simple project, in this forum I don't know where is it possible...
Put it in the attachments group. If you feel there is sensitive material then
you can just email it to me.

--
Jeff Overcash (TeamB)
(Please do not email me directly unless asked. Thank You)
Learning is finding out what you already know. Doing is demonstrating that you
know it. Teaching is reminding others that they know it as well as you. We are
all leaners, doers, teachers. (R Bach)
Ok, the sample is at this url
[https://forums.embarcadero.com/thread.jspa?threadID=246817&stqc=true]
I can't test that since it is against Firebird and not InterBase. I do not have
Firebird installed since IBX does not support FB. While it is probably not a FB
(there have been none I can remember over the years even though IBX does not
support FB) specific bug, I can't test unless it is against IB.

--
Jeff Overcash (TeamB)
(Please do not email me directly unless asked. Thank You)
Learning is finding out what you already know. Doing is demonstrating that you
know it. Teaching is reminding others that they know it as well as you. We are
all leaners, doers, teachers. (R Bach)

[http://www.firebirdfaq.org/faq8/]

I always use IBX component with Firebird and previous version of delphi and always work well (and no problem with blob)
Ok, probably IBX are not officially support Firebird but always work (in previous version of Delphi)

I stated 17 years ago I would not be supporting Firebird with IBX. IBX is
actually owned internally by the InterBase team and not the Delphi team so makes
sense that IBX support InterBase and not forks of IB.

I am interested in fixing this problem if it still exists, but I will not
install Firebird to track down bugs since it is not a supported backend. Bug
reports against IBX must have an InterBase example.

--
Jeff Overcash (TeamB)
(Please do not email me directly unless asked. Thank You)
Learning is finding out what you already know. Doing is demonstrating that you
know it. Teaching is reminding others that they know it as well as you. We are
all leaners, doers, teachers. (R Bach)
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02