Improve tests for LoadBlobFromFile
This commit is contained in:
parent
cfcfa28082
commit
8aac65cc81
@ -21,4 +21,4 @@ insert into test_blobs( description, file_type, source_file ) values ('fb log',
|
||||
insert into test_blobs( description, file_type, source_file ) values ('computer', 'bin', '/usr/share/icons/Adwaita/48x48/devices/computer.png');
|
||||
insert into test_blobs( description, file_type, source_file ) values ('git gui icon', 'bin', '/usr/share/git-gui/lib/git-gui.ico');
|
||||
|
||||
|
||||
commit;
|
||||
|
@ -12,3 +12,23 @@ select FLAGGED (190, 0) from rdb$database;
|
||||
select FLAGGED (191, 0) from rdb$database;
|
||||
|
||||
commit;
|
||||
|
||||
|
||||
execute procedure load_blob(1);
|
||||
execute procedure load_blob(2);
|
||||
execute procedure load_blob(3);
|
||||
execute procedure load_blob(4);
|
||||
commit;
|
||||
|
||||
select cast ( description as varchar(32) ) as DESCRIPTION
|
||||
, file_type
|
||||
, cast (left(source_file,32) as varchar(32)) as source_file
|
||||
, source_status
|
||||
-- , source_bytes D_BIGINT
|
||||
-- , target_file D_PATH
|
||||
-- , target_status D_STATUS
|
||||
-- , target_bytes D_BIGINT
|
||||
-- , the_blob D_BLOB
|
||||
from test_blobs;
|
||||
commit;
|
||||
|
||||
|
@ -30,6 +30,8 @@ create domain D_PATH as varchar(8189) default '' not null ;
|
||||
create domain D_STATUS as CHAR(1) default 'U' not null check (VALUE IN ('U', 'F', 'L', 'W'));
|
||||
comment on domain D_STATUS is 'unset, failed, loaded, written';
|
||||
|
||||
create exception E_BLOB_EXCEPTION '';
|
||||
|
||||
create table test_blobs(
|
||||
test_blobs_id D_ID generated always as identity
|
||||
, description D_DESCRIPTION
|
||||
@ -60,24 +62,28 @@ set term ^;
|
||||
create or alter procedure load_blob ( a_test_blob_id D_ID ) sql security definer
|
||||
as
|
||||
declare asource_file D_PATH;
|
||||
declare ablob D_BLOB;
|
||||
declare oldblob D_BLOB;
|
||||
declare newblob D_BLOB;
|
||||
declare result D_BIGINT;
|
||||
declare status D_STATUS;
|
||||
begin
|
||||
|
||||
select source_file, the_blob from test_blobs where test_blobs_id = :a_test_blob_id into asource_file, ablob;
|
||||
select LoadBlobFromFile( :asource_file, :ablob ) from rdb$database into :result;
|
||||
if (result > 0 ) then
|
||||
select source_file, the_blob from test_blobs where test_blobs_id = :a_test_blob_id into :asource_file, :oldblob;
|
||||
select LoadBlobFromFile( :asource_file ) from rdb$database into :newblob;
|
||||
|
||||
if ( newblob is not null ) then
|
||||
status = 'L';
|
||||
else if ( result < 0 ) then
|
||||
else
|
||||
status = 'F';
|
||||
|
||||
|
||||
update test_blobs
|
||||
set the_blob = :ablob
|
||||
, source_bytes = :result
|
||||
set the_blob = :newblob
|
||||
-- , source_bytes = :result
|
||||
, source_status = :status
|
||||
where test_blobs_id = :a_test_blob_id;
|
||||
when any do begin
|
||||
EXCEPTION E_BLOB_EXCEPTION 'Error updating test_blobs';
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user