Re: RFC: pg_stat_logmsg
Joe Conway <mail@joeconway.com>
From: Joe Conway <mail@joeconway.com>
To: Pavel Stehule <pavel.stehule@gmail.com>
Cc: PostgreSQL-development <pgsql-hackers@postgresql.org>
Date: 2023-07-01T19:52:50Z
Lists: pgsql-hackers
Attachments
- pg_stat_logmsg-001.tgz (application/x-compressed-tar)
On 6/30/23 23:20, Pavel Stehule wrote: > so 1. 7. 2023 v 1:57 odesílatel Joe Conway <mail@joeconway.com > <mailto:mail@joeconway.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