Querying a custom postgresql parameter with SELECT statement

喜你入骨 提交于 2019-12-10 13:51:11

问题


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?


回答1:


Use the function current_setting()

SELECT current_setting('abc.my_var');

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



来源:https://stackoverflow.com/questions/14179335/querying-a-custom-postgresql-parameter-with-select-statement

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!