Make use of a label and do everything in one go:
sed '/^\/\*/,/\*\//{s|^/\*||; s|\*/$||; b a};s/^/ /;:a' filename
This would indent all lines except those including and between /*
and */
and remove the comments from those blocks.
For your input, it'd produce:
create or replace function test(a integer, b integer) returns integer as $$
declare
_c int;
_d int;
begin
Do some basic stuff
----------------------
Do some really basic stuff:
- this is a list
- this is a list
if a = b then
_c:=a+b;
end if;
Do some more advanced stuff
----------------------------
Description of some advanced stuff
if a <> b then
_d:=a*b;
end if;
return 1;
end;
$$ language plpgsql;