diff --git a/sql/swh-func.sql b/sql/swh-func.sql --- a/sql/swh-func.sql +++ b/sql/swh-func.sql @@ -931,24 +931,6 @@ select dir_id, name from path order by depth desc limit 1; $$; - --- Walk the revision history starting from a given revision, until a matching --- occurrence is found. Return all occurrence information if one is found, NULL --- otherwise. -create or replace function swh_revision_find_occurrence(revision_id sha1_git) - returns occurrence - language sql - stable -as $$ - select origin, branch, target, target_type - from swh_revision_list_children(ARRAY[revision_id] :: bytea[]) as rev_list - left join occurrence_history occ_hist - on rev_list.id = occ_hist.target - where occ_hist.origin is not null and - occ_hist.target_type = 'revision' - limit 1; -$$; - -- Find the visit of origin id closest to date visit_date create or replace function swh_visit_find_by_date(origin bigint, visit_date timestamptz default NOW()) returns origin_visit @@ -1209,15 +1191,6 @@ $$; -create or replace function swh_occurrence_by_origin_visit(origin_id bigint, visit_id bigint) - returns setof occurrence - language sql - stable -as $$ - select origin, branch, target, target_type from occurrence_history - where origin = origin_id and visit_id = ANY(visits); -$$; - -- end revision_metadata functions -- origin_metadata functions create type origin_metadata_signature as ( diff --git a/sql/swh-schema.sql b/sql/swh-schema.sql --- a/sql/swh-schema.sql +++ b/sql/swh-schema.sql @@ -12,7 +12,7 @@ -- latest schema version insert into dbversion(version, release, description) - values(121, now(), 'Work In Progress'); + values(122, now(), 'Work In Progress'); -- a SHA1 checksum create domain sha1 as bytea check (length(value) = 20); diff --git a/sql/upgrades/122.sql b/sql/upgrades/122.sql new file mode 100644 --- /dev/null +++ b/sql/upgrades/122.sql @@ -0,0 +1,11 @@ +-- SWH DB schema upgrade +-- from_version: 121 +-- to_version: 122 +-- description: Remove some unused functions + +insert into dbversion(version, release, description) + values(122, now(), 'Work In Progress'); + +DROP FUNCTION swh_occurrence_by_origin_visit(origin_id bigint, visit_id bigint); + +DROP FUNCTION swh_revision_find_occurrence(revision_id public.sha1_git); diff --git a/swh/storage/db.py b/swh/storage/db.py --- a/swh/storage/db.py +++ b/swh/storage/db.py @@ -622,27 +622,6 @@ occurrence_cols = ['origin', 'branch', 'target', 'target_type'] - def occurrence_by_origin_visit(self, origin_id, visit_id, cur=None): - """Retrieve all occurrences for a particular origin_visit. - - Args: - origin_id: the origin concerned - visit_id: The visit step for that origin - - Yields: - The occurrence's history visits - - """ - cur = self._cursor(cur) - - query = """\ - SELECT %s - FROM swh_occurrence_by_origin_visit(%%s, %%s) - """ % (', '.join(self.occurrence_cols)) - - cur.execute(query, (origin_id, visit_id)) - yield from cursor_to_bytes(cur) - @staticmethod def mangle_query_key(key, main_table): if key == 'id':