Working on global temporary table I need to define function which returns set of pg_statistic records. Unfortunately I failed to declare such function! Type pg_statistic is defined in postgres.bki so I was not able to refer to it in pg_proc.dat file. And if I explicitly enumerate columns of this type:
then I go the following error when try to use this function:
a column definition list is required for functions returning "record" at character 111
The column definition list provided in pg_proc.dat was rejected because it contains reference to anyarray which can not be resolved.
If I try to declare function in system_views.sql as returning setof pg_statistic then I got error "cannot change return type of existing function".
CREATE OR REPLACE FUNCTION pg_gtt_statistic_for_relation(relid oid) returns setof pg_statistic LANGUAGE INTERNAL STRICT AS 'pg_gtt_statistic_by_relation';
And if I try to declare it as returning record and explicitly cast it to pg_statistic, then reported error is "cannot cast type record to pg_statistic".
So the only possible way I found is to create extension and define function in this extension. I wonder if there is some better solution?