Database Reference
In-Depth Information
Writing a debugging_info function for developers
Several of the parameters controlling logging are reserved to be used by only superusers.
If you want to let some of your developers set logging on, and if you can write a function for
them to do just that:
create or replace function debugging_info_on()
returns void
security definer
as
$$
begin
set client_min_messages to 'DEBUG1';
set log_min_messages to 'DEBUG1';
set log_error_verbosity to 'VERBOSE';
set log_min_duration_statement to 0;
end;
$$ language plpgsql;
revoke all on function debugging_info_on() from public;
grant execute on function debugging_info_on() to bob;
You may also want to have a function to return to the default logging state by assigning
DEFAULT to all the variables:
create or replace function debugging_info_reset()
returns void
security definer
as
$$
begin
set client_min_messages to DEFAULT;
set log_min_messages to DEFAULT;
set log_error_verbosity to DEFAULT;
set log_min_duration_statement to DEFAULT;
end;
$$ language plpgsql;
No need to fiddle with GRANTs and REVOKEs here, as setting it back to default does not pose
a security risk. Instead of SET xxx to DEFAULT , you can also use a shorter version of the
same command, namely, RESET xxx .
Alternatively, you may just end your session, as the parameters are valid only for the
current session.
 
Search WWH ::




Custom Search