Re: replication commands and log_statements - Mailing list pgsql-hackers

From Fujii Masao
Subject Re: replication commands and log_statements
Date
Msg-id CAHGQGwHDpy6nSxDkUKbUz2KkxTVBFXPKg6QbLz9AauOuX+dMuA@mail.gmail.com
Whole thread Raw
In response to Re: replication commands and log_statements  (Robert Haas <robertmhaas@gmail.com>)
Responses Re: replication commands and log_statements  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
On Thu, Jun 12, 2014 at 10:55 PM, Robert Haas <robertmhaas@gmail.com> wrote:
> On Wed, Jun 11, 2014 at 7:42 AM, Magnus Hagander <magnus@hagander.net> wrote:
>>> Replication commands like IDENTIFY_COMMAND are not logged even when
>>> log_statements is set to all. Some users who use log_statements to
>>> audit *all* statements might dislike this current situation. So I'm
>>> thinking to change log_statements or add something like log_replication
>>> so that we can log replication commands. Thought?
>>
>> +1. I think adding a separate parameter is the way to go.
>>
>> The other option would be to turn log_statements into a parameter that you
>> specify multiple ones
>
> I kind of like this idea, but...
>
>> - so instead of "all" today it would be "ddl,dml,all"
>> or something like that, and then you'd also add "replication" as an option.
>> But that would cause all sorts of backwards compatibility annoyances.. And
>> do you really want to be able to say things like "ddl,all" meanin you'd get
>> ddl and select but not dml?
>
> ...you lost me here.  I mean, I think it could be quite useful to
> redefine the existing GUC as a list.  We could continue to have ddl,
> dml, and all as tokens that would be in the list, but you wouldn't
> write "ddl,dml,all" because "all" would include everything that those
> other ones would log.  But then you could have combinations like
> "dml,replication" and so on.

Yep, that seems useful, even aside from logging of replication command topic.
OK, I've just implemented the patch (attached) which does this, i.e., redefines
log_statement as a list. Thanks to the patch, log_statement can be set
to "none",
"ddl", "mod", "dml", "all", and any combinations of them. The meanings of
"none", "ddl", "mod" and "all" are the same as they are now. New setting value
"dml" loggs both data modification statements like INSERT and query access
statements like SELECT and COPY TO.

What about applying this patch first?

Regards,

--
Fujii Masao

Attachment

pgsql-hackers by date:

Previous
From: Jeevan Chalke
Date:
Subject: Re: add line number as prompt option to psql
Next
From: Christoph Berg
Date:
Subject: Re: Is analyze_new_cluster.sh still useful?