Changeset View
Changeset View
Standalone View
Standalone View
swh/scheduler/sql/40-swh-func.sql
Show All 28 Lines | begin | ||||
insert into task (type, arguments, next_run, status, current_interval, policy, | insert into task (type, arguments, next_run, status, current_interval, policy, | ||||
retries_left, priority) | retries_left, priority) | ||||
select type, arguments, next_run, status, current_interval, policy, | select type, arguments, next_run, status, current_interval, policy, | ||||
retries_left, priority | retries_left, priority | ||||
from tmp_task t | from tmp_task t | ||||
where not exists(select 1 | where not exists(select 1 | ||||
from task | from task | ||||
where type = t.type and | where type = t.type and | ||||
arguments->'args' = t.arguments->'args' and | md5(arguments::text) = md5(t.arguments::text) and | ||||
arguments->'kwargs' = t.arguments->'kwargs' and | arguments = t.arguments and | ||||
policy = t.policy and | policy = t.policy and | ||||
priority is not distinct from t.priority and | priority is not distinct from t.priority and | ||||
status = t.status); | status = t.status); | ||||
return query | return query | ||||
select distinct t.* | select distinct t.* | ||||
from tmp_task tt inner join task t on ( | from tmp_task tt inner join task t on ( | ||||
tt.type = t.type and | tt.type = t.type and | ||||
tt.arguments->'args' = t.arguments->'args' and | md5(tt.arguments::text) = md5(t.arguments::text) and | ||||
tt.arguments->'kwargs' = t.arguments->'kwargs' and | tt.arguments = t.arguments and | ||||
tt.policy = t.policy and | tt.policy = t.policy and | ||||
tt.priority is not distinct from t.priority and | tt.priority is not distinct from t.priority and | ||||
tt.status = t.status | tt.status = t.status | ||||
); | ); | ||||
end; | end; | ||||
$$; | $$; | ||||
comment on function swh_scheduler_create_tasks_from_temp () is 'Create tasks in bulk from the temporary table'; | comment on function swh_scheduler_create_tasks_from_temp () is 'Create tasks in bulk from the temporary table'; | ||||
▲ Show 20 Lines • Show All 352 Lines • Show Last 20 Lines |