WL#9344: Logging services: error messages

Affects: Server-8.0   —   Status: Complete

LOG MESSAGES

Update the calls to error-logging in the server
code to leverage the new features introduced by 
WL#9323 and friends, "structured logging."


Review sql_print_*() calls in mysqld:

- At minimum, add a SQL error code

- Identify calls that appear repeatedly with same or similar
  messages, and collapse them into the same message (where possible)
  and the same error code code.  For these, the error code can
  replace the string literal -- the convenience wrapper will then
  fill in the well-known string for that error code).

- add additional log-items of interest 
  (where applicable -- OS error code, etc.)

- messages shall not be localized at this point



Due to the volume of this task and the design of the
new logging infrastructure, these calls can be switched
over incrementally, id est, in several batches.


RELATED CONCERNS

We currently derive our server error messages from a file, errmsg-utf8.txt, that 
contains messages in various languages. From this input, we create one 
errmsg.sys file per language, to be read by the server at runtime; we also 
create header files, include/mysqld_error.h and include/mysqld_ername.h, which 
contain the default C/English messages. These headers are already compiled into 
the server (as per trunk). Rather than to fail in the absence of an errmsg.sys, 
it is suggested that we fail back on the compiled-in messages. The benefits are 
obvious:
- simpler start-up (simpler configuration)
- more robustness (can still start-up when errmsg.sys is missing)
- less overhead (no need to read errmsg.sys when we already have the information 
compiled-in)
- option to later deprecate the i10n mechanism (errmsg.sys files and their 
loading and handling) for simpler, more streamlined code
- opportunity to keep on using the proven mechanism for the time being, without 
needing to inflate this WL

I.e. this will give us backward compatibility and "the best of both 
worlds" for now (the ability for a more straightforward startup on one 
side, and the option to overload the default error messages with rewritten or 
translated ones -- as far as "bulk" goes; individual messages could also be 
transformed in a log-filter component).  We'll retain the option to deprecate 
the message file at a later date, in favor of the simplicity of just the 
compiled-in English set, or for other solutions (e.g. reading the information 
from a table, rather than having a separate mechanism to access a custom file -- 
this would present the data in a way more familiar to the DBA).

The new messages are philsophically in the class of "messages emitted by the 
server", and as an implementation detail, sourced from errmsg-utf8.txt for the 
time being. For both these reasons, their indices will be in the range of the 
server messages. As a related concern, while the numeric indices are of obvious 
usefulness within the server, the structured logging stack aims to also provide 
the symbolic error-code ("ER_FOO_MISSING" instead of 4711 etc.) which should 
serve to both enhance readability and to somewhat shield the end user from the 
numeric values which are considered rather an implementation detail.