How to "inflate" Firebird database with temporary blobs

This is one of the don't-do-this articles - just as an example. If you encounter the abnormal growth of your Firebird database, check that you did not write a stored procedure, trigger or execute block, which uses BLOBs concatenation.
In some cases, Firebird stores temporary BLOBs inside the database file, so it grows very very quickly.

The following example creates a lot of small temp blobs, which are stored in the database file, so it will "inflate" Firebird database by ~2Gb (Be careful and don't run it on production or important databases!) :

execute block
returns (
    BLB blob)
declare BLB1 blob;
declare I integer;
  I = 0;
  BLB = 'blabla';
  BLB1 = cast('blablablablablablablablablablablablablabla' as blob);
  while (I < 10000) do
    BLB = BLB || BLB1;
    I = I + 1;
Firebird keeps temporary blobs until the commit (or rollback) of the transaction. If you commit the transaction and then launch code once again, you will notice that the database file will not grow - this is due to the fact that space for temporary BLOBs inside the database is reused.

Follow Firebird Friday Jokes on our Telegram channel: