10

Using PGAdmin III I can right-click on a database, navigate to the Variables tab, and put a variable name-value property on the database itself. Is there a way to customize these? I saw an application_name variable, but I'd like to have an application_version variable.

Paul White
95.3k30 gold badges439 silver badges689 bronze badges
asked Dec 7, 2012 at 1:29

2 Answers 2

11

To add to @dezso's answer, these variables can be changed with

SELECT set_config('class.name', 'value', valid_for_transaction_only::boolean)

and read with

SELECT current_setting('class.name')

See this link for more info: http://www.postgresql.org/docs/9.3/static/functions-admin.html

András Váczi
31.8k13 gold badges103 silver badges152 bronze badges
answered Jun 16, 2014 at 21:05
8

You have to add the variable to the end of your postgresql.conf like

#------------------------------------------------------------------------------
# CUSTOMIZED OPTIONS
#------------------------------------------------------------------------------
custom_variable_classes = 'general' # list of custom variable class names
general.application_version = 'v1.0'

When restarted, you can add general.application_version manually in PgAdmin (it will not show up in the drop-down - at least not for me). Otherwise, you can use it just like any other PostgreSQL variable.

Update for version 9.2 and newer

From PostgreSQL 9.2 onwards, we don't have to set custom_variable_classes anymore. One can set whatever variable they want - the only limitation seems to be it still has to have two parts:

SET something TO 'bla';
ERROR: unrecognized configuration parameter "something"
SET thing.something TO 'bla';
SET

I guess this is so to avoid collision with the builtin parameters.

answered Dec 7, 2012 at 6:08
2
  • Hmmm. No way to do that from a SQL query in the database? Commented Dec 7, 2012 at 12:50
  • You have to first define the variables in postgresql.conf. AFAIK this requires restarting PostgreSQL, so you can't do that from SQL. Commented Dec 7, 2012 at 12:55

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.