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

Attachment: 0001-quote-newlines.patch
Description: Binary data

Attachment: 0002-motd.patch
Description: Binary data

Reply via email to