"Zhixuan Zhu" <zzhu@stripped> writes:
> So my question is: is there a way to get all the fields (item_fields)
> that are used in the query? They should include select list, where,
> having, group by, order by clause, subquery, and everything. Currently
> we're getting all select columns from select_lex.item_list. We then
> parse select_lex.join->conds to get the where clause columns. After that
> we get group by, order by, having clause columns by iterate group_list,
> order_list and having of select_lex. Besides the complexity of this
> solution, we're most concerned that some columns might be left out
> because we still can not interpret all the item types on the cond tree
> (like ref item) and we'll drop whatever we don't understand. We'll
> simply return NULL for the columns we drop. Thus MySQL will give a wrong
> result based on the NULL columns that it actually expects result back.
Can you use the table->write_set and table->read_set?
Generally, table->read_set gives you the columns that you need to fetch and
return to the SQL layer, and table->write_set gives the columns that you must
(for write_row(), you need to change all columns always, as this implements
REPLACE INTO, write_set just gives which columns are mentioned in the query,
but remaining columns must still be reset to default values).