database function returns setof my_table with a few extra columns

In my postgres database functions I'm finding myself frequently wanting to return a setof a specific table type with a new few columns added, but it looks like to do this I have to explicitly define all of the column names.

example of what I'd like to do:

create or replace function users_with_extra_columns()
returns setof users + table(user_rank float, user_id uuid)

It worries me a little if I have to type of the explicit return set, because if I change the table schema later I have to go through my functions and make changes.

Is there a way to do this?
Was this page helpful?