Avoid slow PL/pgSQL exception handling in example (#543)

This commit is contained in:
Joe Nelson
2016-04-10 15:36:32 -07:00
parent 0401a8eb13
commit c32d13c8f1
+4 -3
View File
@@ -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;
$$;
```