bein-0.3: sql/immutability_test_data.sql
-- There are four relations we want to exercise:
-- template, program:
-- The program of a running execution is immutable, which means 501
-- should be immutable if the rest of the system works. In that case
-- 500, its template, should also be immutable.
-- This is also the test for program dependency.
insert into headers (id,uid,type) values (500,0,'program');
insert into programs (id) values (500);
insert into headers (id,uid,type) values (501,0,'program');
insert into programs (id) values (501);
insert into program_inputs (id,label,type)
values (501,'boris','file');
insert into program_outputs (id,label,type) values (501,'myoutput','file');
insert into copying_dependencies (object,depends_on) values (501,500);
insert into headers (id,uid,type) values (502,0,'execution');
insert into executions (id,program,status)
values (502,501,'running');
-- input:
-- Object with id 503 should be immutable, since it is the input to a running execution.
insert into headers (id,uid,type) values (503,0,'file');
insert into files (id,user_filename,stored_as)
values (503,'hilda','abcdefg');
update execution_object_inputs set value = 503 where id = 502 and label = 'boris';
-- created_by:
-- Now we have a sequence of executions, both running. The first one, 502, should be immutable.
insert into headers (id,type) values (504,'execution');
insert into executions (id,program,status) values (504,501,'running');
insert into execution_inputs (id,label,type) values (504,'boris','file');
insert into execution_outputs (id,label,type)
values (502,'myoutput','file');
-- We immediately grab the new object id again with currval.
update execution_object_inputs set value = currval('headers_id_seq') where id = 504 and label = 'boris';
select id,immutable(id),true as expected from headers where id = 500;
select id,immutable(id),true as expected from headers where id = 501;
select id,immutable(id),true as expected from headers where id = 502;
select id,immutable(id),true as expected from headers where id = 503;
select id,immutable(id),false as expected from headers where id = 504;