[PATCH] Implement motd for PostgreSQL
Joel Jacobson <joel@compiler.org>
From: "Joel Jacobson" <joel@compiler.org>
To: pgsql-hackers@lists.postgresql.org,
"Michael Paquier" <michael@paquier.xyz>
Date: 2021-04-02T20:46:16Z
Lists: pgsql-hackers
Commits
Same data as JSON:
GET /api/v1/messages/:b64id/commits
the thread's linked commits as JSON, with link sources.
API reference →
-
Disallow newlines in parameter values to be set in ALTER SYSTEM.
- 99f3b5613bd1 9.6.0 cited
Attachments
- 0001-quote-newlines.patch (application/octet-stream) patch 0001
- 0002-motd.patch (application/octet-stream) patch 0002
Dear fellow hackers,
This patch is one day late, my apologies for missing the deadline this year.
PostgreSQL has since long been suffering from the lack of a proper UNIX style motd (message of the day).
DBAs have no ways of conveying important information to users,
having to rely on external protocols, such as HTTPS and "websites" to provide such information.
By adding a motd configuration parameter, the DBA can set this to a text string,
which will be automatically presented to the user as a NOTICE when logging on to the server.
While at it, fix escape_single_quotes_ascii() to properly escape newlines,
so that such can be used in ALTER SYSTEM values.
This makes sense, since parsing \n in config values works just fine.
To demonstrate the usefulness of this feature,
I've setup an open public PostgreSQL server at "pit.org",
to which anyone can connect without a password.
You need to know the username though,
which will hopefully make problems for bots.
$ psql -U brad -h pit.org motd
NOTICE:
____ ______ ___
/ )/ /
( / __ _ )
(/ o) ( o) )
_ (_ ) ) /
/_/ )_/
/ //| |\
v | | v
__/
This was accomplished by setting the "motd",
which requires superuser privileges:
$ psql motd
psql (14devel)
Type "help" for help.
motd=# ALTER SYSTEM SET motd TO E'\u001B[94m'
'\n ____ ______ ___ '
'\n / )/ \/ \ '
'\n ( / __ _\ )'
'\n \ (/ o) ( o) )'
'\n \_ (_ ) \ ) / '
'\n \ /\_/ \)_/ '
'\n \/ //| |\\ '
'\n v | | v '
'\n \__/ '
'\u001b[0m';
ALTER SYSTEM
motd=# SELECT pg_reload_conf();
pg_reload_conf
----------------
t
(1 row)
motd=# \q
Ascii elephant in example by Michael Paquier [1], with ANSI colors added by me.
[1] https://www.postgresql.org/message-id/CAB7nPqRaacwcaANOYY3Hxd3T0No5RdZXyqM5HB6fta%2BCoDLOEg%40mail.gmail.com
Happy Easter!
/Joel