How to read configuration option into variable? I want to read configuration option as TEXT but SHOW statement is strange because it does not return any rows.

create or replace function get_param()
returns text as $$  
begin
  return query show custom.param; -- does not work, because show does not return setof 
end;
$$ language plpgsql;

set custom.param = 'custom value';
select get_param() as param;


Is there any other way of doing this?



Actually I found answer in a question asked by me :) set session - custom variable to store user id :

SELECT current_setting('custom.param');
Besides current_setting(), SHOW is workable in this context, it's just a matter of returning a scalar rather than a set. Your function slightly fixed to work would be:

create or replace function get_param()
returns text as $$  
declare v text;
begin
  SHOW custom.param INTO v;
  return v;
end;
$$ language plpgsql;


However this form does not seem to offer any advantage over calling directly current_setting(), so it's probably not worth creating such functions.