Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Querying a custom postgresql parameter with SELECT statement

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?

like image 937
tralston Avatar asked Jan 06 '13 04:01

tralston


1 Answers

Use the function current_setting()

SELECT current_setting('abc.my_var');

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

like image 95
a_horse_with_no_name Avatar answered Oct 12 '22 10:10

a_horse_with_no_name