Changeset View
Changeset View
Standalone View
Standalone View
sql/swh-func.sql
Show First 20 Lines • Show All 340 Lines • ▼ Show 20 Lines | |||||
as $$ | as $$ | ||||
create temporary table tmp_revision_metadata ( | create temporary table tmp_revision_metadata ( | ||||
like revision_metadata including defaults | like revision_metadata including defaults | ||||
) on commit drop; | ) on commit drop; | ||||
$$; | $$; | ||||
comment on function swh_mktemp_revision_metadata() is 'Helper table to add revision metadata'; | comment on function swh_mktemp_revision_metadata() is 'Helper table to add revision metadata'; | ||||
-- add tmp_origin_intrinsic_metadata entries to origin_intrinsic_metadata, overwriting | |||||
-- duplicates if conflict_update is true, skipping duplicates otherwise. | |||||
-- | |||||
-- If filtering duplicates is in order, the call to | |||||
-- swh_origin_intrinsic_metadata_missing must take place before calling this | |||||
-- function. | |||||
-- | |||||
-- operates in bulk: 0. swh_mktemp(content_language), 1. COPY to | |||||
-- tmp_origin_intrinsic_metadata, 2. call this function | |||||
create or replace function swh_origin_intrinsic_metadata_add(conflict_update boolean) | |||||
returns void | |||||
language plpgsql | |||||
as $$ | |||||
begin | |||||
if conflict_update then | |||||
insert into origin_intrinsic_metadata (id, translated_metadata, indexer_configuration_id) | |||||
moranegg: this might change with the refactoring of the `origin_intrinsic_metadata` table | |||||
select id, translated_metadata, indexer_configuration_id | |||||
from tmp_origin_intrinsic_metadata tcm | |||||
on conflict(id, indexer_configuration_id) | |||||
do update set translated_metadata = excluded.translated_metadata; | |||||
else | |||||
insert into origin_intrinsic_metadata (id, translated_metadata, indexer_configuration_id) | |||||
select id, translated_metadata, indexer_configuration_id | |||||
from tmp_origin_intrinsic_metadata tcm | |||||
on conflict(id, indexer_configuration_id) | |||||
do nothing; | |||||
end if; | |||||
return; | |||||
end | |||||
$$; | |||||
comment on function swh_origin_intrinsic_metadata_add(boolean) IS 'Add new origin metadata'; | |||||
-- create a temporary table for retrieving origin_intrinsic_metadata | |||||
create or replace function swh_mktemp_origin_intrinsic_metadata() | |||||
returns void | |||||
language sql | |||||
as $$ | |||||
create temporary table tmp_origin_intrinsic_metadata ( | |||||
like origin_intrinsic_metadata including defaults | |||||
) on commit drop; | |||||
$$; | |||||
comment on function swh_mktemp_origin_intrinsic_metadata() is 'Helper table to add origin metadata'; | |||||
create or replace function swh_mktemp_indexer_configuration() | |||||
returns void | |||||
language sql | |||||
as $$ | |||||
create temporary table tmp_indexer_configuration ( | |||||
like indexer_configuration including defaults | |||||
) on commit drop; | |||||
alter table tmp_indexer_configuration drop column id; | |||||
$$; | |||||
create or replace function swh_mktemp_indexer_configuration() | create or replace function swh_mktemp_indexer_configuration() | ||||
returns void | returns void | ||||
language sql | language sql | ||||
as $$ | as $$ | ||||
create temporary table tmp_indexer_configuration ( | create temporary table tmp_indexer_configuration ( | ||||
like indexer_configuration including defaults | like indexer_configuration including defaults | ||||
) on commit drop; | ) on commit drop; | ||||
alter table tmp_indexer_configuration drop column id; | alter table tmp_indexer_configuration drop column id; | ||||
Show All 25 Lines |
this might change with the refactoring of the origin_intrinsic_metadata table