Re: Add support for logging the current role

Поиск
Список
Период
Сортировка
От Stephen Frost
Тема Re: Add support for logging the current role
Дата
Msg-id 20110214143007.GH4116@tamriel.snowman.net
обсуждение исходный текст
Ответ на Re: Add support for logging the current role  (Itagaki Takahiro <itagaki.takahiro@gmail.com>)
Ответы Re: Add support for logging the current role  (Itagaki Takahiro <itagaki.takahiro@gmail.com>)
Список pgsql-hackers
Itagaki,

* Itagaki Takahiro (itagaki.takahiro@gmail.com) wrote:
> We need to design csvlog_header more carefully. csvlog_header won't work
> if log_filename is low-resolution, ex. log-per-day.

This isn't any different a problem to the issue of someone changing the
csvlog_fields GUC but not checking if the log file already exists on
restart.  I've suggested a number of different options, but none of them
are terribly good, and I havn't heard anyone supporting any solution to
this issue.

> It's still useful when
> a DBA reads the file manually, but documentation would better.

Eh?  If you mean that we should add documentation to make users aware of
the possible issue of changing these values without making sure the log
file gets rotated- sure, I'd be happy to do that.

> Or, should we skip writing headers when the open log file is not
> empty?

This doesn't help the csvlog_fields issue, unfortunately.  I don't think
it'd be hard to implement this to help with the header issue, I'm just
not sure if it makes sense to do so when the actual list of fields could
change...

> * It might be my misunderstanding, but there was a short description for %U
> for in log_line_prefix in postgresql.conf, right? Did you remove it in the
> latest version?

No, and I don't see where I ever added it..  I've fixed it.

> * In assign_csvlog_fields(), we need to cleanup memory and memory context
> before return on error.
> +         /* check if no option matched, and if so, return error */
> +         if (curr_option == MAX_CSVLOG_OPTS)
> +             return NULL;

Fixed this and a couple of similar issues.

> * An added needless "return" should be removed.

Meh, I like explicit returns, but since it generated a hunk all by
itself, I'll clear it out.

Updated patch attached, git log below.

    Thanks,

        Stephen

commit 304e35ebb74f68da69163ed9dd1dd453b67181e7
Author: Stephen Frost <sfrost@snowman.net>
Date:   Mon Feb 14 09:26:03 2011 -0500

    csvlog_fields: fix leak, other cleanup

    Fix a couple of potential memory leaks in assign_csvlog_fields().
    Also added a few comments, removed an extra 'return;', and added
    %U to the sample postgresql.conf.

commit 592c256ffff4ffde77fc29ff28fdedd2c9f2dafd
Merge: 33639eb cebbaa1
Author: Stephen Frost <sfrost@snowman.net>
Date:   Sun Feb 13 21:11:44 2011 -0500

    Merge branch 'master' of git://git.postgresql.org/git/postgresql into log_csv_options

commit 33639ebfe67b0dd58a0a89161e9f0d5237830ed4
Author: Stephen Frost <sfrost@snowman.net>
Date:   Sun Feb 13 21:08:08 2011 -0500

    Add csvlog_header GUC, other cleanup

    This patch adds a csvlog_header option which will start each CSV
    log file with a header which matches the GUC (and hence the format
    of the CSV log file generated).

    Numerous other whitespace clean-ups, removed build_default_csvlog_list(),
    since it wasn't actually necessary or useful.  Added an array which
    lists the text strings of the various CSVLOG options to simplify
    assign_csvlog_fields().

commit 6bd2b9f1d2bc3b166a3e5598ee590e25159c61a5
Author: Stephen Frost <sfrost@snowman.net>
Date:   Fri Feb 11 11:16:17 2011 -0500

    Rename log_csv_fields GUC to csvlog_fields

    This patch renames the log_csv_fileds GUC to csvlog_fields, to better
    match the other csvlog_* options.

    Also cleaned up the CSV generation code a bit by moving the comma-adding
    code out of the switch() statement.

commit a281ca611e6181339e92b488c815e0cb8c1298d2
Merge: d8dddd1 183d3cf
Author: Stephen Frost <sfrost@snowman.net>
Date:   Fri Feb 11 08:37:27 2011 -0500

    Merge branch 'master' of git://git.postgresql.org/git/postgresql into log_csv_options

commit d8dddd1c425a4c320540769084ceeb7d23bc3662
Author: Stephen Frost <sfrost@snowman.net>
Date:   Sun Feb 6 14:02:05 2011 -0500

    Change log_csv_options listing to a table

    This patch changes the listing of field options available to
    log_csv_options into a table, which will hopefully both look
    better and be clearer.

commit f9851cdfaeb931f01c015f5651b72d16957c7114
Merge: 3e71e33 5ed45ac
Author: Stephen Frost <sfrost@snowman.net>
Date:   Sun Feb 6 13:26:17 2011 -0500

    Merge branch 'master' of git://git.postgresql.org/git/postgresql into log_csv_options

commit 3e71e338a2b9352d730f59a989027e33d99bea50
Author: Stephen Frost <sfrost@snowman.net>
Date:   Fri Jan 28 22:44:33 2011 -0500

    Cleanup log_csv_options patch

    Clean up of various function declarations to hopefully be correct
    and clean and matching PG conventions.  Also move TopMemoryContext
    usage to later, since the local variables don't need to be in
    TopMemoryContext.  Lastly, ensure that a comma is not produced
    after the last CSV field, and that one is produced if
    application_name is not the last field.

    Review by Itagaki Takahiro, thanks!

commit 1825def11badd661d219fa4c516f06e0ad423443
Merge: ff249ae 847e8c7
Author: Stephen Frost <sfrost@snowman.net>
Date:   Wed Jan 19 06:50:03 2011 -0500

    Merge branch 'master' of git://git.postgresql.org/git/postgresql into log_csv_options

commit ff249aeac7216da623bf77840380d5e767f681fc
Author: Stephen Frost <sfrost@snowman.net>
Date:   Wed Jan 19 00:26:52 2011 -0500

    Add log_csv_fields GUC for CSV output & curr_role

    This patch adds a new GUC called 'log_csv_fields'.  This GUC allows
    the user to control the set of fields written to the CSV output as
    well as the order in which they are written.  The default set of
    fields remains those that were included in 9.0, to avoid breaking
    existing user configurations.

    In passing, update 'user_name' for log_line_prefix and log_csv_fields
    to mean 'session user' (which could be reset by a superuser with
    set session authorization), and add a 'role_name' option (%U) to
    log_line_prefix and log_csv_fields, to allow users to log the
    current role (as set by SET ROLE- not impacted by SECURITY DEFINER
    functions).

Вложения

В списке pgsql-hackers по дате отправления:

Предыдущее
От: Andrew Dunstan
Дата:
Сообщение: Re: Debian readline/libedit breakage
Следующее
От: Frederik Ramm
Дата:
Сообщение: using a lot of maintenance_work_mem