[type/__postgres_conf] Add psql_conf_source function to state explorer

This commit is contained in:
Dennis Camera 2021-04-15 09:04:07 +02:00
parent 2ccc03fef1
commit e0416403c4
1 changed files with 5 additions and 2 deletions

View File

@ -27,6 +27,10 @@ psql_exec() {
su - "${postgres_user}" -c "psql postgres -twAc $(quote "$*")"
}
psql_conf_source() {
# NOTE: SHOW/SET are case-insentitive, so this command should also be.
psql_exec "SELECT CASE WHEN source = 'default' OR setting = boot_val THEN 'default' ELSE source END FROM pg_settings WHERE lower(name) = lower('$1')"
}
psql_conf_cmp() {
test "$(psql_exec "SHOW $1")" = "$2"
}
@ -40,8 +44,7 @@ if psql_conf_cmp "${conf_name}" "$(cat "${__object:?}/parameter/value")"
then
echo present
else
# NOTE: SHOW/SET are case-insentitive, so this command should also be.
case $(psql_exec "SELECT CASE WHEN source = 'default' OR setting = boot_val THEN 'default' ELSE source END FROM pg_settings WHERE lower(name) = lower('${conf_name}')")
case $(psql_conf_source "${conf_name}")
in
('')
# invalid configuration parameter