From c32d13c8f17cf6a46e2e001309e8262a784e40e7 Mon Sep 17 00:00:00 2001 From: Joe Nelson Date: Sun, 10 Apr 2016 15:36:32 -0700 Subject: [PATCH] Avoid slow PL/pgSQL exception handling in example (#543) --- docs/examples/users.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/docs/examples/users.md b/docs/examples/users.md index ed2613d2b..6ce38abbb 100644 --- a/docs/examples/users.md +++ b/docs/examples/users.md @@ -456,15 +456,16 @@ Here's a function to get the email of the currently authenticated user. ```sql +-- Prevent current_setting('postgrest.claims.email') from raising +-- an exception if the setting is not present. Default it to ''. +ALTER DATABASE your_db_name SET postgrest.claims.email TO ''; + create or replace function basic_auth.current_email() returns text language plpgsql as $$ begin return current_setting('postgrest.claims.email'); -exception - -- handle unrecognized configuration parameter error - when undefined_object then return ''; end; $$; ```