firebird icon indicating copy to clipboard operation
firebird copied to clipboard

Regression: "Blob not found" exception after insert, select and delete in procedure

Open abzalov opened this issue 3 years ago • 7 comments

create database 'c:\test.fdb' user 'sysdba' password 'masterkey';

create table t(c blob sub_type 1);
commit;
 
set term ^;

create or alter procedure p returns (c blob sub_type 1)
as
begin
  insert into t(c) values ('AAA!');
  select c from t into :c;
  delete from t;
  suspend;
end^

commit^

select * from p^;

Output FB 4.0: BLOB not found. Output FB 2.5: AAA!

Expected behavior is returning the blob data copied before it delete.

abzalov avatar Oct 17 '21 14:10 abzalov

This behavior is "as designed" and fixing it would result in significant performance penalty.

On 2.5 the error was raised as well if UPDATE is used instead of DELETE. Now it is at least consistent...

aafemt avatar Oct 17 '21 14:10 aafemt

Assignment to a BLOB variable copies the blob ID, not the blob contents. If the blob is removed in the meantime, the blob ID cannot be used to access the blob anymore.

dyemanov avatar Oct 17 '21 14:10 dyemanov

Theoretically whole BLOB could be copied into the temporary tablespace unless it is already there but that's performance penalty I was talked about. Another solution could be reference-counted BLOB IDs.

aafemt avatar Oct 17 '21 15:10 aafemt

I have no doubt what is going on inside - it's obvious.

This could be considered "as design" if we were provided with methods for copying the content of the blob like in Oracle. And now this "design" is not self-sufficient.

You cannot break previously working things without providing working alternatives.

abzalov avatar Oct 17 '21 15:10 abzalov

Do "c = c||'';" and yuo'll get what you want.

aafemt avatar Oct 17 '21 15:10 aafemt

What about blobs greater than 64K?

If there is no such restriction now, when can we expect it? After removing one hack, you will provide the another.

abzalov avatar Oct 17 '21 15:10 abzalov

What about blobs greater than 64K?

Concatenation works with them without problems and no restriction is going to be applied.

aafemt avatar Oct 17 '21 15:10 aafemt