create table xxx (i varchar);

create or replace function immutable_direct(j varchar)
returns varchar IMMUTABLE
language plpgsql as $$
begin
	insert into xxx values(j);
	return j;
end $$;

create or replace function volatile_direct(j varchar)
returns varchar VOLATILE
language plpgsql as $$
begin
	insert into xxx values(j);
	return j;
end $$;

create or replace function immutable_indirect(j varchar)
returns varchar IMMUTABLE
language plpgsql as $$
begin
	perform volatile_direct(j);
	return j;
end $$;

select immutable_direct('immutable_direct');

select volatile_direct('volatile_direct');

select immutable_indirect('immutable_indirect');

select * from xxx;
