Rafal Pietrak <rafal(at)zorro(dot)isa-geek(dot)com> writes:
> CREATE FUNCTION new_user (text,text) RETURNS SETOF people AS $$
> CREATE ROLE $1 PASSWORD $2;
> SELECT CASE WHEN $2 is not null THEN ROW($1, null, null, null)::people
> ELSE null::ludzie END
> $$ language sql;
> "ERROR: function returning set of rows cannot return null value"
If you want to return no rows, then return no rows. Something like
SELECT ROW($1, null, null, null)::people WHERE $2 is not null;
regards, tom lane