create view test_view (p1,p2) as select cast(null as int),cast(null asint)
create or replace function test_rec1(int,int) returns test_view as
'
declare
view_rec test_view%rowtype ;
view_rec1 test_view%rowtype ;
begin
view_rec.p1 = 2;
view_rec.p2 = 3;
select * into view_rec1 from test_rec2( test_rec3($1),$2);
return view_rec1;
end;'language 'plpgsql';
create or replace function test_rec2(test_view,int) returns test_view as
'
declare
view_return alias for $1;
begin
view_return.p2 = $2;
return view_return;
end;'language 'plpgsql';
create or replace function test_rec3(int) returns test_view as
'
declare
view_return test_view%rowtype;
begin
view_return.p1 = $1;
view_return.p2 =0;
return view_return;
end;'language 'plpgsql';