--
-- lob_copy/2
--
create or replace function lob_copy(
integer,
integer
) returns int4 as $$
declare
from_id alias for $1;
to_id alias for $2;
begin
if from_id is null then
raise exception 'lob_copy: attempt to copy null from_id to % to_id',to_id;
end if;
insert into lobs (lob_id,refcount) values (to_id,0);
insert into lob_data
select to_id as lob_id, segment, byte_len, data
from lob_data
where lob_id = from_id;
return null;
end;$$ language plpgsql;