From: | David Christensen <david(at)endpoint(dot)com> |
---|---|
To: | PostgreSQL-development Hackers <pgsql-hackers(at)postgresql(dot)org> |
Subject: | [PATCH] two-arg current_setting() with fallback |
Date: | 2015-03-19 23:16:08 |
Message-ID: | 46069B54-AAEC-479C-98EA-5861416E206D@endpoint.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | 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.
Attachment | Content-Type | Size |
---|---|---|
0001-Add-two-arg-for-of-current_setting-NAME-FALLBACK.patch | application/octet-stream | 7.0 KB |
unknown_filename | text/plain | 79 bytes |
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2015-03-19 23:19:02 | Re: "cancelling statement due to user request error" occurs but the transaction has committed. |
Previous Message | Bruce Momjian | 2015-03-19 23:09:00 | Re: "cancelling statement due to user request error" occurs but the transaction has committed. |