[PATCH] two-arg current_setting() with fallback

Поиск
Список
Период
Сортировка
От David Christensen
Тема [PATCH] two-arg current_setting() with fallback
Дата
Msg-id 46069B54-AAEC-479C-98EA-5861416E206D@endpoint.com
обсуждение исходный текст
Ответы Re: [PATCH] two-arg current_setting() with fallback  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-hackers
Apologies if this is a double-post.

Enclosed is a patch that creates a two-arg current_setting() function.  From the commit message:

The two-arg form of the current_setting() function will allow a
fallback value to be returned instead of throwing an error when an
unknown GUC is provided.  This would come in most useful when using
custom GUCs; e.g.:

  -- errors out if the 'foo.bar' setting is unset
  SELECT current_setting('foo.bar');

  -- returns current setting of foo.bar, or 'default' if not set
  SELECT current_setting('foo.bar', 'default')

This would save you having to wrap the use of the function in an
exception block just to catch and utilize a default setting value
within a function.



--
David Christensen
End Point Corporation
david@endpoint.com
785-727-1171




Вложения

В списке pgsql-hackers по дате отправления:

Предыдущее
От: Bruce Momjian
Дата:
Сообщение: Re: "cancelling statement due to user request error" occurs but the transaction has committed.
Следующее
От: Tom Lane
Дата:
Сообщение: Re: "cancelling statement due to user request error" occurs but the transaction has committed.