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
042cddf4
Commit
042cddf4
authored
9 years ago
by
Stefano Zacchiroli
Browse files
Options
Downloads
Patches
Plain Diff
swh_directory_entry_*_add: port to merged dir entries
parent
89b36a3e
No related branches found
Branches containing commit
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
+54
-27
54 additions, 27 deletions
sql/swh-func.sql
sql/upgrades/015.sql
+105
-0
105 additions, 0 deletions
sql/upgrades/015.sql
with
159 additions
and
27 deletions
sql/swh-func.sql
+
54
−
27
View file @
042cddf4
...
...
@@ -240,6 +240,9 @@ $$;
--
-- operates in bulk: 0. swh_mktemp_dir_entry('directory_entry_dir'), 1 COPY to
-- tmp_directory_entry_dir, 2. call this function
--
-- Assumption: this function is used in the same transaction that inserts the
-- context directory in table "directory".
create
or
replace
function
swh_directory_entry_dir_add
()
returns
void
language
plpgsql
...
...
@@ -256,15 +259,21 @@ begin
t
.
mtime
is
not
distinct
from
i
.
mtime
and
t
.
ctime
is
not
distinct
from
i
.
ctime
);
insert
into
directory_list_dir
(
dir_id
,
entry_ids
)
select
t
.
dir_id
,
array_agg
(
i
.
id
)
from
tmp_directory_entry_dir
t
inner
join
directory_entry_dir
i
on
t
.
target
=
i
.
target
and
t
.
name
=
i
.
name
and
t
.
perms
=
i
.
perms
and
t
.
atime
is
not
distinct
from
i
.
atime
and
t
.
mtime
is
not
distinct
from
i
.
mtime
and
t
.
ctime
is
not
distinct
from
i
.
ctime
group
by
t
.
dir_id
;
with
new_entries
as
(
select
t
.
dir_id
,
array_agg
(
i
.
id
)
as
entries
from
tmp_directory_entry_dir
t
inner
join
directory_entry_dir
i
on
t
.
target
=
i
.
target
and
t
.
name
=
i
.
name
and
t
.
perms
=
i
.
perms
and
t
.
atime
is
not
distinct
from
i
.
atime
and
t
.
mtime
is
not
distinct
from
i
.
mtime
and
t
.
ctime
is
not
distinct
from
i
.
ctime
group
by
t
.
dir_id
)
update
directory
as
d
set
dir_entries
=
new_entries
.
entries
from
new_entries
where
d
.
id
=
new_entries
.
dir_id
;
return
;
end
$$
;
...
...
@@ -274,6 +283,9 @@ $$;
--
-- operates in bulk: 0. swh_mktemp_dir_entry('directory_entry_file'), 1 COPY to
-- tmp_directory_entry_file, 2. call this function
--
-- Assumption: this function is used in the same transaction that inserts the
-- context directory in table "directory".
create
or
replace
function
swh_directory_entry_file_add
()
returns
void
language
plpgsql
...
...
@@ -290,15 +302,21 @@ begin
t
.
mtime
is
not
distinct
from
i
.
mtime
and
t
.
ctime
is
not
distinct
from
i
.
ctime
);
insert
into
directory_list_file
(
dir_id
,
entry_ids
)
select
t
.
dir_id
,
array_agg
(
i
.
id
)
from
tmp_directory_entry_file
t
inner
join
directory_entry_file
i
on
t
.
target
=
i
.
target
and
t
.
name
=
i
.
name
and
t
.
perms
=
i
.
perms
and
t
.
atime
is
not
distinct
from
i
.
atime
and
t
.
mtime
is
not
distinct
from
i
.
mtime
and
t
.
ctime
is
not
distinct
from
i
.
ctime
group
by
t
.
dir_id
;
with
new_entries
as
(
select
t
.
dir_id
,
array_agg
(
i
.
id
)
from
tmp_directory_entry_file
t
inner
join
directory_entry_file
i
on
t
.
target
=
i
.
target
and
t
.
name
=
i
.
name
and
t
.
perms
=
i
.
perms
and
t
.
atime
is
not
distinct
from
i
.
atime
and
t
.
mtime
is
not
distinct
from
i
.
mtime
and
t
.
ctime
is
not
distinct
from
i
.
ctime
group
by
t
.
dir_id
)
update
directory
as
d
set
file_entries
=
new_entries
.
entries
from
new_entries
where
d
.
id
=
new_entries
.
dir_id
;
return
;
end
$$
;
...
...
@@ -308,6 +326,9 @@ $$;
--
-- operates in bulk: 0. swh_mktemp_dir_entry('directory_entry_rev'), 1 COPY to
-- tmp_directory_entry_rev, 2. call this function
--
-- Assumption: this function is used in the same transaction that inserts the
-- context directory in table "directory".
create
or
replace
function
swh_directory_entry_rev_add
()
returns
void
language
plpgsql
...
...
@@ -324,15 +345,21 @@ begin
t
.
mtime
is
not
distinct
from
i
.
mtime
and
t
.
ctime
is
not
distinct
from
i
.
ctime
);
insert
into
directory_list_rev
(
dir_id
,
entry_ids
)
select
t
.
dir_id
,
array_agg
(
i
.
id
)
from
tmp_directory_entry_rev
t
inner
join
directory_entry_rev
i
on
t
.
target
=
i
.
target
and
t
.
name
=
i
.
name
and
t
.
perms
=
i
.
perms
and
t
.
atime
is
not
distinct
from
i
.
atime
and
t
.
mtime
is
not
distinct
from
i
.
mtime
and
t
.
ctime
is
not
distinct
from
i
.
ctime
group
by
t
.
dir_id
;
with
new_entries
as
(
select
t
.
dir_id
,
array_agg
(
i
.
id
)
from
tmp_directory_entry_rev
t
inner
join
directory_entry_rev
i
on
t
.
target
=
i
.
target
and
t
.
name
=
i
.
name
and
t
.
perms
=
i
.
perms
and
t
.
atime
is
not
distinct
from
i
.
atime
and
t
.
mtime
is
not
distinct
from
i
.
mtime
and
t
.
ctime
is
not
distinct
from
i
.
ctime
group
by
t
.
dir_id
)
update
directory
as
d
set
rev_entries
=
new_entries
.
entries
from
new_entries
where
d
.
id
=
new_entries
.
dir_id
;
return
;
end
$$
;
...
...
This diff is collapsed.
Click to expand it.
sql/upgrades/015.sql
+
105
−
0
View file @
042cddf4
...
...
@@ -35,6 +35,111 @@ drop table directory_list_dir;
drop
table
directory_list_file
;
drop
table
directory_list_rev
;
create
or
replace
function
swh_directory_entry_dir_add
()
returns
void
language
plpgsql
as
$$
begin
insert
into
directory_entry_dir
(
target
,
name
,
perms
,
atime
,
mtime
,
ctime
)
select
distinct
t
.
target
,
t
.
name
,
t
.
perms
,
t
.
atime
,
t
.
mtime
,
t
.
ctime
from
tmp_directory_entry_dir
t
where
not
exists
(
select
1
from
directory_entry_dir
i
where
t
.
target
=
i
.
target
and
t
.
name
=
i
.
name
and
t
.
perms
=
i
.
perms
and
t
.
atime
is
not
distinct
from
i
.
atime
and
t
.
mtime
is
not
distinct
from
i
.
mtime
and
t
.
ctime
is
not
distinct
from
i
.
ctime
);
with
new_entries
as
(
select
t
.
dir_id
,
array_agg
(
i
.
id
)
as
entries
from
tmp_directory_entry_dir
t
inner
join
directory_entry_dir
i
on
t
.
target
=
i
.
target
and
t
.
name
=
i
.
name
and
t
.
perms
=
i
.
perms
and
t
.
atime
is
not
distinct
from
i
.
atime
and
t
.
mtime
is
not
distinct
from
i
.
mtime
and
t
.
ctime
is
not
distinct
from
i
.
ctime
group
by
t
.
dir_id
)
update
directory
as
d
set
dir_entries
=
new_entries
.
entries
from
new_entries
where
d
.
id
=
new_entries
.
dir_id
;
return
;
end
$$
;
create
or
replace
function
swh_directory_entry_file_add
()
returns
void
language
plpgsql
as
$$
begin
insert
into
directory_entry_file
(
target
,
name
,
perms
,
atime
,
mtime
,
ctime
)
select
distinct
t
.
target
,
t
.
name
,
t
.
perms
,
t
.
atime
,
t
.
mtime
,
t
.
ctime
from
tmp_directory_entry_file
t
where
not
exists
(
select
1
from
directory_entry_file
i
where
t
.
target
=
i
.
target
and
t
.
name
=
i
.
name
and
t
.
perms
=
i
.
perms
and
t
.
atime
is
not
distinct
from
i
.
atime
and
t
.
mtime
is
not
distinct
from
i
.
mtime
and
t
.
ctime
is
not
distinct
from
i
.
ctime
);
with
new_entries
as
(
select
t
.
dir_id
,
array_agg
(
i
.
id
)
from
tmp_directory_entry_file
t
inner
join
directory_entry_file
i
on
t
.
target
=
i
.
target
and
t
.
name
=
i
.
name
and
t
.
perms
=
i
.
perms
and
t
.
atime
is
not
distinct
from
i
.
atime
and
t
.
mtime
is
not
distinct
from
i
.
mtime
and
t
.
ctime
is
not
distinct
from
i
.
ctime
group
by
t
.
dir_id
)
update
directory
as
d
set
file_entries
=
new_entries
.
entries
from
new_entries
where
d
.
id
=
new_entries
.
dir_id
;
return
;
end
$$
;
create
or
replace
function
swh_directory_entry_rev_add
()
returns
void
language
plpgsql
as
$$
begin
insert
into
directory_entry_rev
(
target
,
name
,
perms
,
atime
,
mtime
,
ctime
)
select
distinct
t
.
target
,
t
.
name
,
t
.
perms
,
t
.
atime
,
t
.
mtime
,
t
.
ctime
from
tmp_directory_entry_rev
t
where
not
exists
(
select
1
from
directory_entry_rev
i
where
t
.
target
=
i
.
target
and
t
.
name
=
i
.
name
and
t
.
perms
=
i
.
perms
and
t
.
atime
is
not
distinct
from
i
.
atime
and
t
.
mtime
is
not
distinct
from
i
.
mtime
and
t
.
ctime
is
not
distinct
from
i
.
ctime
);
with
new_entries
as
(
select
t
.
dir_id
,
array_agg
(
i
.
id
)
from
tmp_directory_entry_rev
t
inner
join
directory_entry_rev
i
on
t
.
target
=
i
.
target
and
t
.
name
=
i
.
name
and
t
.
perms
=
i
.
perms
and
t
.
atime
is
not
distinct
from
i
.
atime
and
t
.
mtime
is
not
distinct
from
i
.
mtime
and
t
.
ctime
is
not
distinct
from
i
.
ctime
group
by
t
.
dir_id
)
update
directory
as
d
set
rev_entries
=
new_entries
.
entries
from
new_entries
where
d
.
id
=
new_entries
.
dir_id
;
return
;
end
$$
;
create
or
replace
function
swh_directory_walk_one
(
walked_dir_id
sha1_git
)
returns
setof
directory_entry
language
plpgsql
...
...
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