WL#8227: Support SEs to create index on virtual generated columns

Status: Complete

Server will provide info on the GC, both virtual and stored, in several
ways.
1) Info about GC's in general is stored in the Field::gcol_info.
GC's expression as string is available in Field::gcol_info::expr_str.
GC's expression as parsed and ready for execution Item tree is available at
Field::gcol_info::expr_item.
When handler::open is called, SE can check whether all functions used in the
GCs expressions are supported by SE. If not, SE should return an error
indicating that an expression in a GC isn't supported and mentioning the GC
in question.

The item tree is configured to use TABLE::record[0] as the data source.
In order to evaluate the expression SE should call 
  table->field->expr_item->save_in_field(table->field, false)
and check return value and thd->is_error(). If either is non-zero/true then
an error occur and should be propagated up to the server. Otherwise
evaluation was successful.

2) When record data is written to SE, e.g on INSERT/REPLACE/UPDATE, server
will calculate values of all GCs in the table and save them in the record
buffer. This is intended to be the main way of getting data for GCs into the
SE.

3) For command like on-line ALTER TABLE (i.e commands that are executed
inside SE and don't have direct access to the server) server will provide a
callback that would allow to calculate values of GCs.

/*

  @param[in] db     table's db 
  @param[in] name   table's name
  @param[in] fields table's fields needs to be calculated
  @param[in] buf    source and result buffer

  @return
    true   an error occur, values of GCs are undefined
    false GCs values successfully calculated 
*/
bool
my_eval_gcolumn_exprs(const char *db, const char *name, ulonglong fields,
                      const char *record);

Following limitations are applicable:
1) GCs which index is beyond 64 can't be calculated this way. Effectively
this means that on-line indexes on GCs beyond this limit aren't supported.
2) The thread calling this callback should be running one of
INSERT/REPLACE/UPDATE/ALTER/SELECT commands, error is returned otherwise.
3) Table should identify a single table that is opened already by the thread.
The callback relies on this and wouldn't check tables in e.g. the SELECT part
of INSERT ..SELECT, neither it will open another table.
4) Source buffer should be same size as TABLE::record[0] and hold
data in the MySQL record format.
5) Result of GCs calculations will be saved in the source and result buffer.
In order to obtain a value of a particular field the SE would have to call
e.g field->val_int() after calculation is done, or read from the buffer
directly.


Pseudo code for this function could look like following
bool
my_eval_gcolumn_exprs(const char *db, const char *name, ulonglong fields,
                      const char *record)
{
  THD *thd= current_thd;
  TABLE *table;
  char *old_buf;
  bool res= false;

  if (non_applicable_command(thd))
    return true;    // Wrong command
  if ((table= find_table_in_thd(thd, db, name))
    return true;    // Table not found
  old_buf= repoint_fields_to_record(table, fields, record);
  for (Field *fld= *table->fields; fld; fld++)
  {
    if (! ((fld->field_index - 1) & fields))
      continue;     // Skip unneeded fields
    if (fld->gcol_info->expr_item->save_in_field(fld, false)
        || thd->is_error())
    {
      res= true;
      break;
    }
  }
  repoint_fields_to_record(table, fields, old_buf);
  return res;
}