WL#6631: Detect transaction boundaries

Affects: Server-5.7   —   Status: Complete

NARRATIVE
---------

Add server flag to detect that a new transaction started.

DESCRIPTION
-----------

In a load-balanced setup, it is necessary to know when a statement resulted in
the start of a new transaction, which would allow connectors to switch to using
a different connection from the connection pool.

The critical case to detect is when the transaction is "fresh" and does not have
any reads or writes attached to it yet. This is the only case where a connector
can switch to using a different connection. If a statement starts a new 
transaction and starts adding reads or writes to it, it is not possible to move
the connection since it would imply a rollback.

To handle this case, a new server status item could be added to the response
packet to indicate when "work" has been added to a transaction.

The existing SERVER_STATUS_IN_TRANS flag provides baseline functionality to this
end, letting as detect when a transaction is active. This is sufficient
information to avoid moving a connection while a transaction is ongoing.
It does not however let us detect edges, so a session of the form
BEGIN ... COMMIT AND CHAIN ... COMMIT AND CHAIN ... COMMIT AND RELEASE
would have the flag set for its entire lifetime, and consequently, the
load-balancer would be unable to re-locate it.

Additional information indicating that a transaction may be active, but no
reads or writes have been attached (and there are no LOCKed TABLES)
would let the load balancer move connections more aggressively.

To break up such a "fresh" transaction (or element of a transaction
chain), the load balancer should be supplied with information about any flags
("READ ONLY", "ISOLATION LEVEL", "WITH CONSISTENT SNAPSHOT", ...) used in START
TRANSACTION, so the transaction can be recreated elsewhere with the same
characteristics. (In fact even flags set with SET TRANSACTION before the
transaction starts should be tracked correctly.)