16:00 — Investigating issue with resolution of fields in where inside derived tables.

16:15 — update (select a+1 as a1 from t1 where a1>0) dt1 set a1=0; We get: ERROR 1054 (42S22): Unknown column 'a1' in 'where clause'

update (select a as a1 from t1 where a1>0) dt1 set a1=0;

We get — segmentation fault.

earlier first query was also causing a segmentation fault but I changed nothing. weird.

17:08 — Break;

17:15 — Back;

17:38 — Merged DTs fields columns are represented as 'field_translations'

17:48 — Current select:

$27 = 0x5555579c84e0 <dbug_item_print_buf> "select t1.a + 1 AS a1 from t1 where a1 > 0"

/* Look up in current select's item_list to find aliased fields */

if (select && select->is_item_list_lookup) [Inside function: Item_field::fix_fields]

What is 'is_item_list_lookup' for? There is no comment in sql_lex.h for it.

I am assuming if it is set to true then we can look up in current select's item list.

18:06 — If we set this to true then item is found in the list by resolving against its alias.

18:09 — It works fine if we set 'is_item_list_lookup' to true.

So, I don't get why we have this in setup_conds:

bool save_is_item_list_lookup= select_lex->is_item_list_lookup; &

thd->lex->current_select->is_item_list_lookup= save_is_item_list_lookup;

because I could not find this item being changed by what is happening inside setup_conds (incl. other functions being called)