Mittwoch, 9. März 2016

Logging level at the client

Is it possible to change CLIENT_MIN_MESSAGES in a session such that its valid only for that session?

Yes it is. And it can be done by the session user such that there is no need for a superuser function to achieve that.

Command used to alter the session in plain SQL: set session client_min_messages to debug;
Anonymous PLPGSQL block used to test in the different sessions:
do language PLPGSQL
$anonymous$
declare
     V_SQL                    text;
     V_REC                    record;
begin
      raise debug     'Session ALTERED';
      raise log       'Session ALTERED';
      raise info      'Session ALTERED';
      raise notice    'Session ALTERED';
      raise warning   'Session ALTERED';
      raise exception 'Session ALTERED';
end;
$anonymous$


There is however something strange. The levels for the raise command are different from the levels the client_min_message parameter takes.
Offending code:
do language PLPGSQL
$anonymous$
declare
     V_SQL                    text;
     V_REC                    record;
begin
      set session client_min_messages to exception;
      raise debug     'Session ALTERED';
      raise log       'Session ALTERED';
      raise info      'Session ALTERED';
      raise notice    'Session ALTERED';
      raise warning   'Session ALTERED';
      raise exception 'Session ALTERED';
end;
$anonymous$


Error message (sorry for the German babble ;-) ):
do language PLPGSQL
$anonymous$
declare
     V_SQL                    text;
     V_REC                    record;
begin
      set session client_min_messages to exception;
      raise debug     'Session ALTERED';
      raise log       'Session ALTERED';
      raise info      'Session ALTERED';
      raise notice    'Session ALTERED';
      raise warning   'Session ALTERED';
      raise exception 'Session ALTERED';
end;
$anonymous$

A very brief search with Ecosia with "postgresql log level raise level mapping" has not revealed a mapping table for the levels. I leave this to be tested or search for to a later date probably just before I get killed by boredom that is at the Sankt-Nimmerleins-Tag.


Keine Kommentare:

Kommentar veröffentlichen