I have table with a lot of columns. I want to create a function which returns all these column, with an additional column. Is there a way to do this type-safe (that is, without returning a record
) without having to repeat all column names and types?
For example:
create table t
(
t1 int,
t2 int,
t3 text,
t4 boolean
);
create function extra_t() returns table(t1 int, t2 int, t3 text, t4 boolean, extra text) as
$$
select t.*, 'example'::text from t;
$$ language sql
It's quite annoying that I have to repeat t1 int, t2 int, t3 text, t4 boolean
in the function definition.