* Tom Lane (t...@sss.pgh.pa.us) wrote: > +1 for choosing something more mnemonic than "%o", btw.
Alright, not to be *too* ridiculous about this, but I'm feeling like '%R' might be better than '%U', if we don't mind overloading a single letter based on case. I've always been annoyed at the lack of distinction between 'user' and 'role' in our docs and feel it does lead to some confusion. Updated patch attached, if people agree. Compiles, passes regressions, works as advertised, etc. commit bba27fe63702405514ed2c3bb72b70cc178f9ce1 Author: Stephen Frost <sfr...@snowman.net> Date: Wed Jan 12 10:38:24 2011 -0500 Change log_line_prefix for current role to %R As we're going for a mnemonic, and this is really about roles instead of users, change log_line_prefix argument to %R from %U for current_role. Thanks, Stephen
*** a/doc/src/sgml/config.sgml --- b/doc/src/sgml/config.sgml *************** *** 3504,3510 **** local0.* /var/log/postgresql </row> <row> <entry><literal>%u</literal></entry> ! <entry>User name</entry> <entry>yes</entry> </row> <row> --- 3504,3515 ---- </row> <row> <entry><literal>%u</literal></entry> ! <entry>User name which was used to authenticate to <productname>PostgreSQL</productname> with</entry> ! <entry>yes</entry> ! </row> ! <row> ! <entry><literal>%R</literal></entry> ! <entry>Current role name, set via <command>SET ROLE</>, the current role identifier is relevant for permission checking</entry> <entry>yes</entry> </row> <row> *** a/src/backend/utils/error/elog.c --- b/src/backend/utils/error/elog.c *************** *** 1826,1831 **** log_line_prefix(StringInfo buf, ErrorData *edata) --- 1826,1841 ---- appendStringInfoString(buf, username); } break; + case 'R': + if (MyProcPort) + { + const char *rolename = GetUserNameFromId(GetUserId()); + + if (rolename == NULL || *rolename == '\0') + rolename = _("[unknown]"); + appendStringInfoString(buf, rolename); + } + break; case 'd': if (MyProcPort) {
signature.asc
Description: Digital signature