WL#7800: PERFORMANCE SCHEMA, SETUP_ACTORS ENABLED COLUMN

Affects: Server-5.7   —   Status: Complete   —   Priority: Medium

Performance_schema.setup_actors table is used to specify for which user/host
connection thread (foreground thread), instrumentation is supposed to be turned ON.

At present, if an entry for a user/host is found in setup_actors table,
instrumentation would be turned ON for that connection (foreground thread). If no
matching row for a user/host is found in setup_actors table, instrumentation for
that user/host connection thread is turned OFF. (keep in mind that %, if
specified, matches to all permissible user/host names).

Therefore, there is no (easy) way to specify the exclusion of a specific
user/host connection thread using setup_actors table. i.e. one can not say enable
all user/host except this one. To allow this, a new column ENABLED is to be
added in setup_actors table to make user capable of specifying exclusion as well.

By default, instrumentation for all foreground threads from all user/host is
Enabled.

Note: Internal (background) threads are unaffected i.e. Enabled.
TABLE performance_schema.SETUP_ACTORS
======================================

Add the following column after the ROLE column:

  `ENABLED` enum('YES','NO') NOT NULL

Operations
----------

The ENABLED column can be updated.

A user must have the proper privileges to perform these operations.

NOTE: Update on ENABLED column doesn't affect the existing foreground threads
from same user/host.

Semantic
========

See the existing documentation for 5.7:
http://dev.mysql.com/doc/refman/5.7/en/setup-actors-table.html

When the Performance Schema checks for a match in setup_actors, it tries to
find more specific matches first. For example, with a user U1 and host H1, it
looks for:
1. a match for 'U1' and 'H1'.
2. then for 'U1' and '%'.
3. then for '%' and 'H1'.
4. then for '%' and '%'.

NOTE: ROLE is still not considered for search.

With the added ENABLED column:
- when the first match returns a row with ENABLED=YES, the instrumentation is
turned ON for foreground threads (connection) from that user/host.
- when the first match returns a row with ENABLED=NO, the instrumentation is
turned OFF for foreground threads (connection) from that user/host.
- when no match is found, the instrumentation is turned OFF for foreground
threads (connection) from that user/host.

Default setup
=============

After the server completes the performance schema initialization,
the table SETUP_ACTORS is populated with the following default rules:

+------+------+------+---------+
| HOST | USER | ROLE | ENABLED |
+------+------+------+---------+
| %    | %    | %    | YES     |
+------+------+------+---------+

In other words, by default:
- Every foreground thread (connection) is instrumented irrespective of user/host.

Requirements
============

(1) Table performance_schema.setup_actors.
-------------------------------------------

Func-Req (1.1): A fresh MySQL installation of CURRENT-VERSION must create the
table performance_schema.setup_actors with the new ENABLED column.

Func-Req (1.2): An upgrade from PREVIOUS-VERSION to CURRENT-VERSION must create
the table performance_schema.setup_actors with the new ENABLED column.

Func-Req (1.3): Security privileges for column setup_actors.ENABLED
are enforced. This column can be updated, by users with the proper grants.

Func-Req (1.4): Table performance_schema.setup_actors contains, by default, the
following values:
- HOST="%", USER="%", ROLE="%", ENABLED="YES",