Issue 1: Locks not being passed down for derived tables.

Finally figured why it was not updating.
Time to find the proper code so this can work without using debugger.

// Found it
for (TABLE_LIST *tbl= tables->next_global; tbl; tbl= tbl->next_local)
{
tbl->lock_type= tables->lock_type;
tbl->mdl_request.set_type(tables->mdl_request.type);
tbl->updating= tables->updating;
}
Q Why do you put this code inside open_and_process_table?
→ Derived tables are not 'opened' as of their definition but can be processed during open_tables phase and open_and_process_table does both. That's why I choose this location for the code.
next_global does not look natural CHECK THIS WITH IGOR
Commit of today's work: https://github.com/rahulanand16nov/server/commit/15c0e678fd8b6f8239978c428e94bb067f40ed36
Next Issues to work on:
→ update (select * from t1) d set a=0; throws error: Unknown column 'a' in 'field list'
[unit→prepare is not called. check sql_derived.cc — mysql_derived_prepare]
→ Make changes so that queries like 'update (select a from (select a from t1) x) d set a=0' works.
[See how 'update v2 set a=0' works where v2 = 'select a from v1' and v1 = 'select a from t1']
TODO:
→ Making is_mergeable() property of a unit instead of a select_lex
→ Change updatability check inside mysql_derived_init to comply with complex cases. [Refer 11 June]
→ Update check_fields to check fields for derived tables. [Refer 11 June]
→ Make changes such that merge_underlying_list can take complex cases. [Refer 12 June]