Hi,

I think that the system variable tracker code has a lot of potential to improve both the user experience for command line clients (automatic out-of-band warnings) as well as improve the startup speed of connections created from many connectors by providing "early metadata" to them (MDEV-31609). This isn't strictly related to the connection redirection so I'll refrain from going on too big a tangent.

Repurposing @@version_comment would probably work and since it's been a "part of the version" for quite some time, a lot of clients probably print it as a part of the version like the mysql/mariadb command line clients do, however it might look a little weird in GUI software. Here's a quick proof-of-concept that I hacked by replacing the SELECT @@version_comment query the client does with one that reads data from a table. It at least shows that it works with the command line version:

$ mysql -S /tmp/rws.sock
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 9
Server version: 10.11.3-MariaDB-1:10.11.3+maria~ubu2204-log mariadb.org binary distribution

Hello, the time is 2023-08-18 10:18:23.
The weather looks good today.

Here's an AI generated poem:
MariaDB, a digital sea,
Tables weave a web, endlessly free.
Data's dance in rows and spaces,
A symphony of ones and zeros embraces.


Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]>

Making version_comment modifiable at runtime would probably be a nice first step that opens up more possibilities for these sorts of tricks. I still think that it would be better to reserve a variable name for passing out-of-band messages to clients, something like @@server_comment. It would already be very useful both for the MotD behavior demonstrated above but also for passing human-readable messages (possibly mid-query) without requiring any interaction from the client. This could then be used to pass the information intended for humans along with the information intended to be machine readable.

Markus

On 8/18/23 12:26, Otto Kekäläinen wrote:
Hi Markus!

I wrote down an idea for out-of-band warning messages in MDEV-31839 where by reserving one "system variable" for warnings, we can inject them to the initial OK packet that the client receives. This way clients that understand the server variable changes are able to display them to the users. The MariaDB Connector/C is already able to extract the system variable change information even if it's in the first OK packet sent after authentication. I found this sort of accidentally when I was testing some code for MDEV-31609.

I would not be surprised if after MDEV-31609 this could be implemented by just adding a dummy server_motd global variable that when set is sent to the clients.
The server supports a COMPILATION_COMMENT[1], which is shown in the
SQL console for connecting clients. This is already used in the wild
to e.g. inform users that an old version of MariaDB is out of support
and should no longer be used. If that field could be changed or
extended at run-time it could do the job you envision above - which
would be useful indeed as a generic way to communicate things to
users.


[1] https://github.com/MariaDB/server/blob/485c9b1fb320958b13253a49d4480ee9decf92f1/sql/sys_vars.cc#L4336-L4342
-- 
Markus Mäkelä, Senior Software Engineer
MariaDB Corporation