WL#8170: Expression analyzer for GC

Status: Complete

The goal of this WL is to allow our range and ref optimizers to find
opportunities to use indexes defined over generated columns (GC). Intended use
of this feature is to allow building indexes over JSON documents.

Basic use case:
CREATE TABLE t1(f1 INT, gc INT AS (f1+1) STORED, KEY gc_idx(gc));
INSERT ...
SELECT * FROM t1 WHERE f1 + 1 > 9;

Optimizer should be able to use RANGE access for this query. This WL will
operate only STORED GCs as indexes over VIRTUAL GCs aren't available at the
moment. When they'll be ready, they'll be automatically used (with exception
of the primary key case below) as optimizer doesn't do any explicit checks for
a GC being stored or virtual.

Also, optimizer should take into account the comparison type: result type of
GC should match the result type of the expression it's compared to. E.g
following query wouldn't use index:

SELECT * FROM t1 WHERE f1 + 1 > 9.1;

The intended use case for it is following:

CREATE TABLE t1 (uuid BINARY(12), data JSON,
                 _gc1 INT AS MYJSON_EXTRACT(data, '$.id'),
                 _gc2 DOUBLE AS MYJSON_EXTRACT(data, '$.id'),
                 KEY _gc1_idx(_gc1),
                 KEY _gc2_idx(_gc2));

Before implementing native JSON indexes (in scope of another WL) result of
MYJSON_XX() functions would have to be casted to a particular SQL type in order
to allow proper indexing by InnoDB.

INSERT ...

SELECT ... FROM t1 WHERE MYJSON_EXTRACT(data, '$.id')=1;

After this WL is implemented, server should be able to generate ref access for
idx index. 

Another application of this WL is to allow to use an index over GC for sorting
and grouping:

CREATE TABLE t1(f1 INT, gc INT AS (f1+1) STORED PRIMARY KEY);
INSERT ...
SELECT * FROM t1 WHERE ... ORDER BY f1 + 1;

Optimizer should be able to use index for resolving ORDER BY clause in this
case.

CREATE TABLE t1(f1 INT, f2 INT, gc INT AS (f1+1) STORED PRIMARY KEY);
INSERT ...
SELECT f1+1, MAX(f2) FROM t1 WHERE ... GROUP BY f1 + 1;

Optimizer should be able to use loose index scan for such query.

Note that in both examples above the primary key is used, also the key should
be clustered. Since there is only one available primary key per table,
optimizer will use whatever type of GC used in it. If type conversion would
happen, it would be handled by server automatically, according to current type
conversion rules, this WL will not add/change anything in this area.