Setting a configuration parameter for functions implemented in PL/pgSQL

非 Y 不嫁゛ 提交于 2019-12-01 21:56:12

You can define your custom parameters in postgresql.conf. Just append a line (e.g.):

my_param.new_param = 'something'

and reload configuration (or restart server).

In your client you can access the parameter with show command:

SHOW my_param.new_param;

or with current_setting() function:

SELECT current_setting('my_param.new_param');

You can change the current parameter (locally in the session):

SET my_param.new_param TO 'new value';

It is also possible to define custom parameters for a database:

ALTER DATABASE test SET my_param.new_param TO 'new test value';
-- each new client to the database will see the parameter with new value
-- current setting of the parameter remains unchanged

-- or
SET my_param.new_param TO 'new test value';
ALTER DATABASE test SET my_param.new_param FROM CURRENT;

A custom parameter must contain a period. Formally, the prefix should indicate the extension to which it relates, but Postgres does not check it in any way. You can have many custom parameters.

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