-------to reproduce -------------------------------------- CREATE OR REPLACE FUNCTION record_to_form_data(p_r record) RETURNS text LANGUAGE plpgsql AS $function$ begin return ( select string_agg(format('%s=%s',key,urlencode(value)),'&') from (select p_r.*) i, hstore(i.*) as h,each(h) ); end; $function$;
Not a bug, it is a documented limitation.
It is your use of "(select p_r.*)" that is problematic.
The mutable nature of record variables presents another problem in this connection. When fields of a record variable are used in expressions or statements, the data types of the fields must not change from one call of the function to the next, since each expression will be analyzed using the data type that is present when the expression is first reached. EXECUTE can be used to get around this problem when necessary.