Re: Add support for logging the current role

From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: Stephen Frost <sfrost(at)snowman(dot)net>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Andrew Dunstan <andrew(at)dunslane(dot)net>, Itagaki Takahiro <itagaki(dot)takahiro(at)gmail(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Add support for logging the current role
Date: 2011-02-17 19:46:16
Message-ID: AANLkTikMadttguOWTkKLtgfe90kxR=U9njk9zEbRwb-+@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Thu, Feb 17, 2011 at 11:45 AM, Stephen Frost <sfrost(at)snowman(dot)net> wrote:
> Robert, if you say this has to be punted to 9.2 again, I'm giving up. ;)

Frankly, this patch has already consumed more than its fair share of
my attention. Having said that, I've just spent some more time on it.
I tightened up both the code and the docs a bit. I fixed
log_line_prefix so that it doesn't needlessly compute the value to be
used for %U when %U isn't used. I fixed the CSV logging code to do
proper escaping. Updated patch attached.

It seems there's at least one more thing to worry about here, which is
the overhead of this computation when CSV logging is in use. If no
SET ROLE or SET SESSION AUTHORIZATION commands are in use, the code
will call show_role(), which will return "none". We'll then strcmp()
that against "none" and decide to call show_session_authorization(),
which will call strtoul() to find the comma separator and then return
a pointer to the string that follows it. Now, none of that is
enormously expensive, so maybe it's not worth worrying about, but
since logging can be a hotspot, I thought I'd mention it and solicit
an opinion on whether that's likely to be a problem in practice.

--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

Attachment Content-Type Size
logrole-rmh.patch application/octet-stream 3.7 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Daniel Loureiro 2011-02-17 19:51:25 Coding style guide
Previous Message Dan Ports 2011-02-17 19:45:22 Re: SSI bug?