That's exactly what we want. Thank you very much!
Have a great day :)
From: Kristian Nielsen [mailto:knielsen@stripped]
Sent: Monday, May 11, 2009 12:15 PM
To: Zhixuan Zhu
Subject: Re: How to get all fields used in a select query
"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
> we get group by, order by, having clause columns by iterate
> 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
> 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
return to the SQL layer, and table->write_set gives the columns that you
(for write_row(), you need to change all columns always, as this
REPLACE INTO, write_set just gives which columns are mentioned in the
but remaining columns must still be reset to default values).