Page Menu
Home
Software Heritage
Search
Configure Global Search
Log In
Files
F9343359
101.sql
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Subscribers
None
101.sql
View Options
-- SWH DB schema upgrade
-- from_version: 100
-- to_version: 101
-- description: Open swh_content_update function
insert
into
dbversion
(
version
,
release
,
description
)
values
(
101
,
now
(),
'Work In Progress'
);
-- Update content entries from temporary table.
-- (columns are potential new columns added to the schema, this cannot be empty)
--
create
or
replace
function
swh_content_update
(
columns_update
text
[])
returns
void
language
plpgsql
as
$$
declare
query
text
;
tmp_array
text
[];
begin
if
array_length
(
columns_update
,
1
)
=
0
then
raise
exception
'Please, provide the list of column names to update.'
;
end
if
;
tmp_array
:
=
array
(
select
format
(
'%1$s=t.%1$s'
,
unnest
)
from
unnest
(
columns_update
));
query
=
format
(
'update content set %s
from tmp_content t where t.sha1 = content.sha1'
,
array_to_string
(
tmp_array
,
', '
));
execute
query
;
return
;
end
$$
;
comment
on
function
swh_content_update
(
text
[])
IS
'Update existing content''s columns'
;
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Fri, Jul 4, 1:28 PM (5 d, 10 h ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3281989
Attached To
rDSTOC swh-storage-cassandra
Event Timeline
Log In to Comment