6

In another question, it was asked how to query a postgresql runtime parameter (e.g. SHOW search_path;) using a SELECT query. In the answer, it was suggested to use

SELECT * FROM pg_settings WHERE name = 'search_path';

This works great, but how can this be done for custom parameters defined in an extension? (See docs about Customized Options).

Example:

SET abc.my_var = 1;
SHOW abc.my_var;

outputs

1

but

SELECT * FROM pg_settings WHERE name = 'abc.my_var';

returns no rows. Is there some other table/view I can query for my custom parameter using a SELECT statement?

Community
  • 1
  • 1
tralston
  • 2,825
  • 3
  • 19
  • 22

1 Answers1

5

Use the function current_setting()

SELECT current_setting('abc.my_var');

http://www.postgresql.org/docs/current/static/functions-admin.html#FUNCTIONS-ADMIN-SET