[MDEV-32931] SESSION_TRACK_WARNINGS: Send warnings via session tracking Created: 2023-12-02  Updated: 2024-01-15

Status: Open
Project: MariaDB Server
Component/s: Protocol
Fix Version/s: 11.6

Type: New Feature Priority: Major
Reporter: Georg Richter Assignee: Ralf Gebhardt
Resolution: Unresolved Votes: 0
Labels: None

Issue Links:
PartOf
includes CONC-678 Retrieve warnings via SESSION_TRACK_W... Open

 Description   

Currently it is only possible to retrieve warnings by checking the warning count and retrieve the warnings afterwards via SHOW WARNINGS after processing all result sets.

This method has several flaws, since it is not always possible to retrieve all warnings, e.g. when calling a stored procedure or when executing multi (semicolon separated) statements:

MariaDB [test]> drop table if exists t1; drop table if exists t2;
Query OK, 0 rows affected, 1 warning (0.018 sec)
 
Query OK, 0 rows affected, 1 warning (0.005 sec)
 
MariaDB [test]> show warnings;
+-------+------+-------------------------+
| Level | Code | Message                 |
+-------+------+-------------------------+
| Note  | 1051 | Unknown table 'test.t2' |
+-------+------+-------------------------+

A better approach would be to send warnings (if requested by client) via session tracking as part of the OK packet for each statement.

If the client is interested in warnings, it will set the capability CLIENT_SESSION_TRACK and the new variable @@session_track_warnings:
Possible Values {-1,0,n}:

  • 0 don't send warnings (default)
  • n specifies the maximum number of warnings

If one or more warnings occur, the server sends back warnings within the OK packet:

  <int1>    Session change type: 0xFF  SESSION_TRACK_WARNINGS
  <intlenc> Total length
  while packet has remaining data
    <int2>    error/warning number
    <strlenc> warning text

If *@@session_track_warnings@@ was set to 0 (OFF), warnings can be still retrieved via SHOW WARNINGS.



 Comments   
Comment by Sergei Golubchik [ 2023-12-04 ]

I don't think we should do -1, it's counterintuitive. Just "number of warnings to send" is enough, 0 naturally disables the feature, any other value — enables it.

Comment by Georg Richter [ 2023-12-07 ]

Agreed - description updated

Generated at Thu Feb 08 10:35:06 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.