// For reference:
create table t1 (a int);
insert into t1 values (1),(2),(3);
create view v1 as (select a from t1);
Goal: 'UPDATE (SELECT a FROM t1) d SET a=0;' should work the same way as 'UPDATE v1 SET a=0;'
Experiment 1: What does select_lex, table_list→alias & table_list→updatable for d looks like near:

→ "<dbug_item_print_buf> "select a AS a from (select a AS a from t1) d"
→ table_list→alias {str = 0x7fff98015d08 "d", length = 1}
→ table_list→updatable= false
Because the property of updatability of derived tables is static we can set it during the initialization phase. Naturally, the question arises when is a derived table updatable? Lets right now go with a simple case and then move to a more complex case slowly.
Let's take case given above: 'UPDATE (SELECT a from t1) d SET a=0;'. So, if d is mergeable and base table t1 is updatable then derived table 'd' is updatable.
FACT TO REMEMBER: mysql_handle_derived goes from inner most select to outer most select and checking all tables in each select.
// Replacing this [inside mysql_derived_init]:
derived->updatable= derived->updatable && derived->is_view();
// With this: [for view derived->updatable is set inside mysql_make_view]
if (!derived->is_view())
{
derived->updatable= derived->is_merged_derived(); //marked inside init_derived
// Check if tables inside specification of 'derived' table are updatable
for (TABLE_LIST *tl=derived->next_global; tl; tl= tl->next_local)
{
if (!(derived->updatable= derived->updatable && tl->updatable))
break;
}
}
Lets check table_list→updatable. It is true now :)
For checking fields of derived table, I'll make changes in check_fields function later.
Experiment 2: Follow table_list→handle_derived(lex, DT_PREPARE) for view and derived table
function of interest: select_unit::create_result_table()
Will do this tomorrow
TODO:
→ Change updatability check inside mysql_derived_init to comply with complex cases.
→ Update check_fields to check fields for derived tables.