-- Deploy tipus:build_cookie to pg -- requires: roles -- requires: schema_tipus -- requires: current_user_email -- requires: current_user_cookie begin; set search_path to tipus, public; create or replace function build_cookie(user_email email default null, user_cookie text default null) returns text as $$ select coalesce(user_cookie, current_user_cookie()) || '/' || coalesce(user_email, current_user_email()); $$ language sql stable; revoke execute on function build_cookie(email, text) from public; grant execute on function build_cookie(email, text) to publisher; grant execute on function build_cookie(email, text) to admin; comment on function build_cookie(email, text) is 'Build the cookie to send to the user’s browser, either for the given values or for the current user.'; commit;