Changeset View
Changeset View
Standalone View
Standalone View
swh/storage/sql/40-funcs.sql
Show First 20 Lines • Show All 408 Lines • ▼ Show 20 Lines | begin | ||||
end loop; | end loop; | ||||
-- at this moment, r is the result. Patch its 'name' with the full path before returning it. | -- at this moment, r is the result. Patch its 'name' with the full path before returning it. | ||||
r.name := paths; | r.name := paths; | ||||
return r; | return r; | ||||
end | end | ||||
$$; | $$; | ||||
-- Returns the entries in a directory, without joining with their target tables | |||||
create or replace function swh_directory_get_entries(dir_id sha1_git) | |||||
returns table ( | |||||
dir_id directory_entry_type, target sha1_git, name unix_path, perms file_perms | |||||
) | |||||
language sql | |||||
stable | |||||
as $$ | |||||
with dir as ( | |||||
select id as dir_id, dir_entries, file_entries, rev_entries | |||||
from directory | |||||
where id = dir_id), | |||||
ls_d as (select dir_id, unnest(dir_entries) as entry_id from dir), | |||||
ls_f as (select dir_id, unnest(file_entries) as entry_id from dir), | |||||
ls_r as (select dir_id, unnest(rev_entries) as entry_id from dir) | |||||
(select 'dir'::directory_entry_type, e.target, e.name, e.perms | |||||
from ls_d | |||||
left join directory_entry_dir e on ls_d.entry_id = e.id) | |||||
union | |||||
(select 'file'::directory_entry_type, e.target, e.name, e.perms | |||||
from ls_f | |||||
left join directory_entry_file e on ls_f.entry_id = e.id) | |||||
union | |||||
(select 'rev'::directory_entry_type, e.target, e.name, e.perms | |||||
from ls_r | |||||
left join directory_entry_rev e on ls_r.entry_id = e.id) | |||||
$$; | |||||
-- List all revision IDs starting from a given revision, going back in time | -- List all revision IDs starting from a given revision, going back in time | ||||
-- | -- | ||||
-- TODO ordering: should be breadth-first right now (what do we want?) | -- TODO ordering: should be breadth-first right now (what do we want?) | ||||
-- TODO ordering: ORDER BY parent_rank somewhere? | -- TODO ordering: ORDER BY parent_rank somewhere? | ||||
create or replace function swh_revision_list(root_revisions bytea[], num_revs bigint default NULL) | create or replace function swh_revision_list(root_revisions bytea[], num_revs bigint default NULL) | ||||
returns table (id sha1_git, parents bytea[]) | returns table (id sha1_git, parents bytea[]) | ||||
language sql | language sql | ||||
stable | stable | ||||
▲ Show 20 Lines • Show All 559 Lines • Show Last 20 Lines |