Re: RFC: pg_stat_logmsg

From: Joe Conway <mail(at)joeconway(dot)com>
To: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: RFC: pg_stat_logmsg
Date: 2023-07-01 19:52:50
Message-ID: 22b9f497-74f2-733b-9181-7ba1040f649c@joeconway.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 6/30/23 23:20, Pavel Stehule wrote:
> so 1. 7. 2023 v 1:57 odesílatel Joe Conway <mail(at)joeconway(dot)com
> <mailto:mail(at)joeconway(dot)com>> napsal:
> Part of the thinking is that people with fleets of postgres instances
> can use this to scan for various errors that they care about.
> Additionally it would be useful to look for "should not happen" errors.
>
> I will register this in the July CF and will appreciate feedback.
>
> This can be a very interesting feature. I like it.

Thanks!

FWIW, I just modified it to provide the localized text of the elevel
rather than the internal number. I also localized the message format string:

8<------------------------------
psql (16beta2)
Type "help" for help.

test=# \x
Expanded display is on.
test=# select * from pg_stat_logmsg where elevel = 'ERROR' and
sqlerrcode = 'XX000' and count > 1;
-[ RECORD 1 ]---------------------------------------------
filename | tablecmds.c
lineno | 10908
elevel | ERROR
funcname | ATExecAlterConstraint
sqlerrcode | XX000
message | cannot alter constraint "%s" on relation "%s"
count | 2
-[ RECORD 2 ]---------------------------------------------
filename | user.c
lineno | 2130
elevel | ERROR
funcname | check_role_membership_authorization
sqlerrcode | XX000
message | role "%s" cannot have explicit members
count | 2

test=# set lc_messages ='sv_SE.UTF8';
SET
test=# select * from pg_stat_logmsg where elevel = 'FEL' and sqlerrcode
= 'XX000' and count > 1;
-[ RECORD 1 ]---------------------------------------------
filename | tablecmds.c
lineno | 10908
elevel | FEL
funcname | ATExecAlterConstraint
sqlerrcode | XX000
message | kan inte ändra villkoret "%s" i relation "%s"
count | 2
-[ RECORD 2 ]---------------------------------------------
filename | user.c
lineno | 2130
elevel | FEL
funcname | check_role_membership_authorization
sqlerrcode | XX000
message | rollen "%s" kan inte ha explicita medlemmar
count | 2
8<------------------------------

New tarball attached.

--
Joe Conway
PostgreSQL Contributors Team
RDS Open Source Databases
Amazon Web Services: https://aws.amazon.com

Attachment Content-Type Size
pg_stat_logmsg-001.tgz application/x-compressed-tar 14.8 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Kirk Wolak 2023-07-01 21:41:25 Re: Adding SHOW CREATE TABLE
Previous Message Noah Misch 2023-07-01 17:31:32 Re: ICU locale validation / canonicalization