Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
S
swh-storage
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Platform
Development
swh-storage
Commits
2a9e8b90
Commit
2a9e8b90
authored
9 years ago
by
Stefano Zacchiroli
Browse files
Options
Downloads
Patches
Plain Diff
swh_content_find_dir: port to merged dir entries
parent
69d3ea78
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
sql/swh-func.sql
+2
-4
2 additions, 4 deletions
sql/swh-func.sql
sql/upgrades/015.sql
+30
-0
30 additions, 0 deletions
sql/upgrades/015.sql
with
32 additions
and
4 deletions
sql/swh-func.sql
+
2
−
4
View file @
2a9e8b90
...
...
@@ -583,8 +583,7 @@ begin
(
select
dir
.
id
as
dir_id
,
dir_entry_f
.
name
as
name
,
0
as
depth
from
directory_entry_file
as
dir_entry_f
join
content
on
content
.
sha1_git
=
dir_entry_f
.
target
join
directory_list_file
as
ls_f
on
ls_f
.
entry_ids
@>
array
[
dir_entry_f
.
id
]
join
directory
as
dir
on
ls_f
.
dir_id
=
dir
.
id
join
directory
as
dir
on
dir
.
file_entries
@>
array
[
dir_entry_f
.
id
]
where
content
.
sha1
=
content_id
limit
1
)
union
all
...
...
@@ -593,8 +592,7 @@ begin
path
.
depth
+
1
from
path
join
directory_entry_dir
as
dir_entry_d
on
dir_entry_d
.
target
=
path
.
dir_id
join
directory_list_dir
as
ls_d
on
ls_d
.
entry_ids
@>
array
[
dir_entry_d
.
id
]
join
directory
as
dir
on
ls_d
.
dir_id
=
dir
.
id
join
directory
as
dir
on
dir
.
dir_entries
@>
array
[
dir_entry_d
.
id
]
limit
1
)
)
select
dir_id
,
name
from
path
order
by
depth
desc
limit
1
...
...
This diff is collapsed.
Click to expand it.
sql/upgrades/015.sql
+
30
−
0
View file @
2a9e8b90
...
...
@@ -34,3 +34,33 @@ create index on directory using gin (rev_entries);
drop
table
directory_list_dir
;
drop
table
directory_list_file
;
drop
table
directory_list_rev
;
create
or
replace
function
swh_content_find_directory
(
content_id
sha1
)
returns
content_dir
language
plpgsql
as
$$
declare
d
content_dir
;
begin
with
recursive
path
as
(
(
select
dir
.
id
as
dir_id
,
dir_entry_f
.
name
as
name
,
0
as
depth
from
directory_entry_file
as
dir_entry_f
join
content
on
content
.
sha1_git
=
dir_entry_f
.
target
join
directory
as
dir
on
dir
.
file_entries
@>
array
[
dir_entry_f
.
id
]
where
content
.
sha1
=
content_id
limit
1
)
union
all
(
select
dir
.
id
as
dir_id
,
(
dir_entry_d
.
name
||
'/'
||
path
.
name
)::
unix_path
as
name
,
path
.
depth
+
1
from
path
join
directory_entry_dir
as
dir_entry_d
on
dir_entry_d
.
target
=
path
.
dir_id
join
directory
as
dir
on
dir
.
dir_entries
@>
array
[
dir_entry_d
.
id
]
limit
1
)
)
select
dir_id
,
name
from
path
order
by
depth
desc
limit
1
into
strict
d
;
return
d
;
end
$$
;
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment