Avoid slow PL/pgSQL exception handling in example (#543)
This commit is contained in:
@@ -456,15 +456,16 @@ Here's a function to get the email of the currently authenticated
|
|||||||
user.
|
user.
|
||||||
|
|
||||||
```sql
|
```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
|
create or replace function
|
||||||
basic_auth.current_email() returns text
|
basic_auth.current_email() returns text
|
||||||
language plpgsql
|
language plpgsql
|
||||||
as $$
|
as $$
|
||||||
begin
|
begin
|
||||||
return current_setting('postgrest.claims.email');
|
return current_setting('postgrest.claims.email');
|
||||||
exception
|
|
||||||
-- handle unrecognized configuration parameter error
|
|
||||||
when undefined_object then return '';
|
|
||||||
end;
|
end;
|
||||||
$$;
|
$$;
|
||||||
```
|
```
|
||||||
|
|||||||
Reference in New Issue
Block a user