Greetings, * Robert Haas (robertmh...@gmail.com) wrote: > 1. Why %o? That's not obviously mnemonic. Perhaps %U? > > 2. It won't be clear to people reading this what the difference is > between %u and this. You probably need to reword the documentation > for the existing option as well as documenting the new one. > > 3. Please attach the patch rather than including it inline, if possible.
Updated patch attached- commit 7319e8ddc91d62addea25b85f7dbe2f95132cdc1 Author: Stephen Frost <sfr...@snowman.net> Date: Wed Jan 12 10:23:13 2011 -0500 Use %U for role in log_line_prefix; improve docs Change the variable for logging the current role in log_line_prefix from %o to %U, to better reflect the 'user'-type mnemonic. Improve the documentation for the %U and %u log_line_prefix options to better differentiate them from each other. commit 3cb707aa9f228e629e7127625a76a223751a778b Author: Stephen Frost <sfr...@snowman.net> Date: Wed Jan 12 09:17:31 2011 -0500 Add support for logging the current role This adds a '%o' option to the log_line_prefix GUC which will log the current role. The '%u' option only logs the Session user, which can be misleading, but it's valuable to have both options. 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>%U</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 'U': + 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