[PATCH] two-arg current_setting() with fallback - Mailing list pgsql-hackers

From David Christensen
Subject [PATCH] two-arg current_setting() with fallback
Date
Msg-id 46069B54-AAEC-479C-98EA-5861416E206D@endpoint.com
Whole thread Raw
Responses Re: [PATCH] two-arg current_setting() with fallback
List 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




Attachment

pgsql-hackers by date:

Previous
From: Bruce Momjian
Date:
Subject: Re: "cancelling statement due to user request error" occurs but the transaction has committed.
Next
From: Tom Lane
Date:
Subject: Re: "cancelling statement due to user request error" occurs but the transaction has committed.